News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Replace preg_replace with preg_replace_callback

Started by Combert, October 03, 2014, 04:08:52 AM

Previous topic - Next topic

Combert

In php 5.5 preg_replace is deprecated. This leads to error messages being posted on the site and in the logs.

I am not too good with php, so I am wondering if someone can create an update. It seems to be the Sources/Load.php file that contains several preg_replace functions.

margarett

Unfortunately that won't happen. It's far more complex than you might think.

You should really upgrade to 2.0.x ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Combert

Thank you for answering.

That sucks!  :)

Upgrading is also very complex. Especially if you have various mods installed.

May I ask why it is so complex to replace the functions? It seems, from googling, that it is not such a big operation. I just don't understand the regex and the returning of an anonymous function.

And you would think there would be a lot of SMF1 sites out there suddenly throwing these errors because their hosts have updated the PHP version.

margarett

I understand that...
But you need to consider that SMF 1.1.x is a 7-year old product that sooner or later WILL reach its end of life. And that EOL is now :P This was the last update it got and we will cease support when 2.1 final gets out...

It is impossible to support such an old product. Now its preg_replace, later other constraints would appear...
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Combert


Dragooon

preg_replace isn't deprecated, the /e modifier is which is what originally preg_replace_callback was designed for. 2.0.7 (2.0.6?) sort of fixed this issue and 2.1 properly fixes this issue since we bumped up to PHP 5.3 minimum, but for 1.1 I can't guarantee a fix since we need to move ahead and let things go. As said, 1.1 is a really old branch.

Hj Ahmad Rasyid Hj Ismail

Do the upgrading slow and steady. Some SMF 1.1.x can work on 2.0.x and most mods are already upgraded to 2.0.x or have their equivalents.

Combert

Yes, the use of /e is deprecated. I can totally understand that SMF1 is very old and SMF2 is the way forward and deserves time and attention over SMF1. And I am certainly not demanding anything be done. Just asking and hoping  :)

I guess it also depends on how easy/hard a fix it is. And I don't know that. Sometimes it just seems like its a matter of replacing a few lines of code.  ;)

Combert

Quote from: ahrasis on October 03, 2014, 06:18:26 AM
Do the upgrading slow and steady. Some SMF 1.1.x can work on 2.0.x and most mods are already upgraded to 2.0.x or have their equivalents.

Yes, I guess that is the best way forward in the long run too. Just dreading it a little bit.

Hj Ahmad Rasyid Hj Ismail

There is a fix for that or at least its replacement. I am sure of it but I am not very good with it. I wish I can help. :(

SMF will be dropping support for it when SMF 2.1 is to be properly released.

But hey, may be those who wish to keep SMF 1.1.x can form a group and create a forum that can help each other in fixing things for it. ;)

Illori

Quote from: ahrasis on October 03, 2014, 06:28:54 AM
But hey, may be those who wish to keep SMF 1.1.x can form a group and create a forum that can help each other in fixing things for it. ;)

really not a good idea as they would also need to be aware of security issues that may effect only 1.1 and would not be reported to them so they would not know to fix. upgrading to 2.0 would be the best option so they stay officially supported.

Antes

before upgrade, you can ask community which mods you are missing, maybe they'll offer you different solution/mod or even you maybe missing the feature in core build. So I suggest beside holding back, open new topic under SMF 2.0.x Support or Building Your Community and other Forum Advice.

Hj Ahmad Rasyid Hj Ismail

I know that Illori. I have advised them to upgrade earlier as well.

It is just an alternative if they wish to continue with it when the support is dropped. They may be a minority but they have their right to keep using SMF older version and to create association to do so. It won't hurt a bit and it is up to them anyway.

Of course, again, and as you said it, the best is still upgrading their forum to the latest with official support.

Illori

if they dont create security patches, then yes it will hurt as they will be vulnerable to hacking. in other words anyone running 1.1.* *needs* to upgrade to 2.0 so they can keep their forum secure.

Arantor

Let me just put it this way: it took several talented, competent programmers quite a number of hours to do it in SMF 2.0 since SMF 2.0 had the same problem. Doing it all again in 1.1.x would be quite a feat and none of them want to do it again.

Kindred

And, actually, ahrasis, since smf 1.1.x is not a fully open license, an external group could not do what you are suggesting.  They could form a commiseration group... But they would not be allowed  to distribute ANY SMF code....
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

Illori

Quote from: Kindred on October 05, 2014, 11:40:14 PM
And, actually, ahrasis, since smf 1.1.x is not a fully open license, an external group could not do what you are suggesting.  They could form a commiseration group... But they would not be allowed  to distribute ANY SMF code....

they could still make mod packages right?

margarett

Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Hj Ahmad Rasyid Hj Ismail

Personally, I am not interested either but it's just an option for them. I did some mod for SMF 1.1.x for the sake of learning the old SMF code.

I'll leave it for them to decide as I can see few are still attached to it.

TehCraw

* Carvin uses the simplest, shortest possible answer, automatically replacing every instance of preg_replace with @preg_replace.

MAUAHAAUUAHAHA!!!!!!1!1!!!1!1!1one1oneon1

Seriously though, this is probably not a good idea, nor does it actually fix the problem. But it does make the errors go away. ;)
Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

Advertisement: