PKP Bugzilla – Bug 5028
Cannot return string offsets by reference in DataObject.inc.php
Last modified: 2010-01-11 19:23:25 PST
Fatal error: Cannot return string offsets by reference in /lib/pkp/classes/core/DataObject.inc.php on line 57
see http://journal.ciiss.net/index.php/ciiss/about/editorialTeamBio/28 as an example.
Found the error while unit testing DataObject, then while researching the error on the web the above URL appeared high in the rankings. I'm wondering why we didn't get this bug report earlier. Seems to be something very basic...
@Alec: Here again - can you give me a hint how I'd best grep this?
#5015 fixes this for DataObject, will leave the bug open until we checked that the same condition doesn't apply elsewhere.
This is a duplicate of #5029. With #5029 in mind the error can be explained like this:
Assume that the data array is initialized like this:
$this->data['somekey'] = 'somevalue';
The wrong test condition described in #5029 (isset() without is_array()) allowed the following access to the array:
$result =& $this->data['somekey']['some_locale'];
Which PHP internally resolves to:
$result =& $this->data['somekey'];
This is obviously an error as you cannot return a reference to a string offset in PHP (this being the 0'th character of the content of $this->data['somekey'] (='s', the first letter of 'somevalue').
*** This bug has been marked as a duplicate of bug 5029 ***