Page MenuHomePhabricator

Warning with preSaveTransform (possibly PHP 5.3 specific)
Closed, ResolvedPublic

Description

Author: mwacker

Description:
This happened to my wiki after I upgraded to PHP 5.3. I haven't had this issue before.

When I try to preview changes being made to an article (in part or whole) or change the entire article, I get the following warning:

Warning: Parameter 2 to Parser::preSaveTransform() expected to be a reference, value given in /var/www/wiki/wiki/includes/StubObject.php on line 58

When I try to preview an article, it just gives me the warning. I can't see the preview, but nothing else happens. However, if I try to edit the entire article (the entire thing, the bug doesn't occur when I edit a specific part) and save the changes, it's followed up by an internal error. Here's the stack trace that follows:

Original exception: exception 'DBQueryError' with message 'A database error has occurred
Query: INSERT INTO text (old_id,old_text,old_flags) VALUES (NULL,NULL,'utf-8')
Function: Revision::insertOn
Error: 1048 Column 'old_text' cannot be null (localhost)
' in /var/www/wiki/wiki/includes/db/Database.php:636
Stack trace:
#0 /var/www/wiki/wiki/includes/db/Database.php(591): Database->reportQueryError('Column 'old_tex...', 1048, 'INSERT INTO `t...', 'Revision::inser...', false)
#1 /var/www/wiki/wiki/includes/db/Database.php(1311): Database->query('INSERT INTO `t...', 'Revision::inser...')
#2 /var/www/wiki/wiki/includes/Revision.php(802): Database->insert('text', Array, 'Revision::inser...')
#3 /var/www/wiki/wiki/includes/Article.php(1544): Revision->insertOn(Object(DatabaseMysql))
#4 /var/www/wiki/wiki/includes/Article.php(1376): Article->doEdit('Use the Taskmas...', 'added miscellan...', 98)
#5 /var/www/wiki/wiki/includes/EditPage.php(1011): Article->updateArticle('Use the Taskmas...', 'added miscellan...', false, false, false, '')
#6 /var/www/wiki/wiki/includes/EditPage.php(2392): EditPage->internalAttemptSave(false, false)
#7 /var/www/wiki/wiki/includes/EditPage.php(453): EditPage->attemptSave()
#8 /var/www/wiki/wiki/includes/EditPage.php(346): EditPage->edit()
#9 /var/www/wiki/wiki/includes/Wiki.php(505): EditPage->submit()
#10 /var/www/wiki/wiki/includes/Wiki.php(63): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#11 /var/www/wiki/wiki/index.php(114): MediaWiki->initialize(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#12 {main}

Exception caught inside exception handler: exception 'DBQueryError' with message 'A database error has occurred
Query: INSERT INTO text (old_id,old_text,old_flags) VALUES (NULL,NULL,'utf-8')
Function: Revision::insertOn
Error: 1048 Column 'old_text' cannot be null (localhost)
' in /var/www/wiki/wiki/includes/db/Database.php:636
Stack trace:
#0 /var/www/wiki/wiki/includes/db/Database.php(591): Database->reportQueryError('Column 'old_tex...', 1048, 'INSERT INTO `t...', 'Revision::inser...', false)
#1 /var/www/wiki/wiki/includes/db/Database.php(1311): Database->query('INSERT INTO `t...', 'Revision::inser...')
#2 /var/www/wiki/wiki/includes/Revision.php(802): Database->insert('text', Array, 'Revision::inser...')
#3 /var/www/wiki/wiki/includes/Article.php(1544): Revision->insertOn(Object(DatabaseMysql))
#4 /var/www/wiki/wiki/includes/Article.php(1376): Article->doEdit('Use the Taskmas...', 'added miscellan...', 98)
#5 /var/www/wiki/wiki/includes/EditPage.php(1011): Article->updateArticle('Use the Taskmas...', 'added miscellan...', false, false, false, '')
#6 /var/www/wiki/wiki/includes/EditPage.php(2392): EditPage->internalAttemptSave(false, false)
#7 /var/www/wiki/wiki/includes/EditPage.php(453): EditPage->attemptSave()
#8 /var/www/wiki/wiki/includes/EditPage.php(346): EditPage->edit()
#9 /var/www/wiki/wiki/includes/Wiki.php(505): EditPage->submit()
#10 /var/www/wiki/wiki/includes/Wiki.php(63): MediaWiki->performAction(Object(OutputPage), Object(Article), Object(Title), Object(User), Object(WebRequest))
#11 /var/www/wiki/wiki/index.php(114): MediaWiki->initialize(Object(Title), Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#12 {main}


Version: 1.14.x
Severity: normal

Details

Reference
bz18170

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:31 PM
bzimport set Reference to bz18170.
bzimport added a subscriber: Unknown Object (MLST).

mwacker wrote:

Ok, so I found a fix. It's so simple I'm just going to describe it. Go to line of 2981 of Article.php. Add an ampersand before the second argument.

return $wgParser->preSaveTransform( $text, $this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) );

should now be

return $wgParser->preSaveTransform( $text, &$this->mTitle, $wgUser, ParserOptions::newFromUser( $wgUser ) );

IAlex added a comment.Apr 1 2009, 5:22 PM

Yes, this is a PHP 5.3 specific issue, but passing "&$this->mTitle" as argument will emit an E_WARNING for those who have allow_call_time_pass_reference disabled.

IAlex added a comment.Apr 2 2009, 7:16 PM

fixed in r49142.

  • Bug 18375 has been marked as a duplicate of this bug. ***
Danny_B moved this task from Unsorted to PHP 5.3 on the [DO NOT USE] NewPHP board.Jul 11 2016, 2:04 AM