Navigation Menu

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

Remove deprecated $php_errormsg usage #2680

Closed
ddb4github opened this issue May 9, 2019 · 2 comments
Closed

Remove deprecated $php_errormsg usage #2680

ddb4github opened this issue May 9, 2019 · 2 comments
Labels
bug Undesired behaviour resolved A fixed issue
Milestone

Comments

@ddb4github
Copy link
Contributor

ddb4github commented May 9, 2019

RHEL 8.0, SLES 15, and Ubuntu 18.04 had include PHP 7.2.x Out-of-Box.

Ref: https://www.php.net/manual/en/migration72.deprecated.php:

  • When the track_errors ini setting is enabled, a $php_errormsg variable is created in the
    local scope when a non-fatal error occurs. Given that the preferred way of retrieving such
    error information is by using error_get_last(), this feature has been deprecated.
./lib/html_utility.php: 
global $php_errormsg;
...
$php_error = trim(str_replace('preg_match():', '', $php_errormsg));

Possible Diff like

--- html_utility.php.orig       2019-05-09 23:29:05.862308613 +0800
+++ html_utility.php    2019-05-09 23:29:24.066158348 +0800
@@ -812,8 +812,6 @@
 }

 function validate_is_regex($regex) {
-       global $php_errormsg;
-
        if ($regex == '') {
                return true;
        }
@@ -828,7 +826,7 @@
                return true;
        }

-       $php_error = trim(str_replace('preg_match():', '', $php_errormsg));
+       $php_error = trim(str_replace('preg_match():', '', error_get_last()['message']));

        ini_set('track_errors', $track_errors);
  • This function(each) is far slower at iteration than a normal foreach, and causes implementation issues for some language changes. It has therefore been deprecated.
    like #2610 Fixing
./lib/tree.php:
while (list($_tier_key, $tier_array) = each($leaf_sort_array)) {
...
while (list($_search_key, $search_array) = each($tier_array)) {
...
while (list($_tier_key, $tier_array) = each($leaf_sort_array)) {
...
while (list($_search_key, $search_array) = each($tier_array)) {
...
while (list($leaf_order_key, $leaf_title) = each($search_array)) {

./graph_settings.php:
while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
...
while (list($field_name, $field_array) = each($tab_fields)) {
...
while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
...
while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
...
while (list($tab_short_name, $tab_fields) = each($settings_graphs)) {
...
while (list($field_name, $field_array) = each($tab_fields)) {
...
while (list($sub_field_name, $sub_field_array) = each($field_array["items"])) {
@ddb4github
Copy link
Contributor Author

ddb4github commented May 9, 2019

Move graph_export.php issue to new ticket under Plugin->GExport

And open another two ticket for thold and syslog plugin

Remove phpseclib issue from above main issue desc because phpseclib add version comparing for create_function usage

Also, lib/tree.php and graph_settings.php are not exist in Cacti 1.x. It is in my dirty env.

@ddb4github ddb4github changed the title PHP 7.2 supporting to remove deprecated $php_errormsg, create_function(), each() PHP 7.2 supporting to remove deprecated $php_errormsg, each() May 9, 2019
@cigamit cigamit added the bug Undesired behaviour label May 11, 2019
@cigamit cigamit added this to the v1.2.4 milestone May 11, 2019
@cigamit cigamit changed the title PHP 7.2 supporting to remove deprecated $php_errormsg, each() PHP 7.2 supporting to remove deprecated $php_errormsg May 11, 2019
cigamit added a commit that referenced this issue May 11, 2019
PHP 7.2 supporting to remove deprecated $php_errormsg
@cigamit
Copy link
Member

cigamit commented May 11, 2019

This is resolved. Thanks for verifying.

@cigamit cigamit added the resolved A fixed issue label May 11, 2019
@netniV netniV changed the title PHP 7.2 supporting to remove deprecated $php_errormsg Remove deprecated $php_errormsg usage Jun 2, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Undesired behaviour resolved A fixed issue
Projects
None yet
Development

No branches or pull requests

2 participants