php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76691 bad result when using reference
Submitted: 2018-08-01 08:57 UTC Modified: 2018-08-07 07:18 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: dying318 at gmail dot com Assigned: cmb (profile)
Status: Not a bug Package: *General Issues
PHP Version: 7.2Git-2018-08-01 (Git) OS: macOs
Private report: No CVE-ID: None
 [2018-08-01 08:57 UTC] dying318 at gmail dot com
Description:
------------
the test script is ok, but when I remove the annotation at line 2, the findFirst will return a bad result,
Note: the findFinst is defined in phalcon framework.

Test script:
---------------
        $parameters = [[["id=470"]]];
//        $conditions = &$parameters[0]; // the problem code
        $model = Model::findFirst($parameters);
        echo $model->name , "<br>";
        echo $this->di->get('profiler')->getLastProfile()->getSQLStatement(), "<br>";



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-08-01 08:58 UTC] 641202944 at qq dot com
Note: the findFirst method is defined in phalcon.
 [2018-08-01 11:54 UTC] cmb@php.net
-Status: Open +Status: Feedback -Package: PECL +Package: *General Issues -Assigned To: +Assigned To: cmb
 [2018-08-01 11:54 UTC] cmb@php.net
> Note: the findFirst method is defined in phalcon.

Then why do you report the issue here?
 [2018-08-07 06:28 UTC] dying318 at gmail dot com
-Status: Feedback +Status: Assigned
 [2018-08-07 06:28 UTC] dying318 at gmail dot com
Embarrassing for the assuming, cause I don't know it is a bug from phalcon or something wrong with the reference. The parameters pass to findFirst is considered to be the same, but actually it is not, I wonder why this happened.
 [2018-08-07 07:03 UTC] requinix@php.net
-Status: Assigned +Status: Not a bug
 [2018-08-07 07:03 UTC] requinix@php.net
There is nothing inherently wrong with creating a reference, but apparently Phalcon is doing something with $parameters that is affected by [0] being a reference. So I suggest you not do that.

As for what or why, you'd have to ask the Phalcon people. If they say there is a PHP bug then we can always revisit this.
 [2018-08-07 07:18 UTC] dying318 at gmail dot com
OKļ¼Œthanks, I have ask. 
Additionally, even I do `unset($conditions)` after reference it to [0] (line 2) the result is also being bad.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 14:01:30 2024 UTC