SimpleMachines / SMF

Simple Machines Forum — SMF in short — is free and open-source community forum software, delivering professional grade features in a package that allows you to set up your own online community within minutes!
https://www.simplemachines.org/
Other
586 stars 253 forks source link

Autolinker tlds passed by reference #3689

Closed jdarwood007 closed 7 years ago

jdarwood007 commented 7 years ago

This introduces a new error

Notice : Only variables should be passed by reference in /smf21git/Sources/Subs.php on line 5710

In my Subs 5709 and 10 lines:

    // build_regex() returns an array. We only need the first item.
    $tld_regex = array_shift(build_regex($tlds));
jdarwood007 commented 7 years ago

@Sesquipedalian from PR #3680

Sesquipedalian commented 7 years ago

What version of PHP?

jdarwood007 commented 7 years ago

PHP 7.0.8-0ubuntu0.16.04.3

Sesquipedalian commented 7 years ago

Thanks, @jdarwood. I am currently travelling, so at the moment I can't directly test any fixes myself. Instead, could you please test what happens if you change line 5799 in your local copy from

$index_to_regex = function (&$index, $delim) use (&$strlen, &$index_to_regex)

to

$index_to_regex = function ($index, $delim) use (&$strlen, &$index_to_regex)
albertlast commented 7 years ago

Got the same issue, when i apply your changes i got: Fatal error: Maximum execution time of 30 seconds exceeded in G:\github\SMF2.1\Sources\Subs.php on line 5819 grafik

jdarwood007 commented 7 years ago

Seems to work if I do this:

    // build_regex() returns an array. We only need the first item.
    $temp = build_regex($tlds);
    $tld_regex = array_shift($temp);
Sesquipedalian commented 7 years ago

Well, it strikes me as odd that using a temporary variable is not necessary in PHP 5 but is in PHP 7. But hey, if it works, it works. I'll submit a PR including this change early next week (I won't return from my travels until then).

jdarwood007 commented 7 years ago

http://stackoverflow.com/questions/28477341/strict-standards-only-variables-should-be-passed-by-reference https://bugs.php.net/bug.php?id=48937

Seems to indicate this is how array_shift works and strict mode throws the warning.

Sesquipedalian commented 7 years ago

Thanks, @jdarwood007. That explains the issue nicely.