r74700 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r74699‎ | r74700 | r74701 >
Date:00:05, 13 October 2010
Author:neilk
Status:ok
Tags:
Comment:
merging a commit missed when this branch was created (r74034)
Modified paths:
  • /branches/uploadwizard/phase3/includes/Article.php (modified) (history)
  • /branches/uploadwizard/phase3/includes/EditPage.php (modified) (history)
  • /branches/uploadwizard/phase3/includes/FileDeleteForm.php (modified) (history)
  • /branches/uploadwizard/phase3/includes/Title.php (modified) (history)
  • /branches/uploadwizard/phase3/maintenance/tests/phpunit/includes/UploadFromUrlTest.php (modified) (history)

Diff [purge]

Index: branches/uploadwizard/phase3/maintenance/tests/phpunit/includes/UploadFromUrlTest.php
@@ -235,7 +235,7 @@
236236 $a->doDeleteArticle( '' );
237237 }
238238
239 - $this->assertFalse( (bool)$talk->getArticleId( GAID_FOR_UPDATE ), 'User talk does not exist' );
 239+ $this->assertFalse( (bool)$talk->getArticleId( Title::GAID_FOR_UPDATE ), 'User talk does not exist' );
240240
241241 $data = $this->doApiRequest( array(
242242 'action' => 'upload',
@@ -252,7 +252,7 @@
253253 $job->run();
254254
255255 $this->assertTrue( wfLocalFile( 'UploadFromUrlTest.png' )->exists() );
256 - $this->assertTrue( (bool)$talk->getArticleId( GAID_FOR_UPDATE ), 'User talk exists' );
 256+ $this->assertTrue( (bool)$talk->getArticleId( Title::GAID_FOR_UPDATE ), 'User talk exists' );
257257
258258 $this->deleteFile( 'UploadFromUrlTest.png' );
259259
Index: branches/uploadwizard/phase3/includes/Article.php
@@ -3111,7 +3111,7 @@
31123112 public function doDelete( $reason, $suppress = false ) {
31133113 global $wgOut, $wgUser;
31143114
3115 - $id = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
 3115+ $id = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
31163116
31173117 $error = '';
31183118 if ( wfRunHooks( 'ArticleDelete', array( &$this, &$wgUser, &$reason, &$error ) ) ) {
@@ -3171,7 +3171,7 @@
31723172
31733173 $dbw = wfGetDB( DB_MASTER );
31743174 $t = $this->mTitle->getDBkey();
3175 - $id = $id ? $id : $this->mTitle->getArticleID( GAID_FOR_UPDATE );
 3175+ $id = $id ? $id : $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
31763176
31773177 if ( $t === '' || $id == 0 ) {
31783178 return false;
Index: branches/uploadwizard/phase3/includes/EditPage.php
@@ -869,7 +869,7 @@
870870 wfProfileOut( __METHOD__ . '-checks' );
871871
872872 # If article is new, insert it.
873 - $aid = $this->mTitle->getArticleID( GAID_FOR_UPDATE );
 873+ $aid = $this->mTitle->getArticleID( Title::GAID_FOR_UPDATE );
874874 if ( 0 == $aid ) {
875875 // Late check for create permission, just in case *PARANOIA*
876876 if ( !$this->mTitle->userCan( 'create' ) ) {
Index: branches/uploadwizard/phase3/includes/Title.php
@@ -13,8 +13,6 @@
1414 require_once( dirname( __FILE__ ) . '/normal/UtfNormal.php' );
1515 }
1616
17 -define ( 'GAID_FOR_UPDATE', 1 );
18 -
1917 /**
2018 * Represents a title within MediaWiki.
2119 * Optionally may contain an interwiki designation or namespace.
@@ -36,7 +34,13 @@
3735 */
3836 const CACHE_MAX = 1000;
3937
 38+ /**
 39+ * Used to be GAID_FOR_UPDATE define. Used with getArticleId() and friends
 40+ * to use the master DB
 41+ */
 42+ const GAID_FOR_UPDATE = 1;
4043
 44+
4145 /**
4246 * @name Private member variables
4347 * Please use the accessor functions instead.
@@ -193,11 +197,11 @@
194198 * Create a new Title from an article ID
195199 *
196200 * @param $id \type{\int} the page_id corresponding to the Title to create
197 - * @param $flags \type{\int} use GAID_FOR_UPDATE to use master
 201+ * @param $flags \type{\int} use Title::GAID_FOR_UPDATE to use master
198202 * @return \type{Title} the new object, or NULL on an error
199203 */
200204 public static function newFromID( $id, $flags = 0 ) {
201 - $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 205+ $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
202206 $row = $db->selectRow( 'page', '*', array( 'page_id' => $id ), __METHOD__ );
203207 if ( $row !== false ) {
204208 $title = Title::newFromRow( $row );
@@ -2326,7 +2330,7 @@
23272331 * Get the article ID for this Title from the link cache,
23282332 * adding it if necessary
23292333 *
2330 - * @param $flags \type{\int} a bit field; may be GAID_FOR_UPDATE to select
 2334+ * @param $flags \type{\int} a bit field; may be Title::GAID_FOR_UPDATE to select
23312335 * for update
23322336 * @return \type{\int} the ID
23332337 */
@@ -2335,7 +2339,7 @@
23362340 return $this->mArticleID = 0;
23372341 }
23382342 $linkCache = LinkCache::singleton();
2339 - if ( $flags & GAID_FOR_UPDATE ) {
 2343+ if ( $flags & self::GAID_FOR_UPDATE ) {
23402344 $oldUpdate = $linkCache->forUpdate( true );
23412345 $linkCache->clearLink( $this );
23422346 $this->mArticleID = $linkCache->addLinkObj( $this );
@@ -2352,7 +2356,7 @@
23532357 * Is this an article that is a redirect page?
23542358 * Uses link cache, adding it if necessary
23552359 *
2356 - * @param $flags \type{\int} a bit field; may be GAID_FOR_UPDATE to select for update
 2360+ * @param $flags \type{\int} a bit field; may be Title::GAID_FOR_UPDATE to select for update
23572361 * @return \type{\bool}
23582362 */
23592363 public function isRedirect( $flags = 0 ) {
@@ -2373,7 +2377,7 @@
23742378 * What is the length of this page?
23752379 * Uses link cache, adding it if necessary
23762380 *
2377 - * @param $flags \type{\int} a bit field; may be GAID_FOR_UPDATE to select for update
 2381+ * @param $flags \type{\int} a bit field; may be Title::GAID_FOR_UPDATE to select for update
23782382 * @return \type{\bool}
23792383 */
23802384 public function getLength( $flags = 0 ) {
@@ -2393,7 +2397,7 @@
23942398 /**
23952399 * What is the page_latest field for this page?
23962400 *
2397 - * @param $flags \type{\int} a bit field; may be GAID_FOR_UPDATE to select for update
 2401+ * @param $flags \type{\int} a bit field; may be Title::GAID_FOR_UPDATE to select for update
23982402 * @return \type{\int} or 0 if the page doesn't exist
23992403 */
24002404 public function getLatestRevID( $flags = 0 ) {
@@ -3610,11 +3614,11 @@
36113615 * Get the revision ID of the previous revision
36123616 *
36133617 * @param $revId \type{\int} Revision ID. Get the revision that was before this one.
3614 - * @param $flags \type{\int} GAID_FOR_UPDATE
 3618+ * @param $flags \type{\int} Title::GAID_FOR_UPDATE
36153619 * @return \twotypes{\int,\bool} Old revision ID, or FALSE if none exists
36163620 */
36173621 public function getPreviousRevisionID( $revId, $flags = 0 ) {
3618 - $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 3622+ $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
36193623 return $db->selectField( 'revision', 'rev_id',
36203624 array(
36213625 'rev_page' => $this->getArticleId( $flags ),
@@ -3629,11 +3633,11 @@
36303634 * Get the revision ID of the next revision
36313635 *
36323636 * @param $revId \type{\int} Revision ID. Get the revision that was after this one.
3633 - * @param $flags \type{\int} GAID_FOR_UPDATE
 3637+ * @param $flags \type{\int} Title::GAID_FOR_UPDATE
36343638 * @return \twotypes{\int,\bool} Next revision ID, or FALSE if none exists
36353639 */
36363640 public function getNextRevisionID( $revId, $flags = 0 ) {
3637 - $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 3641+ $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
36383642 return $db->selectField( 'revision', 'rev_id',
36393643 array(
36403644 'rev_page' => $this->getArticleId( $flags ),
@@ -3647,11 +3651,11 @@
36483652 /**
36493653 * Get the first revision of the page
36503654 *
3651 - * @param $flags \type{\int} GAID_FOR_UPDATE
 3655+ * @param $flags \type{\int} Title::GAID_FOR_UPDATE
36523656 * @return Revision (or NULL if page doesn't exist)
36533657 */
36543658 public function getFirstRevision( $flags = 0 ) {
3655 - $db = ( $flags & GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
 3659+ $db = ( $flags & self::GAID_FOR_UPDATE ) ? wfGetDB( DB_MASTER ) : wfGetDB( DB_SLAVE );
36563660 $pageId = $this->getArticleId( $flags );
36573661 if ( !$pageId ) {
36583662 return null;
Property changes on: branches/uploadwizard/phase3/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
36593663 Merged /trunk/phase3/includes/Title.php:r74034
Index: branches/uploadwizard/phase3/includes/FileDeleteForm.php
@@ -116,7 +116,7 @@
117117 $log->addEntry( 'delete', $title, $logComment );
118118 }
119119 } else {
120 - $id = $title->getArticleID( GAID_FOR_UPDATE );
 120+ $id = $title->getArticleID( Title::GAID_FOR_UPDATE );
121121 $article = new Article( $title );
122122 $error = '';
123123 $dbw = wfGetDB( DB_MASTER );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r74034Refactor GAID_FOR_UPDATE into Title::GAID_FOR_UPDATE. Yay less file-scope cod...demon19:13, 30 September 2010

Status & tagging log