With the introduction of CommentStore, selects from various table
require certain joins or column aliases for proper operation. The
upcoming actor table change, and the suggested title table change, will
add more such requirements.
Change-Id: Ic8213bff74b8350b15cd271d0ef252e63e7e79bd
15 files changed:
$layer = [];
$res = $this->dbr->select(
/* FROM */ 'categorylinks',
$layer = [];
$res = $this->dbr->select(
/* FROM */ 'categorylinks',
+ /* SELECT */ [ 'cl_to', 'cl_from' ],
/* WHERE */ [ 'cl_from' => $this->next ],
__METHOD__ . '-1'
);
/* WHERE */ [ 'cl_from' => $this->next ],
__METHOD__ . '-1'
);
# Protect the redirect title as the title used to be...
$res = $dbw->select(
'page_restrictions',
# Protect the redirect title as the title used to be...
$res = $dbw->select(
'page_restrictions',
+ [ 'pr_type', 'pr_level', 'pr_cascade', 'pr_user', 'pr_expiry' ],
[ 'pr_page' => $pageid ],
__METHOD__,
'FOR UPDATE'
[ 'pr_page' => $pageid ],
__METHOD__,
'FOR UPDATE'
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
}
$this->db->selectDB( $this->getVar( 'wgDBname' ) );
- if ( $this->db->selectRow( 'interwiki', '*', [], __METHOD__ ) ) {
+ if ( $this->db->selectRow( 'interwiki', '1', [], __METHOD__ ) ) {
$status->warning( 'config-install-interwiki-exists' );
return $status;
$status->warning( 'config-install-interwiki-exists' );
return $status;
* $setOpts += Database::getCacheSetOptions( $dbr );
*
* // Load the row for this file
* $setOpts += Database::getCacheSetOptions( $dbr );
*
* // Load the row for this file
- * $row = $dbr->selectRow( 'file', '*', [ 'id' => $id ], __METHOD__ );
+ * $row = $dbr->selectRow( 'file', File::selectFields(), [ 'id' => $id ], __METHOD__ );
*
* return $row ? (array)$row : false;
* },
*
* return $row ? (array)$row : false;
* },
*
* // Load the rows for these files
* $rows = [];
*
* // Load the rows for these files
* $rows = [];
- * $res = $dbr->select( 'file', '*', [ 'id' => $ids ], __METHOD__ );
+ * $res = $dbr->select( 'file', File::selectFields(), [ 'id' => $ids ], __METHOD__ );
* foreach ( $res as $row ) {
* $rows[$row->id] = $row;
* $mtime = wfTimestamp( TS_UNIX, $row->timestamp );
* foreach ( $res as $row ) {
* $rows[$row->id] = $row;
* $mtime = wfTimestamp( TS_UNIX, $row->timestamp );
$row = $dbr->selectRow(
'uploadstash',
$row = $dbr->selectRow(
'uploadstash',
+ [
+ 'us_user', 'us_key', 'us_orig_path', 'us_path', 'us_props',
+ 'us_size', 'us_sha1', 'us_mime', 'us_media_type',
+ 'us_image_width', 'us_image_height', 'us_image_bits',
+ 'us_source_type', 'us_timestamp', 'us_status',
+ ],
[ 'us_key' => $key ],
__METHOD__
);
[ 'us_key' => $key ],
__METHOD__
);
$repo = RepoGroup::singleton()->getLocalRepo();
do {
$repo = RepoGroup::singleton()->getLocalRepo();
do {
- $res = $dbr->select( 'image', '*', [ 'img_name > ' . $dbr->addQuotes( $start ) ],
+ $res = $dbr->select( 'image', LocalFile::selectFields(),
+ [ 'img_name > ' . $dbr->addQuotes( $start ) ],
__METHOD__, [ 'LIMIT' => $this->mBatchSize ] );
foreach ( $res as $row ) {
$numImages++;
__METHOD__, [ 'LIMIT' => $this->mBatchSize ] );
foreach ( $res as $row ) {
$numImages++;
$bestBlock = null;
$res2 = $db->select(
'ipblocks',
$bestBlock = null;
$res2 = $db->select(
'ipblocks',
[
'ipb_user' => $row->ipb_user,
]
[
'ipb_user' => $row->ipb_user,
]
$withdiff = 0;
$parserCache = MediaWikiServices::getInstance()->getParserCache();
while ( $pages-- > 0 ) {
$withdiff = 0;
$parserCache = MediaWikiServices::getInstance()->getParserCache();
while ( $pages-- > 0 ) {
- $row = $dbr->selectRow( 'page', '*',
+ $row = $dbr->selectRow( 'page',
+ // @todo Title::selectFields() or Title::getQueryInfo() or something
+ [
+ 'page_namespace', 'page_title', 'page_id',
+ 'page_len', 'page_is_redirect', 'page_latest',
+ ],
[
'page_namespace' => $this->getOption( 'namespace' ),
'page_is_redirect' => 0,
[
'page_namespace' => $this->getOption( 'namespace' ),
'page_is_redirect' => 0,
$afile = false;
} else { // specified version
$dbw = $this->getDB( DB_MASTER );
$afile = false;
} else { // specified version
$dbw = $this->getDB( DB_MASTER );
- $row = $dbw->selectRow( 'filearchive', '*',
+ $row = $dbw->selectRow( 'filearchive', ArchivedFile::selectFields(),
[ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ],
__METHOD__ );
if ( !$row ) {
[ 'fa_storage_group' => 'deleted', 'fa_storage_key' => $filekey ],
__METHOD__ );
if ( !$row ) {
protected function scrubAllVersions( $name ) {
$dbw = $this->getDB( DB_MASTER );
protected function scrubAllVersions( $name ) {
$dbw = $this->getDB( DB_MASTER );
- $res = $dbw->select( 'filearchive', '*',
+ $res = $dbw->select( 'filearchive', ArchivedFile::selectFields(),
[ 'fa_name' => $name, 'fa_storage_group' => 'deleted' ],
__METHOD__ );
foreach ( $res as $row ) {
[ 'fa_name' => $name, 'fa_storage_group' => 'deleted' ],
__METHOD__ );
foreach ( $res as $row ) {
while ( $blockEnd <= $end ) {
$this->output( "...doing log_id from $blockStart to $blockEnd\n" );
$cond = "log_id BETWEEN $blockStart AND $blockEnd";
while ( $blockEnd <= $end ) {
$this->output( "...doing log_id from $blockStart to $blockEnd\n" );
$cond = "log_id BETWEEN $blockStart AND $blockEnd";
- $res = $db->select( 'logging', '*', $cond, __FUNCTION__ );
+ $res = $db->select(
+ 'logging', [ 'log_id', 'log_type', 'log_action', 'log_params' ], $cond, __FUNCTION__
+ );
foreach ( $res as $row ) {
// RevisionDelete logs - revisions
if ( LogEventsList::typeAction( $row, $delTypes, 'revision' ) ) {
foreach ( $res as $row ) {
// RevisionDelete logs - revisions
if ( LogEventsList::typeAction( $row, $delTypes, 'revision' ) ) {
}
$this->output( "Populating rev_sha1 column\n" );
}
$this->output( "Populating rev_sha1 column\n" );
- $rc = $this->doSha1Updates( 'revision', 'rev_id', 'rev' );
+ $rc = $this->doSha1Updates( 'revision', 'rev_id', Revision::selectFields(), 'rev' );
$this->output( "Populating ar_sha1 column\n" );
$this->output( "Populating ar_sha1 column\n" );
- $ac = $this->doSha1Updates( 'archive', 'ar_rev_id', 'ar' );
+ $ac = $this->doSha1Updates( 'archive', 'ar_rev_id', Revision::selectArchiveFields(), 'ar' );
$this->output( "Populating ar_sha1 column legacy rows\n" );
$ac += $this->doSha1LegacyUpdates();
$this->output( "Populating ar_sha1 column legacy rows\n" );
$ac += $this->doSha1LegacyUpdates();
* @param string $prefix
* @return int Rows changed
*/
* @param string $prefix
* @return int Rows changed
*/
- protected function doSha1Updates( $table, $idCol, $prefix ) {
+ protected function doSha1Updates( $table, $idCol, $fields, $prefix ) {
$db = $this->getDB( DB_MASTER );
$start = $db->selectField( $table, "MIN($idCol)", false, __METHOD__ );
$end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ );
$db = $this->getDB( DB_MASTER );
$start = $db->selectField( $table, "MIN($idCol)", false, __METHOD__ );
$end = $db->selectField( $table, "MAX($idCol)", false, __METHOD__ );
$this->output( "...doing $idCol from $blockStart to $blockEnd\n" );
$cond = "$idCol BETWEEN $blockStart AND $blockEnd
AND $idCol IS NOT NULL AND {$prefix}_sha1 = ''";
$this->output( "...doing $idCol from $blockStart to $blockEnd\n" );
$cond = "$idCol BETWEEN $blockStart AND $blockEnd
AND $idCol IS NOT NULL AND {$prefix}_sha1 = ''";
- $res = $db->select( $table, '*', $cond, __METHOD__ );
+ $res = $db->select( $table, $fields, $cond, __METHOD__ );
$this->beginTransaction( $db, __METHOD__ );
foreach ( $res as $row ) {
$this->beginTransaction( $db, __METHOD__ );
foreach ( $res as $row ) {
protected function doSha1LegacyUpdates() {
$count = 0;
$db = $this->getDB( DB_MASTER );
protected function doSha1LegacyUpdates() {
$count = 0;
$db = $this->getDB( DB_MASTER );
- $res = $db->select( 'archive', '*',
+ $res = $db->select( 'archive', Revision::selectArchiveFields(),
[ 'ar_rev_id IS NULL', 'ar_sha1' => '' ], __METHOD__ );
$updateSize = 0;
[ 'ar_rev_id IS NULL', 'ar_sha1' => '' ], __METHOD__ );
$updateSize = 0;
- function buildTable( $table, $key, $callback ) {
+ function buildTable( $table, $key, $fields, $callback ) {
$count = $this->dbw->selectField( $table, 'count(*)', '', __METHOD__ );
$this->init( $count, $table );
$this->output( "Processing $table...\n" );
$count = $this->dbw->selectField( $table, 'count(*)', '', __METHOD__ );
$this->init( $count, $table );
$this->output( "Processing $table...\n" );
- $result = $this->getDB( DB_REPLICA )->select( $table, '*', [], __METHOD__ );
+ $result = $this->getDB( DB_REPLICA )->select( $table, $fields, [], __METHOD__ );
foreach ( $result as $row ) {
$update = call_user_func( $callback, $row, null );
foreach ( $result as $row ) {
$update = call_user_func( $callback, $row, null );
function buildImage() {
$callback = [ $this, 'imageCallback' ];
function buildImage() {
$callback = [ $this, 'imageCallback' ];
- $this->buildTable( 'image', 'img_name', $callback );
+ $this->buildTable( 'image', 'img_name', LocalFile::selectFields(), $callback );
}
function imageCallback( $row, $copy ) {
}
function imageCallback( $row, $copy ) {
}
function buildOldImage() {
}
function buildOldImage() {
- $this->buildTable( 'oldimage', 'oi_archive_name', [ $this, 'oldimageCallback' ] );
+ $this->buildTable( 'oldimage', 'oi_archive_name', OldLocalFile::selectFields(),
+ [ $this, 'oldimageCallback' ] );
}
function oldimageCallback( $row, $copy ) {
}
function oldimageCallback( $row, $copy ) {
$conds[] = "img_minor_mime = {$dbr->addQuotes( $minor_mime )}";
}
$conds[] = "img_minor_mime = {$dbr->addQuotes( $minor_mime )}";
}
- $res = $dbr->select( 'image', '*', $conds,
+ $res = $dbr->select( 'image', LocalFile::selectFields(), $conds,
__METHOD__, [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'img_name ASC' ] );
if ( $res->numRows() > 0 ) {
__METHOD__, [ 'LIMIT' => $this->mBatchSize, 'ORDER BY' => 'img_name ASC' ] );
if ( $res->numRows() > 0 ) {
do {
$res = $dbw->select(
'image',
do {
$res = $dbw->select(
'image',
+ LocalFile::selectFields(),
array_merge( $conds, $conds2 ),
__METHOD__,
$options
array_merge( $conds, $conds2 ),
__METHOD__,
$options
$dbr = $this->getDB( DB_REPLICA );
$res = $dbr->select(
[ 'page', 'revision', 'text' ],
$dbr = $this->getDB( DB_REPLICA );
$res = $dbr->select(
[ 'page', 'revision', 'text' ],
+ array_merge(
+ Revision::selectFields(),
+ Revision::selectPageFields(),
+ Revision::selectTextFields()
+ ),
[
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey(),
[
'page_namespace' => $title->getNamespace(),
'page_title' => $title->getDBkey(),