Page MenuHomePhabricator

1.26alpha / Notice: Array to string conversion in ... / Function: ApiStashEdit::checkCache
Closed, ResolvedPublic

Description

MediaWiki 1.26alpha (1747b12)
PHP 5.6.8 (apache2handler)
MySQL 5.6.24

and

$wgDBprefix = "mw-core";

$wgObjectCaches['redis'] = array(
    'class'                => 'RedisBagOStuff',
    'servers'              => array( '127.0.0.1:6379' )
);

$wgMainCacheType = 'redis';

failed for a normal article edit with:

Notice: Array to string conversion in ...\mw-core\includes\db\Database.php on line 2223
A database query error has occurred. This may indicate a bug in the software.

Query:
SELECT 1 FROM `mw-corepage` WHERE (Array) LIMIT 1
Function: ApiStashEdit::checkCache
Error: 1054 Unknown column 'Array' in 'where clause' (localhost)
Backtrace:

#0 ...\mw-core\includes\db\Database.php(1231): DatabaseBase->reportQueryError('Unknown column ...', 1054, 'SELECT  1  FROM...', 'ApiStashEdit::c...', false)
#1 ...\mw-core\includes\db\Database.php(1757): DatabaseBase->query('SELECT  1  FROM...', 'ApiStashEdit::c...')
#2 ...\mw-core\includes\db\Database.php(1424): DatabaseBase->select('page', '1', '(Array)', 'ApiStashEdit::c...', Array)
#3 ...\mw-core\includes\api\ApiStashEdit.php(289): DatabaseBase->selectField('page', '1', '(Array)', 'ApiStashEdit::c...')
#4 ...\mw-core\includes\page\WikiPage.php(2067): ApiStashEdit::checkCache(Object(Title), Object(WikitextContent), Object(User))
#5 ...\mw-core\includes\page\WikiPage.php(1756): WikiPage->prepareContentForEdit(Object(WikitextContent), NULL, Object(User), 'text/x-wiki')
#6 [internal function]: WikiPage->doEditContent(Object(WikitextContent), '', 98, false, NULL, 'text/x-wiki')
#7 ...\mw-core\includes\page\Article.php(2017): call_user_func_array(Array, Array)
#8 ...\mw-core\includes\EditPage.php(1948): Article->__call('doEditContent', Array)
#9 ...\mw-core\includes\EditPage.php(1948): Article->doEditContent(Object(WikitextContent), '', 98, false, NULL, 'text/x-wiki')
#10 ...\mw-core\includes\EditPage.php(1322): EditPage->internalAttemptSave(Array, false)
#11 ...\mw-core\includes\EditPage.php(557): EditPage->attemptSave(Array)
#12 ...\mw-core\includes\actions\EditAction.php(56): EditPage->edit()
#13 ...\mw-core\includes\actions\SubmitAction.php(40): EditAction->show()
#14 ...\mw-core\includes\MediaWiki.php(457): SubmitAction->show()
#15 ...\mw-core\includes\MediaWiki.php(255): MediaWiki->performAction(Object(Article), Object(Title))
#16 ...\mw-core\includes\MediaWiki.php(678): MediaWiki->performRequest()
#17 ...\mw-core\includes\MediaWiki.php(475): MediaWiki->main()
#18 ...\mw-core\index.php(41): MediaWiki->run()
#19 {main}

Event Timeline

mwjames raised the priority of this task from to Needs Triage.
mwjames updated the task description. (Show Details)
mwjames subscribed.

(Please associate at least one project with this task, otherwise nobody can find this task when searching in the corresponding project(s). Thanks!)

Change 224458 had a related patch set uploaded (by Aaron Schulz):
Fixed edit stash inclusion queries

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

Change 224458 merged by jenkins-bot:
Fixed edit stash inclusion queries

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

siebrand claimed this task.
siebrand subscribed.

Patch merged.

Can this patch be backported to MW 1.25, please? We are experiencing the same behavior under MW 1.25.1. I just upgraded to MW 1.25.2, but it does not include the patch, so I expect the bug to persist. Thanks.

Change 244453 had a related patch set uploaded (by Reedy):
Fixed edit stash inclusion queries

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

Change 244453 merged by jenkins-bot:
Fixed edit stash inclusion queries

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

Wow, that was fast! Thank you!!

Thanks! I came up with a different fix:

diff --git a/includes/db/Database.php b/includes/db/Database.php
index 99716a5..07edbd2 100644
--- a/includes/db/Database.php
+++ b/includes/db/Database.php
@@ -2037,7 +2037,11 @@ abstract class DatabaseBase implements IDatabase {
 			}
 
 			if ( ( $mode == LIST_AND || $mode == LIST_OR ) && is_numeric( $field ) ) {
+				if ( is_array( $value ) ) {
+					$list .= '(' . $this->makeList( $value, LIST_AND ) . ')';
+				} else {
 					$list .= "($value)";
+				}
 			} elseif ( ( $mode == LIST_SET ) && is_numeric( $field ) ) {
 				$list .= "$value";
 			} elseif ( ( $mode == LIST_AND || $mode == LIST_OR ) && is_array( $value ) ) {

Yours is more thorough.