News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

SMF 2.0.17 to SMF 2.0.18 Uncaught Error: Call to undefined function pregReplaceC

Started by Lord Crudelito, February 28, 2021, 05:40:16 AM

Previous topic - Next topic

Lord Crudelito

Hi Community,

i updated my forum from 2.0.17 to 2.0.18 and had an issue with the SUBS.php. I used the automatic update function and received the following error:

Fatal error: Uncaught Error: Call to undefined function pregReplaceCurry() in /www/htdocs/xxxxx/smf/Sources/Subs.php:2995 Stack trace: #0 /www/htdocs/xxxx/smf/Sources/Subs.php(2885): parsesmileys('Das FMA-Team w\xFC...') #1 /www/htdocs/xxxx/smf/Sources/Subs.php(3711): parse_bbc('Das FMA-Team w\xFC...', true, 'news0') #2 /www/htdocs/xxx/smf/Sources/Subs.php(3864): setupThemeContext() #3 /www/htdocs/xxxx/smf/Sources/Subs.php(3317): template_header() #4 /www/htdocs/xxxx/index.php(155): obExit(NULL, true, true) #5 {main} thrown in /www/htdocs/xxxx/smf/Sources/Subs.php on line 2995

Afterwards, I had a look into the manual update guide => https://custom.simplemachines.org/upgrades/index.php?action=upgrade;file=smf_patch_2.0.18.tar.gz;smf_version=2.0.17
I have this error message if I delete the pregReplaceCurry()-function (operation 14 for Subs.php in the linked guide above). If I do not do this, it seems to work fine. Is it ok to stay with the update without operation 14 or do i have to re-adjust it? Did I miss to change something in a previous update? The last update worked fine with the "auto-update"-mode.

Thanks for your help,
Benjamin


LiBen

I don't see the function you describe in SMF 2.0.18
I have an old file from SMF 2.0.11 and there it's still present. I guess it got removed in one of the updates in between.

My advice: remove or dysfunction the lines. If you turn them off for testing first, it's easy to keep track of the change for now.

Select this:


}

// This allows use to do delayed argument binding and bring in the replacement variables for some preg replacements.
function pregReplaceCurry($func, $arity)
{
return create_function('', "
\$args = func_get_args();
if(count(\$args) >= $arity)
return call_user_func_array('$func', \$args);
\$args = var_export(\$args, 1);
return create_function('','
\$a = func_get_args();
\$z = ' . \$args . ';
\$a = array_merge(\$z,\$a);
return call_user_func_array(\'$func\', \$a);
');
");


and replace by:

   
    // turn off to test fix
/* }

// This allows use to do delayed argument binding and bring in the replacement variables for some preg replacements.
function pregReplaceCurry($func, $arity)
{
return create_function('', "
\$args = func_get_args();
if(count(\$args) >= $arity)
return call_user_func_array('$func', \$args);
\$args = var_export(\$args, 1);
return create_function('','
\$a = func_get_args();
\$z = ' . \$args . ';
\$a = array_merge(\$z,\$a);
return call_user_func_array(\'$func\', \$a);
');
"); */


shawnb61

The function was rrmoved in .18.

You need to find out where it is getting called from.   

It appears the 2.0.18 patch wasn't fully installed.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Lord Crudelito

Quote from: shawnb61 on February 28, 2021, 10:15:04 AM
The function was rrmoved in .18.

You need to find out where it is getting called from.   

It appears the 2.0.18 patch wasn't fully installed.

Thanks a lot for the quick reply. According to the error-message, it was called from line 2995 in the Subs.php.

This is line 2995:

// TODO: When SMF supports only PHP 5.3+, we can change this to "uses" keyword and simplify this.
[b]$callback = pregReplaceCurry('smielyPregReplaceCallback', 2);[/b]


The server where the forum is running, supports PHP 5.6 up to 7.4.


Quote from: LiBen on February 28, 2021, 06:51:38 AM
I don't see the function you describe in SMF 2.0.18
I have an old file from SMF 2.0.11 and there it's still present. I guess it got removed in one of the updates in between.

My advice: remove or dysfunction the lines. If you turn them off for testing first, it's easy to keep track of the change for now.

The function was removed in 2.0.18 but was part of the 2.0.17. It is called in my Subs.php in 2.0.18. I copied the function from the old Subs.php back in the 2.0.18. Subs.php and it seems to work fine for now as far as i can see..

shawnb61

I don't know how your code ended up that way - possibly either a mod or a manual edit somewhere along the line. 

The curry function & all references to it were removed in 2.0.18.  Line 2995 is actually a blank line in 2.0.18. 

The bottom of parsesmileys(), where those lines are found, has looked like this back in 2.0.17 & prior:
// TODO: When SMF supports only PHP 5.3+, we can change this to "uses" keyword and simplify this.
$context['smiley_replacements'] = $smileyPregReplacements;
$message = preg_replace_callback($smileyPregSearch, 'smileyPregReplaceCallback', $message);
}


I would try restoring it to this form.  If that doesn't work, I'd refresh the code & reinstall mods. 

The old curry function was removed because it uses a create_function, which is not supported in php 7.4. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: