Page MenuHomePhabricator

migrateOversightRevisions.php doesn't work with table aliases
Closed, ResolvedPublic

Description

I use table prefixes on my dev wiki for this specific reason

reedy@ubuntu64-web-esxi:/var/www/wiki/mediawiki/core/extensionsgit/Oversight$ php migrateToRevDel.php
Migrating oversighted revisions to suppressed revisions. This will not add anything to recentchanges.
A database query error has occurred.
Query: SELECT hidden_page as page_id,hidden_namespace as page_namespace,hidden_title as page_title,hidden_page as rev_page,hidden_comment as rev_comment,hidden_user as rev_user,hidden_user_text as rev_user_text,hidden_timestamp as rev_timestamp,hidden_minor_edit as rev_minor_edit,hidden_deleted as rev_deleted,hidden_rev_id as rev_id,hidden_text_id as rev_text_id,0 as rev_len,hidden_by_user,hidden_on_timestamp,hidden_reason,user_name,0 as page_is_new,0 as rc_id,1 as rc_patrolled,0 as rc_old_len,0 as rc_new_len,0 as rc_params,NULL AS rc_log_action,0 AS rc_deleted,0 AS rc_logid,NULL AS rc_log_type,NULL AS rev_parent_id,hidden.* FROM mw_hidden INNER JOIN mw_user ON ((user.user_id = hidden.hidden_by_user)) WHERE (hidden.hidden_rev_id > '-1') ORDER BY hidden_rev_id LIMIT 20
Function: MigrateOversightRevisions::execute
Error: 1051 Unknown table 'hidden' (192.168.0.212)

			$hiddenRows = $dbw->select(
				array( 'hidden', 'user' ),
				$selectFields,
				array( 'hidden.hidden_rev_id > ' . $dbw->addQuotes( $lastRevId ) ),
				__METHOD__,
				array( 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'hidden_rev_id' ),
				array( 'user' => array( 'INNER JOIN', 'user.user_id = hidden.hidden_by_user' ) )
			);

There's at least 2 usages there (maybe more in the whole file) of tablename.col, that does break for hidden and user queries

Simplest fix might be to just alias the tables when selecting the tables


Version: unspecified
Severity: normal

Details

Reference
bz60499

Event Timeline

bzimport raised the priority of this task from to Needs Triage.Nov 22 2014, 3:07 AM
bzimport set Reference to bz60499.
bzimport added a subscriber: Unknown Object (MLST).
Reedy created this task.Jan 27 2014, 9:49 PM

Change 109765 had a related patch set uploaded by Reedy:
Use table prefixes in migrateToRevDel.php

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

Change 109767 had a related patch set uploaded by Reedy:
Use table prefixes in migrateToRevDel.php

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

Change 109765 abandoned by Reedy:
Use table prefixes in migrateToRevDel.php

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

Change 109767 merged by Alex Monk:
Use table prefixes in migrateToRevDel.php

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

Should be fixed