while ( $row = $dbw->fetchObject( $res ) ) { to foreach ( $res as $row ) in maintenance stuffs (more to come)
$res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" );
$ids = array();
$res = $dbw->query( "SELECT cur_namespace,cur_title,cur_id FROM $cur" );
$ids = array();
- while ( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$title = $row->cur_title;
if ( $row->cur_namespace ) {
$title = $wgContLang->getNsText( $row->cur_namespace ) . ":$title";
$title = $row->cur_title;
if ( $row->cur_namespace ) {
$title = $wgContLang->getNsText( $row->cur_namespace ) . ":$title";
}
$tuplesAdded = 0; # no tuples added to INSERT yet
}
$tuplesAdded = 0; # no tuples added to INSERT yet
- while ( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$fromTitle = $row->l_from;
if ( array_key_exists( $fromTitle, $ids ) ) { # valid title
$from = $ids[$fromTitle];
$fromTitle = $row->l_from;
if ( array_key_exists( $fromTitle, $ids ) ) { # valid title
$from = $ids[$fromTitle];
# Get "active" text records from the revisions table
echo( "Searching for active text records in revisions table..." );
$res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" );
# Get "active" text records from the revisions table
echo( "Searching for active text records in revisions table..." );
$res = $dbw->query( "SELECT DISTINCT rev_text_id FROM $tbl_rev" );
- while ( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$cur[] = $row->rev_text_id;
}
echo( "done.\n" );
$cur[] = $row->rev_text_id;
}
echo( "done.\n" );
# Get "active" text records from the archive table
echo( "Searching for active text records in archive table..." );
$res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" );
# Get "active" text records from the archive table
echo( "Searching for active text records in archive table..." );
$res = $dbw->query( "SELECT DISTINCT ar_text_id FROM $tbl_arc" );
- while ( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) { {
$cur[] = $row->ar_text_id;
}
echo( "done.\n" );
$cur[] = $row->ar_text_id;
}
echo( "done.\n" );
$set = implode( ', ', $cur );
$res = $dbw->query( "SELECT old_id FROM $tbl_txt WHERE old_id NOT IN ( $set )" );
$old = array();
$set = implode( ', ', $cur );
$res = $dbw->query( "SELECT old_id FROM $tbl_txt WHERE old_id NOT IN ( $set )" );
$old = array();
- while ( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) { {
$old[] = $row->old_id;
}
echo( "done.\n" );
$old[] = $row->old_id;
}
echo( "done.\n" );
array( 'page_latest = rev_id', 'rev_user_text' => $user ),
__METHOD__
);
array( 'page_latest = rev_id', 'rev_user_text' => $user ),
__METHOD__
);
- while ( $row = $dbr->fetchObject( $results ) ) {
+ foreach ( $results as $row ) {
$titles[] = Title::makeTitle( $row->page_namespace, $row->page_title );
}
return $titles;
$titles[] = Title::makeTitle( $row->page_namespace, $row->page_title );
}
return $titles;
$dbr->ping();
$res = $dbr->select( 'revision', array( 'rev_id', 'rev_text_id' ),
array( "rev_id BETWEEN $chunkStart AND $chunkEnd" ), $fname );
$dbr->ping();
$res = $dbr->select( 'revision', array( 'rev_id', 'rev_text_id' ),
array( "rev_id BETWEEN $chunkStart AND $chunkEnd" ), $fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$this->oldIdMap[$row->rev_id] = $row->rev_text_id;
}
$dbr->freeResult( $res );
$this->oldIdMap[$row->rev_id] = $row->rev_text_id;
}
$dbr->freeResult( $res );
$objectRevs = array();
$res = $dbr->select( 'text', array( 'old_id', 'old_flags' ),
'old_id IN (' . implode( ',', $this->oldIdMap ) . ')', $fname );
$objectRevs = array();
$res = $dbr->select( 'text', array( 'old_id', 'old_flags' ),
'old_id IN (' . implode( ',', $this->oldIdMap ) . ')', $fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$flags = $row->old_flags;
$id = $row->old_id;
$flags = $row->old_flags;
$id = $row->old_id;
if ( count( $externalRevs ) ) {
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ),
array( 'old_id IN (' . implode( ',', $externalRevs ) . ')' ), $fname );
if ( count( $externalRevs ) ) {
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', 'old_text' ),
array( 'old_id IN (' . implode( ',', $externalRevs ) . ')' ), $fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$urlParts = explode( '://', $row->old_text, 2 );
if ( count( $urlParts ) !== 2 || $urlParts[1] == '' ) {
$this->error( 'restore text', "Error: invalid URL \"{$row->old_text}\"", $row->old_id );
$urlParts = explode( '://', $row->old_text, 2 );
if ( count( $urlParts ) !== 2 || $urlParts[1] == '' ) {
$this->error( 'restore text', "Error: invalid URL \"{$row->old_text}\"", $row->old_id );
$res = $extDb->select( $blobsTable,
array( 'blob_id' ),
array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname );
$res = $extDb->select( $blobsTable,
array( 'blob_id' ),
array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname );
- while ( $row = $extDb->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
unset( $xBlobIds[$row->blob_id] );
}
$extDb->freeResult( $res );
unset( $xBlobIds[$row->blob_id] );
}
$extDb->freeResult( $res );
$headerLength = 300;
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ),
array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), $fname );
$headerLength = 300;
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ),
array( 'old_id IN (' . implode( ',', $objectRevs ) . ')' ), $fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$oldId = $row->old_id;
$matches = array();
if ( !preg_match( '/^O:(\d+):"(\w+)"/', $row->header, $matches ) ) {
$oldId = $row->old_id;
$matches = array();
if ( !preg_match( '/^O:(\d+):"(\w+)"/', $row->header, $matches ) ) {
$headerLength = 300;
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ),
array( 'old_id IN (' . implode( ',', array_keys( $concatBlobs ) ) . ')' ), $fname );
$headerLength = 300;
$res = $dbr->select( 'text', array( 'old_id', 'old_flags', "LEFT(old_text, $headerLength) AS header" ),
array( 'old_id IN (' . implode( ',', array_keys( $concatBlobs ) ) . ')' ), $fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$flags = explode( ',', $row->old_flags );
if ( in_array( 'external', $flags ) ) {
// Concat blob is in external storage?
$flags = explode( ',', $row->old_flags );
if ( in_array( 'external', $flags ) ) {
// Concat blob is in external storage?
$res = $extDb->select( $blobsTable,
array( 'blob_id', "LEFT(blob_text, $headerLength) AS header" ),
array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname );
$res = $extDb->select( $blobsTable,
array( 'blob_id', "LEFT(blob_text, $headerLength) AS header" ),
array( 'blob_id IN( ' . implode( ',', $blobIds ) . ')' ), $fname );
- while ( $row = $extDb->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
if ( strcasecmp( $row->header, CONCAT_HEADER ) ) {
$this->error( 'restore text', "Error: invalid header on target $cluster/{$row->blob_id} of two-part ES URL",
$oldIds[$row->blob_id] );
if ( strcasecmp( $row->header, CONCAT_HEADER ) ) {
$this->error( 'restore text', "Error: invalid header on target $cluster/{$row->blob_id} of two-part ES URL",
$oldIds[$row->blob_id] );
- while( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
# print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n";
compressPage( $row, $extdb );
$last = $row->old_id;
# print " {$row->old_id} - {$row->old_namespace}:{$row->old_title}\n";
compressPage( $row, $extdb );
$last = $row->old_id;
$revLoadOptions
);
$revs = array();
$revLoadOptions
);
$revs = array();
- while ( $revRow = $dbw->fetchObject( $revRes ) ) {
+ foreach ( $res as $row ) {
"old_id BETWEEN $blockStart AND $blockEnd",
'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
), $fname );
"old_id BETWEEN $blockStart AND $blockEnd",
'old_flags NOT ' . $dbr->buildLike( $dbr->anyString(), 'external', $dbr->anyString() ),
), $fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
# Resolve stubs
$text = $row->old_text;
$id = $row->old_id;
# Resolve stubs
$text = $row->old_text;
$id = $row->old_id;
"AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' " .
'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'',
$fname );
"AND old_flags LIKE '%object%' AND old_flags NOT LIKE '%external%' " .
'AND LOWER(CONVERT(LEFT(old_text,22) USING latin1)) = \'o:15:"historyblobstub"\'',
$fname );
- while ( $row = $dbr->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
resolveStub( $row->old_id, $row->old_text, $row->old_flags );
}
}
resolveStub( $row->old_id, $row->old_text, $row->old_flags );
}
}
__METHOD__ );
$add = array();
__METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$copy = array();
foreach ( $fields as $field => $source ) {
if ( $source === MW_UPGRADE_COPY ) {
$copy = array();
foreach ( $fields as $field => $source ) {
if ( $source === MW_UPGRADE_COPY ) {
FROM $cur
ORDER BY cur_id", __METHOD__ );
$add = array();
FROM $cur
ORDER BY cur_id", __METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$add[] = array(
'old_namespace' => $row->cur_namespace,
'old_title' => $row->cur_title,
$add[] = array(
'old_namespace' => $row->cur_namespace,
'old_title' => $row->cur_title,
__METHOD__ );
$add = array();
__METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$add[] = array(
'rev_id' => $row->old_id,
'rev_page' => $row->cur_id,
$add[] = array(
'rev_id' => $row->old_id,
'rev_page' => $row->cur_id,
WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}
ORDER BY cur_id", __METHOD__ );
$add = array();
WHERE cur_id=rev_page AND rev_timestamp=cur_timestamp AND rev_id > {$maxold}
ORDER BY cur_id", __METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$add[] = array(
'page_id' => $row->cur_id,
'page_namespace' => $row->cur_namespace,
$add[] = array(
'page_id' => $row->cur_id,
'page_namespace' => $row->cur_namespace,
FROM $links, $cur
WHERE l_to=cur_id", __METHOD__ );
$add = array();
FROM $links, $cur
WHERE l_to=cur_id", __METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$add[] = array(
'pl_from' => $row->l_from,
'pl_namespace' => $row->cur_namespace,
$add[] = array(
'pl_from' => $row->l_from,
'pl_namespace' => $row->cur_namespace,
"SELECT bl_from, bl_to FROM $brokenlinks",
__METHOD__ );
$add = array();
"SELECT bl_from, bl_to FROM $brokenlinks",
__METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$pagename = $this->conv( $row->bl_to );
$title = Title::newFromText( $pagename );
if ( is_null( $title ) ) {
$pagename = $this->conv( $row->bl_to );
$title = Title::newFromText( $pagename );
if ( is_null( $title ) ) {
__METHOD__ );
$add = array();
__METHOD__ );
$add = array();
- while ( $row = $this->dbr->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$add[] = array(
'wl_user' => $row->wl_user,
'wl_namespace' => MWNamespace::getSubject( $row->wl_namespace ),
$add[] = array(
'wl_user' => $row->wl_user,
'wl_namespace' => MWNamespace::getSubject( $row->wl_namespace ),
echo "Found $n titles with duplicate entries.\n";
if ( $n > 0 ) {
echo "Correcting...\n";
echo "Found $n titles with duplicate entries.\n";
if ( $n > 0 ) {
echo "Correcting...\n";
- while ( $row = $dbw->fetchObject( $res ) ) {
+ foreach ( $res as $row ) {
$ns = intval( $row->cur_namespace );
$title = $dbw->addQuotes( $row->cur_title );
$ns = intval( $row->cur_namespace );
$title = $dbw->addQuotes( $row->cur_title );
HAVING n > 1", $fname );
$list = array();
HAVING n > 1", $fname );
$list = array();
- while ( $row = $this->db->fetchObject( $result ) ) {
+ foreach ( $res as $row ) {
$list[] = $row->user_name;
}
return $list;
$list[] = $row->user_name;
}
return $list;
$firstId = $firstRow->user_id;
wfOut( "Record that will be used for '$name' is user_id=$firstId\n" );
$firstId = $firstRow->user_id;
wfOut( "Record that will be used for '$name' is user_id=$firstId\n" );
- while ( $row = $this->db->fetchObject( $result ) ) {
+ foreach ( $result as $row ) {
$dupeId = $row->user_id;
wfOut( "... dupe id $dupeId: " );
$edits = $this->editCount( $dupeId );
$dupeId = $row->user_id;
wfOut( "... dupe id $dupeId: " );
$edits = $this->editCount( $dupeId );
- while ( $id = $dbr->fetchObject( $result ) ) {
+ foreach ( $result as $id ) {
$user = User::newFromId( $id->user_id );
$user = User::newFromId( $id->user_id );
- while ( $id = $dbr->fetchObject( $result ) ) {
+ foreach ( $result as $id ) {
$user = User::newFromId( $id->user_id );
$user = User::newFromId( $id->user_id );