Page MenuHomePhabricator

Error: 1066 Not unique table/alias: 'page_props'
Closed, ResolvedPublicPRODUCTION ERROR

Description

Error: 1066 Not unique table/alias:page_props
Impact

Special:Random does not function and instead returns:
[cef4f94deef31e1a8e6aa846] 2020-01-31 19:36:18: Fatal exception of type "Wikimedia\Rdbms\DBQueryError"

Notes

Installed software
Product Version
MediaWiki 1.34.0 (4ac8811)
17:38, 25 January 2020
PHP 7.3.11-1+0~rOMWC2019102616b8.48+debian9~1.gbpf71ca0 (fpm-fcgi)
MariaDB 10.2.24-MariaDB-10.2.24+maria~stretch-log
ICU 64.1
LuaSandbox 3.0.3
Lua 5.1.5
LilyPond 2.18.2
From - https://test1.miraheze.org/wiki/Special:Version

Details

Request URL
test1.miraheze.org/wiki/Special:Random
Stack Trace
	/wiki/Special:Random   Wikimedia\Rdbms\DBQueryError from line 1603 of /srv/mediawiki/w/includes/libs/rdbms/database/Database.php: A database query error has occurred. Did you forget to run your application's database schema updater after upgrading? 
Query: SELECT  page_title,page_namespace  FROM `page` LEFT JOIN `page_props` ON ((page_id = pp_page) AND pp_propname = 'softredirect') LEFT JOIN `page_props` ON ((page_id = pp_page) AND pp_propname = 'softredirect')   WHERE page_namespace IN ('4','0','250','252')  AND page_is_redirect = '0' AND (page_random >= 0.275534197787) AND pp_page IS NULL  ORDER BY page_random LIMIT 1  
Function: RandomPage::selectRandomPageFromDB
Error: 1066 Not unique table/alias: 'page_props' (mediawiki-internal-db-master.miraheze.org)

Event Timeline

RhinosF1 created this task.Jan 31 2020, 7:59 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJan 31 2020, 7:59 PM

I think this is likely a bug in an extension that uses the RandomPageQuery hook.

It looks like said extension is being executed twice.

For best safety, the extension should probably alias tables to ensure that it doesn't interfere with any other extension adding a page prop condition to the query

Bawolff added a comment.EditedJan 31 2020, 8:08 PM

Looks like problem is: https://github.com/wikimedia/mediawiki-extensions-SoftRedirector/blob/master/includes/SoftRedirectorHooks.php#L33

private static function excludeSoftRedirectPages( &$tables, &$conds, &$joinConds ) {
		$tables[] = 'page_props';
		$conds['pp_page'] = null;
		$joinConds['page_props'] = [
			'LEFT JOIN', [ 'page_id = pp_page', 'pp_propname' => 'softredirect' ]
		];
	}

It'd be better to do something like:

private static function excludeSoftRedirectPages( &$tables, &$conds, &$joinConds ) {
		$tables['softredirpp'] = 'page_props';
		$conds['softredirpp.pp_page'] = null;
		$joinConds['softredirpp'] = [
			'LEFT JOIN', [ 'page_id = softredirpp.pp_page', 'softredirpp.pp_propname' => 'softredirect' ]
		];
	}
MJL added a comment.Jan 31 2020, 8:25 PM

@Paladox Do you want me to commit the change or do you want to take care of this yourself?

Change 569279 had a related patch set uploaded (by Paladox; owner: Paladox):
[mediawiki/extensions/SoftRedirector@master] Fix alias in excludeSoftRedirectPages

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

Change 569279 merged by MJL:
[mediawiki/extensions/SoftRedirector@master] Fix alias in excludeSoftRedirectPages

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

Paladox closed this task as Resolved.Jan 31 2020, 8:48 PM
Paladox claimed this task.
Paladox removed Paladox as the assignee of this task.

Confirmed Fixed!