php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72214 variables doesn't passed node
Submitted: 2016-05-13 14:57 UTC Modified: 2016-05-13 22:42 UTC
From: schumacher1986 at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 7.0.7RC1 OS: windows
Private report: No CVE-ID: None
 [2016-05-13 14:57 UTC] schumacher1986 at hotmail dot com
Description:
------------
With the 7.0.7 RC1 i get Notice: Only variables should be passed by reference 

testing instruction:

Install Joomla. Change php version to 7.0.7 RC1

On the backend you getting a lot of notices.


Looks like the variables doesn't parsed correct anymore.

Test script:
---------------
public function __construct()
{
   $this->_root = new JMenuNode('ROOT'); 
   $this->_current = & $this->_root;
}


$menu->addChild(new JMenuNode(JText::_('MOD_MENU_CONTROL_PANEL'), 'index.php', 'class:cpanel'));



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-05-13 14:58 UTC] requinix@php.net
-Status: Open +Status: Feedback -Package: *General Issues +Package: Scripting Engine problem
 [2016-05-13 14:59 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2016-05-13 17:18 UTC] matias at avusto dot fi
Its not a bug in PHP, though I have no idea why PHP never had the notice shown before.


class JAdminCssMenu extends JObject
{
    public function addChild(JMenuNode &$node, $setCurrent = false) 
    {
        ...
    }
    ...
}

vs call to it:

$menu->addChild(new JMenuNode(JText::_('MOD_MENU_CONTROL_PANEL'), 'index.php', 'class:cpanel'));

Only variables can be passed to the function as the first parameter and what is passed is certainly not a variable.
 [2016-05-13 17:22 UTC] requinix@php.net
-Status: Feedback +Status: Not a bug
 [2016-05-13 17:22 UTC] requinix@php.net
Never *shown* it before. Your PHP 5 setup probably had notices suppressed.
 [2016-05-13 17:40 UTC] matias at avusto dot fi
Believe me, I have `error_reporting = E_ALL` in all of the PHP versions I've installed (using phpbrew). I'm just saying as Joomla has likely thousands of developers who have never seen this error before. 

I haven't tried PHP 7.0.7 builds yet, but I can say that there are no errors in the log files when I'm using PHP 7.0.6 (or any PHP version I've used in the past).
 [2016-05-13 18:07 UTC] requinix@php.net
-Status: Not a bug +Status: Verified
 [2016-05-13 18:07 UTC] requinix@php.net
Actually I just remembered that PHP 7 came with a reclassification of some strict warnings. The one I'm talking about was a strict before and a notice now.
https://wiki.php.net/rfc/reclassify_e_strict#only_variables_should_be_passed_by_reference

Just tried with 7.0.7RC1 too and I can confirm the message is appearing when it did not in 7.0.6.

Here's the thing: every expression used as a by-ref argument triggered the strict/notice message before - except for new objects. That code was actually working fine before. But I'm more inclined to see that exception as a bug and this change in behavior a bug fix; there would be new notices popping up but code would continue to work. So even though I'm switching this to Verified, it may not be a bug after all. Or maybe its fix is postponed until 7.1.
 [2016-05-13 22:11 UTC] matias at avusto dot fi
Here is the pull request to fix this for Joomla:

https://github.com/joomla/joomla-cms/pull/10452

Personally I think that the new behaviour is the correct one. It doesn't break anything and referencing objects is most of the time so PHP4... :)

I guess the only reason to pass object as reference is when you want to replace the object with something else, but then you'd want to pass variable instead to allow it to be read from outside.
 [2016-05-13 22:42 UTC] bwoebi@php.net
-Status: Verified +Status: Not a bug
 [2016-05-13 22:42 UTC] bwoebi@php.net
Right, that behavior is intentional. It was a long-term bug fix which somehow allowed objects to be passed by-reference without being actually a reference.

If the function expects a reference, you have to pass a reference.

Closing as Not a Bug...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Apr 28 23:01:32 2024 UTC