Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 7.1 deprecations #3492

Closed
jdarwood007 opened this issue Jun 16, 2016 · 6 comments
Closed

PHP 7.1 deprecations #3492

jdarwood007 opened this issue Jun 16, 2016 · 6 comments

Comments

@jdarwood007
Copy link
Member

https://wiki.php.net/rfc/deprecations_php_7_1

We still make use of create_function and rand in a few places. We use create_function a lot more in 2.0, but that is outside the scope of this.

Zeus:SM-SMF2.1 jeremy$ grep -Rn "create_function" .
./other/install.php:39: 'validate_prefix' => create_function('&$value', '
./other/install.php:59: 'validate_prefix' => create_function('&$value', '
./other/install.php:76: 'validate_prefix' => create_function('&$value', '
./other/install.php:1345: create_function('$string', '
./other/install.php:1610: create_function('$string', '
./Sources/DbExtra-postgresql.php:34: 'db_get_engine' => create_function('', 'return 'PostgreSQL';'),

Zeus:SM-SMF2.1 jeremy$ grep -Rn "rand(" . | grep -v "mt_rand(" | grep -v "mt_srand(" | grep -v "array_rand("
./other/upgrade_2-0_mysql.sql:1518:$randomTime = 82800 + rand(0, 86399);
./Sources/Subs-Graphics.php:940: for ($i = 0; $i < rand(1, 5); $i++)
./Sources/Subs-Graphics.php:942: $x1 = rand(0, $total_width / 4);
./Sources/Subs-Graphics.php:943: $x2 = $x1 + round(rand($total_width / 4, $total_width));
./Sources/Subs-Graphics.php:944: $y1 = rand(0, $max_height);
./Sources/Subs-Graphics.php:945: $y2 = $y1 + round(rand(0, $max_height / 3));
./Sources/Subs-Graphics.php:1094: $x1 = round(rand(($total_width / 4) * -1, $total_width + ($total_width / 4)));
./Sources/Subs-Graphics.php:1095: $x2 = round(rand($total_width / 2, 2 * $total_width));
./Sources/Subs-Graphics.php:1096: $y1 = round(rand(($max_height / 4) * -1, $max_height + ($max_height / 4)));
./Sources/Subs-Graphics.php:1097: $y2 = round(rand($max_height / 2, 2 * $max_height));

@albertlast
Copy link
Collaborator

I fixed the pg part.

@MissAllSunday
Copy link
Contributor

I remember there was a discussion about changing the create_function calls on install, the main argument against it was that anyone not using 5.3 will just get a parser error rather than an explanation of why they can't install SMF.

I guess the same issue still applies but it should be less of a problem now.

@jdarwood007
Copy link
Member Author

We should avoid anonymous functions in the installer and upgrader then. They are ok after we validate they have a new enough version of PHP, in which we can then include them with require_once.

@MissAllSunday
Copy link
Contributor

I prefer to leave it as it is otherwise we will have to force a release when php7 becomes mainstream. Besides, the number of servers using 5.2 or less is only going to decrease which means as time goes by theres less chances for anyone to bump into this situation.

@jdarwood007
Copy link
Member Author

I was meaning we avoid using create_function or closures in the installer and use the traditional function anywhere. After we verify we verify they have a new enough PHP version, we can issue require_once to SMF files (as we generally do to handle redundant code. PHP doesn't test files called by require/include until it actually intends to use them. So it would allow us to do a version test safely.

@MissAllSunday
Copy link
Contributor

The validate_prefix calls can be replaced with plain functions bu it will be quite difficult to replace the $smcFunc['strtolower'] definition and usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants