WebSite X5Help Center

 
Jim S.
Jim S.
User

New search feature displaying php warnings because deprecated functions used  en

Auteur : Jim S.
Visité 641, Followers 1, Partagé 0  

On the search results page produced by the new search feature, I had this error:

Deprecated: Function create_function() is deprecated in /home/customer/www/cbcb.co.uk/public_html/res/x5engine.php on line 8466

From google, I found I can hide warnings from functions by putting @ before the function name. So in the file mentioned public_html/res/x5engine.php on line 8466 it said:

$html = preg_replace_callback('/\\s+/', create_function('$matches', 'return implode(\' \', $matches);'), $html);

So I put @ before create_function and the warning no longer appears:

$html = preg_replace_callback('/\\s+/', @create_function('$matches', 'return implode(\' \', $matches);'), $html);

@ is used on other functions in thethat file such as session_start() -  maybe this would be a long-term bugfix to do that for instances of create_function if that is really a deprecated function?

Posté le
6 RéPONSES
Aleksej H.
Aleksej H.
Moderator

Hello.What is your PHP version?

Try 7.2 - 7.4. Also disable the display of PHP error messages on the hosting.

Lire plus
Posté le de Aleksej H.
Jim S.
Jim S.
User
Auteur

I have tried PHP 7.2 and 7.3 (hosting lets me choose a number of versions from from 5.x to 8.0).

I don't think my hosting provider would want to to disable PHP error messages as I am on a shared server.

But it seems a bit drastic to disable all PHP errors just to overcome a problem with one PHP script that could be resolved by slightly changing the script itself.

Lire plus
Posté le de Jim S.
Aleksej H.
Aleksej H.
Moderator

"I don't think my hosting provider would want to to disable PHP error messages as I am on a shared server." - this can be done for an individual account.

"But it seems a bit drastic to disable all PHP errors just to overcome a problem with one PHP script that could be resolved by slightly changing the script itself." - As far as I understand, you received a warning, not an error.Warnings can be ignored.But I sent a notification about your question to the company employees, expect an answer from them here in the comments.

Lire plus
Posté le de Aleksej H.
Incomedia
Stefano G.
Incomedia

Hello Jim

As indicated by Aleksej, switching PHP warnings off is definitely the way to go. It causes no issues to the website itself and normally, they should be off by default if your website is live to avoid any unwanted situations manifesting considering they're meant for developing purposesonly. 

Please contact them first and have them disable those since they're not made to be active on a live website 

Let me know if you encounter further issues then

Thank you

Stefano

Lire plus
Posté le de Stefano G.
Axel  
Axel  
User
Meilleur utilisateur du mois FR

Into your PHPInfo, to check

Lire plus
Posté le de Axel  
Jim S.
Jim S.
User
Auteur

Thanks everyone. I found in my control panel I can change the relevant PHP variables as Axel suggested, so no more warnings displayed.

Lire plus
Posté le de Jim S.