-2

I'm not expert in PHP, my host claims a CPU usage problem on my web site.

I see on error_log a lot of these errors:

2023-03-02 11:16:46 Warning 114.119.159.129 mod_fcgid: stderr: PHP Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /data/vhosts/e-compa.com/httpdocs/smforum/Sources/Load.php(225) : runtime-created function on line 3 Errore di Apach

5.6.40 PHP

Do you know how to solve it?

I'm not expert in PHP

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Andrea
  • 1
  • 1
    Well you will have to change some code! But we cannot see the code, so its difficult to assist – RiggsFolly Mar 02 '23 at 10:26
  • Looks like a warning, not an error. It tells you exactly what to do: "The /e modifier is deprecated, use preg_replace_callback instead" – Mast Mar 02 '23 at 10:39
  • Is the line 3 to check? – Andrea Mar 02 '23 at 10:57
  • search on you code the `preg_replace` function, and post the code, to answer. – francisco Mar 02 '23 at 18:50
  • Here a part of code: global $func; return preg_replace(\'~^([ \t\n\r\x0B\x00' . $space_chars . ']| )+|([ \t\n\r\x0B\x00' . $space_chars . ']| )+$~' . ($utf8 ? 'u' : '') . '\', \'\', ' . implode('$string', $ent_check) . ');'), 'truncate' => create_function('$string, $length', (empty($modSettings['disableEntityCheck']) ? ' global $func; $string = ' . implode('$string', $ent_check) . ';' : '') . ' preg_match(\'~^(' . $ent_list . '|.){\' . $func[\'strlen\'](substr($string, 0, $length)) . \'}~'. ($utf8 ? 'u' : '') . '\', $string, $matches); – Andrea Jul 26 '23 at 00:14
  • Have I to replace some part of code? In which way? Thank you – Andrea Jul 26 '23 at 00:16

1 Answers1

-1

Problem description on the php docs:

When using the deprecated e modifier, this function escapes some characters (namely ', ", \ and NULL) in the strings that replace the backreferences. This is done to ensure that no syntax errors arise from backreference usage with either single or double quotes (e.g. 'strlen('$1')+strlen("$2")'). Make sure you are aware of PHP's string syntax to know exactly how the interpreted string will look.

Replace the deprecated funtion preg_replace() (on that php version) by the preg_replace_callback(), with proper code changes.

Many duplicates to help you like from SO.

francisco
  • 1,387
  • 2
  • 12
  • 23