r94180 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r94179‎ | r94180 | r94181 >
Date:18:32, 10 August 2011
Author:aaron
Status:ok
Tags:
Comment:
Made moveToInternal() check result of Article::insertOn (related to bug 26223)
Modified paths:
  • /trunk/phase3/includes/Title.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Title.php
@@ -1235,7 +1235,7 @@
12361236 */
12371237 private function checkQuickPermissions( $action, $user, $errors, $doExpensiveQueries, $short ) {
12381238 $ns = $this->getNamespace();
1239 -
 1239+
12401240 if ( $action == 'create' ) {
12411241 if ( ( $this->isTalkPage() && !$user->isAllowed( 'createtalk', $ns ) ) ||
12421242 ( !$this->isTalkPage() && !$user->isAllowed( 'createpage', $ns ) ) ) {
@@ -1256,9 +1256,9 @@
12571257 if ( !$user->isAllowed( 'move', $ns) ) {
12581258 // User can't move anything
12591259
1260 - $userCanMove = in_array( 'move', User::getGroupPermissions(
 1260+ $userCanMove = in_array( 'move', User::getGroupPermissions(
12611261 array( 'user' ), $ns ), true );
1262 - $autoconfirmedCanMove = in_array( 'move', User::getGroupPermissions(
 1262+ $autoconfirmedCanMove = in_array( 'move', User::getGroupPermissions(
12631263 array( 'autoconfirmed' ), $ns ), true );
12641264
12651265 if ( $user->isAnon() && ( $userCanMove || $autoconfirmedCanMove ) ) {
@@ -1511,8 +1511,8 @@
15121512 if( $title_protection['pt_create_perm'] == 'sysop' ) {
15131513 $title_protection['pt_create_perm'] = 'protect'; // B/C
15141514 }
1515 - if( $title_protection['pt_create_perm'] == '' ||
1516 - !$user->isAllowed( $title_protection['pt_create_perm'],
 1515+ if( $title_protection['pt_create_perm'] == '' ||
 1516+ !$user->isAllowed( $title_protection['pt_create_perm'],
15171517 $this->mNamespace ) ) {
15181518 $errors[] = array( 'titleprotected', User::whoIs( $title_protection['pt_user'] ), $title_protection['pt_reason'] );
15191519 }
@@ -2369,7 +2369,7 @@
23702370 $fconditions[] = $dbr->bitAnd('fa_deleted', $suppressedTextBits ) .
23712371 ' != ' . $suppressedTextBits;
23722372 }
2373 -
 2373+
23742374 $n += $dbr->selectField( 'filearchive',
23752375 'COUNT(*)',
23762376 $fconditions,
@@ -3339,7 +3339,8 @@
33403340 $nt->resetArticleID( $oldid );
33413341
33423342 $article = new Article( $nt );
3343 - wfRunHooks( 'NewRevisionFromEditComplete', array( $article, $nullRevision, $latest, $wgUser ) );
 3343+ wfRunHooks( 'NewRevisionFromEditComplete',
 3344+ array( $article, $nullRevision, $latest, $wgUser ) );
33443345 $article->setCachedLastEditTime( $now );
33453346
33463347 # Recreate the redirect, this time in the other direction.
@@ -3348,24 +3349,27 @@
33493350 $redirectText = $mwRedir->getSynonym( 0 ) . ' [[' . $nt->getPrefixedText() . "]]\n";
33503351 $redirectArticle = new Article( $this );
33513352 $newid = $redirectArticle->insertOn( $dbw );
3352 - $redirectRevision = new Revision( array(
3353 - 'page' => $newid,
3354 - 'comment' => $comment,
3355 - 'text' => $redirectText ) );
3356 - $redirectRevision->insertOn( $dbw );
3357 - $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
 3353+ if ( $newid ) { // sanity
 3354+ $redirectRevision = new Revision( array(
 3355+ 'page' => $newid,
 3356+ 'comment' => $comment,
 3357+ 'text' => $redirectText ) );
 3358+ $redirectRevision->insertOn( $dbw );
 3359+ $redirectArticle->updateRevisionOn( $dbw, $redirectRevision, 0 );
33583360
3359 - wfRunHooks( 'NewRevisionFromEditComplete', array( $redirectArticle, $redirectRevision, false, $wgUser ) );
 3361+ wfRunHooks( 'NewRevisionFromEditComplete',
 3362+ array( $redirectArticle, $redirectRevision, false, $wgUser ) );
33603363
3361 - # Now, we record the link from the redirect to the new title.
3362 - # It should have no other outgoing links...
3363 - $dbw->delete( 'pagelinks', array( 'pl_from' => $newid ), __METHOD__ );
3364 - $dbw->insert( 'pagelinks',
3365 - array(
3366 - 'pl_from' => $newid,
3367 - 'pl_namespace' => $nt->getNamespace(),
3368 - 'pl_title' => $nt->getDBkey() ),
3369 - __METHOD__ );
 3364+ # Now, we record the link from the redirect to the new title.
 3365+ # It should have no other outgoing links...
 3366+ $dbw->delete( 'pagelinks', array( 'pl_from' => $newid ), __METHOD__ );
 3367+ $dbw->insert( 'pagelinks',
 3368+ array(
 3369+ 'pl_from' => $newid,
 3370+ 'pl_namespace' => $nt->getNamespace(),
 3371+ 'pl_title' => $nt->getDBkey() ),
 3372+ __METHOD__ );
 3373+ }
33703374 $redirectSuppressed = false;
33713375 } else {
33723376 $this->resetArticleID( 0 );

Status & tagging log