Page MenuHomePhabricator

PHP Fatal error: Only variables can be passed by reference in includes/api/ApiBrowse.php
Closed, ResolvedPublic

Description

09.15 -rakkaus:#mediawiki-i18n- [17-Oct-2013 07:15:15 UTC] PHP Fatal error: Only variables can be passed by reference in /www/translatewiki.net/w/extensions/SemanticMediaWiki/includes/api/ApiBrowse.php on line 122


Version: master
Severity: normal

Details

Reference
bz55826

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 2:12 AM
bzimport set Reference to bz55826.
bzimport added a subscriber: Unknown Object (MLST).
Unknown Object (User) added a comment.Oct 17 2013, 1:07 PM

This is strange, neither Jenkins nor Travis kicked in since this part is covered [1]. Do you have the full stack trace?

[1] https://coveralls.io/files/68365996

I don't. And I do not know how to reliable reproduce this, so it is difficult to get one.

Unknown Object (User) added a comment.Oct 17 2013, 1:28 PM

(In reply to comment #3)

I try using [1].

[1] https://translatewiki.net/w/api.php?action=browse&subject=Main_Page

I'm already asleep. Of course, I meant "I tried".

Unknown Object (User) added a comment.Oct 17 2013, 1:31 PM

While fixing the issue shouldn't be the issue here, I'm more interested into why the unit tests didn't raise a flag on both CI's (Jenkins and Travis).

(In reply to comment #3)

I tr[ied] using [1].

[1] https://translatewiki.net/w/api.php?action=browse&subject=Main_Page

Yes, that produces it. :)

Not sure if this helps (missing params) but pasting anyway:

[17-Oct-2013 13:36:01 UTC] <ul>
<li>ApiBrowse.php line 122 calls wfBacktrace()</li>
<li>ApiBrowse.php line 97 calls SMW\ApiBrowse->addIndexTags()</li>
<li>ApiBrowse.php line 28 calls SMW\ApiBrowse->runFormatter()</li>
<li>ApiMain.php line 834 calls SMW\ApiBrowse->execute()</li>
<li>ApiMain.php line 380 calls ApiMain->executeAction()</li>
<li>ApiMain.php line 351 calls ApiMain->executeActionWithErrorHandling()</li>
<li>api.php line 73 calls ApiMain->execute()</li>
</ul>

Unknown Object (User) added a comment.Oct 17 2013, 1:55 PM

The following [1] should do the trick but I'd like to have the tests failing first before making any attempt on fixing this.

$tag =& $serialized['data'][ $key ]['dataitem'];
$this->getResult()->setIndexedTagName( $tag, 'value' );

Unknown Object (User) added a comment.Oct 17 2013, 6:08 PM

After looking into it, two issue came into play as to way the unit tests didn't catch the issue.

The first issue was caused by PHP 5.3 (I used and old 5.3.8 to verify the issue) which handles pass-by-reference for empty arrays differently and secondly $this->getResult()->setIndexedTagName() (responsible to add '_element' for XML output) applies internally a check whether getIsRawMode() is true/false which in case of the current unit test returns false and therefore will not engage in any array manipulation.

By setting $this->getResult()->setRawMode() in the unit test the error is caught which means I'll have to adjust the unit test in order to incorporate the setRawMode() option before fixing the issue which is doing an additional is_array() check.

Change 90389 had a related patch set uploaded by Mwjames:
(#bug 55826) Force ApiBrowse unit test to fail

https://gerrit.wikimedia.org/r/90389

Change 90389 merged by jenkins-bot:
(Bug 55826) Fix ApiBrowse unit test failure

https://gerrit.wikimedia.org/r/90389