reportheader.php is at SVN 6595, last changed on 21 Dec 2009, by me.
The way this is supposed to work is for the code to check for the presence of $attrs["access"]. If this is defined, $access is to be set to the value of the variable referenced by the value of $attrs["access']. Thus, in this case, the result should be
$access = $PRIV_USER
I'm not sure how PHP 7 is proposing to handle "use the value of the variable whose name is defined by the value of a string". That's what the code is trying to do.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If this works, you've demonstrated that PHP 7 doesn't like using the value of an array element as the name of a variable. This would then be either an undocumented change in the PHP language or a bug in this particular implementation of PHP. I'd vote for "bug".
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Seems to have eliminated the error messages. My poor knowledge of PHP, I would like to figure out a simple demo of the issue, and report against PHP 7.0.1
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
We are all struggling with the subtile changes in PHP7 when it comes to these interesting 'shortcuts' ... useful notes http://stackoverflow.com/questions/34092299/variable-variables-handling-order-changes-in-php-7
I've found many instances of code that now throws warnings and errors which needs the addition of extra temporary variables which to my mind defeats the elegence of the original PHP code. In this case the correct fix is I think just wrapping the $attrs["access"] in curly braces.
${$attrs["access"]} ... there are a couple of $$match[1] as well
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There are only three with square brackets ... the ones I idenified. The problem coes around when some sod decided that they should be able to read a string in an array as an array of characters. So you now have little idea if the [1] is a variable or a single letter ;)
I'm building a lean copy of the svn repo to which I'll add this change, along with the _._construct changes for the controllers. http://pgv7.lsces.org.uk is a mirror of my PHP5 version so I'm getting things under control.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Lester:
I've gone through ALL of the code, and "corrected" all occurrences of $$, whether they were ambiguous or not. It remains to be seen whether this works. I DID notice that there were already a number of occurrences of constructs like ${$foo} in there.
I'll let you know.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
PHP 7.0.1
98: if (isset($$attrs["access"])) {
I plugged in a var_dump($attrs);
and got following:
array(2) { ["access"]=> string(9) "PRIV_USER" ["icon"]=> string(5) "place" }
Confessing I don't understand variable variables.
--
Vince
Last edit: vince-br549 2015-12-28
Hmmm should this be svn 7117? How does one find the version, in the downloaded files?
reportheader.php is at SVN 6595, last changed on 21 Dec 2009, by me.
The way this is supposed to work is for the code to check for the presence of $attrs["access"]. If this is defined, $access is to be set to the value of the variable referenced by the value of $attrs["access']. Thus, in this case, the result should be
$access = $PRIV_USER
I'm not sure how PHP 7 is proposing to handle "use the value of the variable whose name is defined by the value of a string". That's what the code is trying to do.
Don't discount the possibility that this code has uncovered a bug in PHP itself.
You could try replacing lines 98 to 100 in file "includes/reportheader.php" with the following:
If this works, you've demonstrated that PHP 7 doesn't like using the value of an array element as the name of a variable. This would then be either an undocumented change in the PHP language or a bug in this particular implementation of PHP. I'd vote for "bug".
Seems to have eliminated the error messages. My poor knowledge of PHP, I would like to figure out a simple demo of the issue, and report against PHP 7.0.1
Just tested 7118 on PHP 5.6.16, this problem does not show up.
bug ? echo "report":fix phpged;
v
We are all struggling with the subtile changes in PHP7 when it comes to these interesting 'shortcuts' ... useful notes
http://stackoverflow.com/questions/34092299/variable-variables-handling-order-changes-in-php-7
I've found many instances of code that now throws warnings and errors which needs the addition of extra temporary variables which to my mind defeats the elegence of the original PHP code. In this case the correct fix is I think just wrapping the $attrs["access"] in curly braces.
${$attrs["access"]} ... there are a couple of $$match[1] as well
Hmmmm, NOT nice.
I guess I'll have to go through all of the code, and add those curly braces wherever there is an occurrence of $$. What a pain.
There are only three with square brackets ... the ones I idenified. The problem coes around when some sod decided that they should be able to read a string in an array as an array of characters. So you now have little idea if the [1] is a variable or a single letter ;)
I'm building a lean copy of the svn repo to which I'll add this change, along with the _._construct changes for the controllers.
http://pgv7.lsces.org.uk is a mirror of my PHP5 version so I'm getting things under control.
Lester:
I've gone through ALL of the code, and "corrected" all occurrences of $$, whether they were ambiguous or not. It remains to be seen whether this works. I DID notice that there were already a number of occurrences of constructs like ${$foo} in there.
I'll let you know.