Last modified: 2012-11-01 18:03:57 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T29360, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 27360 - PHP "Only variables should be passed by reference" error when running maintenance script SMW_refreshdata.php
PHP "Only variables should be passed by reference" error when running mainten...
Status: RESOLVED FIXED
Product: MediaWiki extensions
Classification: Unclassified
Semantic MediaWiki (Other open bugs)
unspecified
All All
: Low minor (vote)
: ---
Assigned To: Markus Krötzsch
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-02-12 12:33 UTC by Gijs van Haastrecht
Modified: 2012-11-01 18:03 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Gijs van Haastrecht 2011-02-12 12:33:07 UTC
When installing and executing the PHP script "SMW_refreshdata.php" in extensions/SemanticMediaWiki/maintenance, I get the following error:

"PHP Strict Standards:  Only variables should be passed by reference in C:\xampp\
htdocs\mediawiki\extensions\SemanticMediaWiki\includes\storage\SMW_SQLStore2.php
 on line 839"

a number of times. Not sure what the impact is.

Further details: I am installing SMW+ extensions, after which I run the "SMW_refreshdata.php" script.
Comment 1 Gijs van Haastrecht 2011-02-12 12:34:11 UTC
It happened after installing the automaticsemanticforms of SMW+.
Comment 2 Markus Krötzsch 2011-02-12 15:38:32 UTC
This is not an error but merely a notice that points to a use of PHP functions that is not completely conforming to the specification. Production sites should be configured to not show these messages at all (php.ini defines what is shown, do not enable STRICT and NOTICE unless you are a developer). 

In your case, the reason for the message might be a number of uses of reset() on return values of functions. We will be eliminating these at some point. A number of calls to the function end() have recently been eliminated in SVN. Neither cause problems in practice.
Comment 3 Jeroen De Dauw 2011-02-13 13:57:40 UTC
This looks like an SMW+ issue really. The warning is probably coming from automaticsemanticforms making an incorrect call to the SMW SQL store. 

In any case, whet version of SMW are you using? Did it came bundled with SMW+ (and have a bunch of patches with it)? If so, you should report this to Ontoprise.
Comment 4 Gijs van Haastrecht 2011-02-13 21:02:25 UTC
Thanks for answering.
I got the latest version of both SMW (1.5.5)and SMW+ (1.5.2).
I thought it might be SMW+ wrongly calling SMW methods as well.
Will report it to them.
Comment 5 Jeroen De Dauw 2011-02-13 21:05:20 UTC
Markus: Unless you disagree with this being SMW+s doing it wrong, this can be marked as invalid.
Comment 6 Markus Krötzsch 2011-02-14 09:43:18 UTC
Our code still has things like

$dv = reset( $data->getPropertyValues( $property ) );

which should cause this message to appear as well (or does it not?). If this is the case, the bug should remain open until we rewrote all such uses to something like

$values = $data->getPropertyValues( $property );
$dv = reset( $values );

I wonder if there isn't a more direct way of getting the first/last element of a PHP array without assigning it to a variable first.
Comment 7 Jeroen De Dauw 2011-02-14 15:24:19 UTC
Indeed there is: 

$dv = array_shift( $data->getPropertyValues( $property ) );

For the last element you can use array_pop()
Comment 8 Markus Krötzsch 2011-02-14 16:06:26 UTC
As I read the documentation [1], array_shift also assumes a call-by-ref parameter, so should yield the same message.

[1] http://php.net/manual/en/function.array-shift.php
Comment 9 Markus Krötzsch 2012-11-01 18:03:57 UTC
I have just checked our code for all uses of reset(), array_shift() and array_pop(). I think it is safe to close this bug now.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links