Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: Sir Osis of Liver on April 12, 2024, 09:54:31 PM

Title: set_magic_quotes_runtime() error
Post by: Sir Osis of Liver on April 12, 2024, 09:54:31 PM
This is a bit difficult to explain, but will try.  Client 2.0.19 forum has been offline for a while since host (SiteGround) moved account to new server.  Had a look last night and found root index.php with permissions set to 00.  Was unable to change permissions via ftp, don't have cpanel access, but was able to rename it and upload clean 2.0.19 index.php and forum loaded normally with some errors.  Restored original file and asked client to see if he could change permissions with filemanager (he couldn't) or ask host support to do it.  Well, host support did it, but also messed with other things, and now forum will not load, server displays this error -

Fatal error: Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /home/customer/www/hydroseeding.org/public_html/jcms/forum/index.php:41 Stack trace: #0 {main} thrown in /home/customer/www/hydroseeding.org/public_html/jcms/forum/index.php on line 41

From server log -

[12-Apr-2024 13:55:10 UTC] PHP Fatal error:  Uncaught Error: Call to undefined function set_magic_quotes_runtime() in /home/customer/www/hydroseeding.org/public_html/jcms/forum/index.php:41
Stack trace:
#0 {main}
  thrown in /home/customer/www/hydroseeding.org/public_html/jcms/forum/index.php on line 41


Same with clean index.php, which worked last night.  set_magic_quotes_runtime() was deprecated in php 7.4.0, removed in 8.0.0.  Phpinfo reports server is running php 7.4.33, set_magic_quotes_runtime() is used in 2.0.19 core index.php, so it should work.  Just to make it more annoying, this is the code, line 41 is the last line -


// Get everything started up...
define('SMF', 1);
//if (version_compare(PHP_VERSION, '7.4.0') == -1 && function_exists('set_magic_quotes_runtime'))
// @set_magic_quotes_runtime(0);
error_reporting(defined('E_STRICT') ? E_ALL | E_STRICT : E_ALL);
$time_start = microtime();

// This makes it so headers can be sent!
ob_start();

// Do some cleaning, just in case.
foreach (array('db_character_set', 'cachedir') as $variable)
if (isset($GLOBALS[$variable]))
unset($GLOBALS[$variable], $GLOBALS[$variable]);


   (https://thekrashsite.com/pics/hairpull1.gif)


Title: Re: set_magic_quotes_runtime() error
Post by: Oldiesmann on April 13, 2024, 11:42:11 PM
I'm not sure why function_exists() would be returning true there if the function doesn't exist (or why PHP_VERSION would be reporting something lower than 7.4.0 if they're on 7.4.33), but it should be safe to leave that commented out either way (also, an old version of the PHP manual I found here (http://php.adamharvey.name/manual/en/function.set-magic-quotes-runtime.php) says that function was removed in 7.0.0, but it's not even listed on PHP's website anymore so who knows). I would also recommend doing your best to convince the client to find a better host.
Title: Re: set_magic_quotes_runtime() error
Post by: Sir Osis of Liver on April 14, 2024, 01:15:25 PM
We got it running by restoring a backup, he was able to change the file permissions using file manager.  It's now up and running without errors.  The original problem was the 00 permissions for index.php, that happened when host migrated forum to different server.  Appeared to be deliberate, no other files were affected.  Everything that went wrong after that was done by host support.