We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

PHP 5.5 | Forum

Topic location: Forum home » Support » General Questions
DeFender
DeFender Sep 1 '13
site not working if I switch to php 5.5
ross Team
ross Sep 2 '13

PHp 5.5 is the newest version of php and was released relatively recently. Which is why we do not support it in the meantime. Probably the php developers have made changes and we'll have to adjust the software for php 5.5. We'll be grateful if you PM me your error logs which pop up with php 5.5. and we'll do necessary changes for the stable work of upcoming release. Thanks. 

The Forum post is edited by ross Sep 2 '13
Hisham Qaddoumi
Hisham Qaddoumi Sep 9 '13
Hello @ross. I posted about this before as you know the error was clear:


Message:preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead

File:/home/hishamqa/public_html/oxwall/ow_utilities/string.php

Line:130


I read the PHP 5.5 manual and I realzed they had deprecated this function completely:

http://php.net/manual/en/migration55.deprecated.php


They suggest to use preg_replace_callback because, as some developers said, it's better for server resource consumption. This will make Oxwall work on all PHP versions because this function is supported from PHP4.5. Now this needs some fixing on the code level for functions in (ow_utilities/string.php) to match the new function requirements. I believe this is something that really need to be considered seriously because it's better for servers and widely supported.

ross Team
ross Sep 10 '13
thank you Hisham, 


I'll report that to our developers in one of the upcoming releases this will be fixed. 

va
va Sep 23 '13
Change string 130 in ow_utilities/string.php from


        return preg_replace('/{\$(\w+)}/ie', "isset(\$vars['\\1']) ? \$vars['\\1'] : '\\0'", $data);


to

        return preg_replace_callback('/{\$(\w+)}/i', 

                function($match) use ($vars) 

                { 

                    return (isset($vars["$match[1]"]) ? $vars["$match[1]"] : $match[0]);

                }, 

                $data);



UPDATE: my first version is wrong, because create_function can't use external variable $vars:

        return preg_replace_callback('/{\$(\w+)}/i', create_function('$match', 'return isset($vars["$match[1]"]) ? $vars["$match[1]"] : $match[0];'), $data);   - INCORRECT!

The Forum post is edited by va Sep 27 '13
ross Team
ross Sep 23 '13
thank you VA, 

I'll report that to our developers in one of the upcoming releases this will be fixed. 

va
va Sep 26 '13
Ross, my first solution was incorrect. PHP create_function can't use external variables. So the old function always returns $match[0], never $vars[$match[1]]... I  updated my post #5 to the correct solution.
Hisham Qaddoumi
Hisham Qaddoumi Oct 6 '13
Thank you VA very much!


Works fine for me, I'll continue testing and I'll let you know if something pops up. Appreciate your help :)

Krespov
Krespov Oct 12 '13

Quote from va Change string 130 in ow_utilities/string.php from


        return preg_replace('/{\$(\w+)}/ie', "isset(\$vars['\\1']) ? \$vars['\\1'] : '\\0'", $data);


to

        return preg_replace_callback('/{\$(\w+)}/i', 

                function($match) use ($vars) 

                { 

                    return (isset($vars["$match[1]"]) ? $vars["$match[1]"] : $match[0]);

                }, 

                $data);



UPDATE: my first version is wrong, because create_function can't use external variable $vars:

        return preg_replace_callback('/{\$(\w+)}/i', create_function('$match', 'return isset($vars["$match[1]"]) ? $vars["$match[1]"] : $match[0];'), $data);   - INCORRECT!


Hi VA, I made the changes as you suggest, but I still get a portion of code displayed in the page like these:



 I understand that you have volunteered to post a solution to the original problem with PhP.5.5; I am sorry to bother you, but I would like to encourage you to continue helping, because this way you will be saving the day to a lot of users of OW.

Many thanks in advance.

Regards,

The Forum post is edited by Krespov Oct 12 '13
Krespov
Krespov Oct 12 '13
I am replying to myself....
After browsing the site for a while, the code is not displayed again; therefore, the solution posted by VA is a good one. It works !!
Thanks VA.

Regards,