r81425 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81424‎ | r81425 | r81426 >
Date:22:23, 2 February 2011
Author:reedy
Status:reverted
Tags:
Comment:
Followup r67094

Wrap some long lines

Tidy up SQL "IN()" wheel re-invention and such

Remove passing of $dbw around

Remove passing of by reference
Modified paths:
  • /trunk/phase3/includes/specials/SpecialRevisionMove.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialRevisionMove.php
@@ -151,8 +151,10 @@
152152 Xml::fieldset( wfMsg( 'revmove-legend' ) ) .
153153 Html::hidden( 'wpEditToken', $wgUser->editToken() ) .
154154 Html::hidden( 'oldTitle', $this->mOldTitle->getPrefixedText() ) .
155 - '<div>' . Xml::inputLabel( wfMsg( 'revmove-reasonfield' ), 'wpReason', 'revmove-reasonfield', 60 ) . '</div>' .
156 - Xml::inputLabel( wfMsg( 'revmove-titlefield' ), 'newTitle', 'revmove-titlefield', 20, $this->mOldTitle->getPrefixedText() ) .
 155+ '<div>' . Xml::inputLabel( wfMsg( 'revmove-reasonfield' ), 'wpReason',
 156+ 'revmove-reasonfield', 60 ) . '</div>' .
 157+ Xml::inputLabel( wfMsg( 'revmove-titlefield' ), 'newTitle', 'revmove-titlefield', 20,
 158+ $this->mOldTitle->getPrefixedText() ) .
157159 Html::hidden( 'ids', implode( ',', $this->mIds ) ) .
158160 Xml::submitButton( wfMsg( 'revmove-submit' ),
159161 array( 'name' => 'wpSubmit' ) ) .
@@ -237,8 +239,6 @@
238240 $oldArticle = new Article( $this->mOldTitle );
239241 $newArticle = new Article( $this->mNewTitle );
240242
241 - $idstring = implode( ", ", $this->mIds );
242 -
243243 # Get DB connection and begin transaction
244244 $dbw = wfGetDB( DB_MASTER );
245245 $dbw->begin();
@@ -256,7 +256,7 @@
257257 $dbw->update( 'revision',
258258 array( 'rev_page' => $this->mNewTitle->getArticleID() ),
259259 array(
260 - 'rev_id IN (' . $idstring . ')',
 260+ 'rev_id' => $this->mIds,
261261 'rev_page' => $this->mOldTitle->getArticleID(),
262262 ),
263263 __METHOD__
@@ -266,9 +266,8 @@
267267 # Check if we need to update page_latest
268268 # Get the latest version of the revisions we are moving
269269 $timestampNewPage = $this->queryLatestTimestamp(
270 - $dbw,
271270 $this->mNewTitle->getArticleID(),
272 - array( 'rev_id IN (' . $idstring . ')' )
 271+ array( 'rev_id' => $this->mIds )
273272 );
274273
275274 # Compare the new page's page_latest against db query.
@@ -278,17 +277,15 @@
279278 if ( $this->createArticle || $timestampNewPage > $currentNewPageRev->getTimestamp() ) {
280279 # we have to set page_latest to $timestampNewPage's revid
281280 $this->updatePageLatest(
282 - $dbw,
283281 $this->mNewTitle,
284282 $newArticle,
285283 $timestampNewPage,
286 - array( 'rev_id IN (' . $idstring . ')' )
 284+ array( 'rev_id' => $this->mIds )
287285 );
288286 }
289287
290288 # Update the old page's page_latest field
291289 $timestampOldPage = $this->queryLatestTimestamp(
292 - $dbw,
293290 $this->mOldTitle->getArticleID()
294291 );
295292
@@ -298,7 +295,7 @@
299296 if ( is_null( $timestampOldPage ) ) {
300297 $dbw->delete(
301298 'page',
302 - array( 'page_id = ' . $this->mOldTitle->getArticleID() ),
 299+ array( 'page_id' => $this->mOldTitle->getArticleID() ),
303300 __METHOD__
304301 );
305302 } else {
@@ -306,7 +303,6 @@
307304 $currentOldPageRev = Revision::newFromId( $this->mOldTitle->getLatestRevID() );
308305 if ( $timestampOldPage < $currentOldPageRev->getTimestamp() ) {
309306 $this->updatePageLatest(
310 - $dbw,
311307 $this->mOldTitle,
312308 $oldArticle,
313309 $timestampOldPage
@@ -331,13 +327,13 @@
332328 /**
333329 * Query for the latest timestamp in order to update page_latest and
334330 * page_timestamp.
335 - * @param &$dbw Database object (Master)
336331 * @param $articleId Integer page_id
337332 * @param $conds array database conditions
338333 *
339334 * @return String timestamp
340335 */
341 - protected function queryLatestTimestamp( &$dbw, $articleId, $conds = array() ) {
 336+ protected function queryLatestTimestamp( $articleId, $conds = array() ) {
 337+ $dbw = wfGetDB( DB_MASTER );
342338 $timestampNewRow = $dbw->selectRow(
343339 'revision',
344340 'max(rev_timestamp) AS maxtime',
@@ -351,7 +347,6 @@
352348 * Updates page_latest and similar database fields (see Article::updateRevisionOn).
353349 * Called two times, for the new and the old page
354350 *
355 - * @param &$dbw Database object (Master)
356351 * @param $articleTitle Title object of the page
357352 * @param $articleObj Article object of the page
358353 * @param $timestamp to search for (use queryLatestTimestamp to get the latest)
@@ -359,7 +354,8 @@
360355 *
361356 * @return boolean indicating success
362357 */
363 - protected function updatePageLatest( &$dbw, $articleTitle, &$articleObj, $timestamp, $conds = array() ) {
 358+ protected function updatePageLatest( $articleTitle, $articleObj, $timestamp, $conds = array() ) {
 359+ $dbw = wfGetDB( DB_MASTER );
364360 # Query to find out the rev_id
365361 $revisionRow = $dbw->selectRow(
366362 'revision',
@@ -373,7 +369,8 @@
374370
375371 # Update page_latest
376372 $latestRev = Revision::newFromId( $revisionRow->rev_id );
377 - return $articleObj->updateRevisionOn( $dbw, $latestRev, $articleTitle->getLatestRevID(), null, /* set new page flag */ true );
 373+ return $articleObj->updateRevisionOn( $dbw, $latestRev, $articleTitle->getLatestRevID(), null,
 374+ /* set new page flag */ true );
378375 }
379376
380377 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r86155Merge r81448 from REL1_17: reverting RevisionMove feature back out until some...demon23:28, 15 April 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r67094New feature RevisionMove (bug 21312). Introducing SpecialRevisionMove.php and...churchofemacs18:00, 30 May 2010

Status & tagging log