MyBB Community Forums

Full Version: PHP 5.5.0 Deprecated: preg_replace
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Greetings dear MyBB team.

Recently the provider I am hosting several MyBB forums has upgraded its PHP version to 5.5.0
Ever since, all of my forums show several lines of error messages when viewing topics. I have different versions installed for troubleshooting purposes, and every version I have up including 1.6.10 is having this problem.
I even attempted a clean installation of 1.6.10 to see if there might be a plugin or other changed option being the root of all evil. Sadly, it isn't. Even with a fresh and clean installation I get said error message. I have copied the full header of error when reading the first topic created on this fresh installation (( I have replaced the URL to my webspace with asterisks for safety's sake and put the dashes at random places, in case you wonder )).
This seems like MyBB isn't fully capable of running on PHP 5.5 ?

Quote:Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 642

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 354

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 354

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 354

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 354

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 354

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 354

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 380

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 381

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 382

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 383

Deprecated: preg_replace() [function.preg-replace]: The /e modifier is deprecated, use preg_replace_callback instead in /******/******/inc/class_parser.php on line 389


Since this is a clean installation, I fear I have to wait for 1.6.11 to properly accomodate PHP 5.5.0, or is there something I can do other than plowing through hundreds of lines of code? I have next to no experience with manually changing files, so I am afraid to screw up at some point when I try fixing the problem on my own. On some forums the error lines are several pages long which refer to the class_parser.php

The search function didn't allow me to search for "php 5.5" because the minimum characters I have to type are 4.
When searching for "deprecated" or "class_parser" or "preg_replace" I do not get any results related to this problem.

The webhost is bplaced.net, and has MySQLi version 5.5.27
Their support states that this affects a lot of forum systems now, and that we would need to wait for an official patch to deal with this, and for those who don't want to wait, they should disable the command in the respective line with an @ . I am not sure if this is not causing more problems and would be detrimental to the use of my forum, so I would like to hear what the experts have to say on this.
I remember I had to do this with the magic_quotes thing, but thankfully this was a problem that could be neatly solved. This one looks a bit more intimidating though.
Here is the link that shows the full functions of said webhost: http://www.phpinfo.bplaced.net/

I look forward to any helping hints, and thank you for your time Smile
MyBB does not yet support PHP 5.5. We'll be resolving this in MyBB 1.6.11. Until then you should ask your host to move you to a server with PHP 5.4 or below. We have not yet fully tested MyBB on PHP 5.5 so there may be other issues we need to fix.
From the looks of it that deprecated notice shouldn't be showing. If you're looking for a workaround you can try replacing:

if(function_exists("unicode_decode"))
{
    // Unicode extension introduced in 6.0
    error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE ^ E_STRICT);
}
elseif(defined("E_DEPRECATED"))
{
    // E_DEPRECATED introduced in 5.3
    error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE);
}
else
{
    error_reporting(E_ALL & ~E_NOTICE);
}

with:

error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE);

in ./inc/init.php.
I remember the webhost support saying in an earlier issue I read about that they do not have old versions for users, so when they upgrade, they do it for everyone. They do change certain variables on the software on a user specific level if they ask nicely and if the thing is simple enough to do.

Where exactly should I place that line of code? I am sorry if I am a pain :/
Should I really replace the entire "If" function with it? Ah well, let me just try and see what happens, I can upload the original file if things go bonkers.

1) replacing the entire block with the line did not help. I am testing on the clean installation now. forced refresh and emptying cache isn't helping. So I tried to mix and match other things:

2) removing just the " e_strict" part in the error reporting isn't helping.
3) replacing the last line at "else" with the line you mentioned to paste, isn't working.
4) commenting out the line mentioned in "elseif" and "else" with an @ isn't working.
5) commenting out the entire "if" as well as "elseif" and "else" selection with an @ isn't working and causes another error, which only proves I am a dumb user and should have used // Smile
6) Just removing the entire block you mentioned and not replacing it with anything else, solved the problem. But that cannot be the solution, right? Which functionality am I shutting down by removing this? What problems am I going to run in by deleting this snippet?

EDIT:
Removing the "elseif" and "else" part and only keeping the "if" one, is working too. but I guess it is still causing other issues?
MyBB handles this correctly, and the notice shouldn't be shown or logged. You should contact your host and ask them about it. On my development VM no notice is shown or logged so it looks like an environment issue.

error_reporting(E_ALL ^ E_DEPRECATED ^ E_NOTICE) tells PHP to ignore any PHP notices or deprecated messages. Silencing the individual calls shouldn't be needed here.
So basically what I am doing when deleting the block (or just the "elseif" and "else" sections) is stopping the error reporting and nothing else. I am not disabling vital functions of MyBB that would hinder me using the product at any other fronts as long as I am not going wild with ridiculous plugins. Should I run into a future error and not know what happens, I should re-enable the error logging and see what is causing the trouble.

And when the new 1.6.11 comes, the init.php file will be updated anyway so all the changes I did to the old will be removed because the file is overwritten anyway.

Are both paragraphs about right? Smile
Quote:Are both paragraphs about right? Smile

Yes, but it's recommended that the host look in to the issue. If it's affecting other accounts it can affect both them and us in terms of the amount of support requests. I'm 99% sure this isn't a MyBB issue.
Host support says:

"Well, it is a MyBB issue because they are using a parameter which shouldn't be used anymore in the first place. Back in PHP 5.4 the same issue was worked out silently, only since 5.5 it starts visibly nagging around.
" The /e modifier is deprecated. Use preg_replace_callback() instead. " ( source link )

Furthermore, the host support says to filter out the comment lines in the affected file with a @ because that is only affecting the error messages related to preg_replace, whereas skipping the block in the init.php is killing all possible - and useful - error messages. Other users have had their problems resolved with commenting out said lines in the files.

I will be the middle man in the correspondence and translate around for the time being Smile
The fact is, the deprecated notice shouldn't be showing. error_reporting() is set correctly. Either they're forcing the notices to be shown, or it's a bug in PHP 5.5. As I said, I have PHP 5.5 installed on my development VM and there are no issues.

E_DEPRECATED and E_NOTICE shouldn't be enabled in production.
Or just edit class_parser.php
Pages: 1 2