r79576 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79575‎ | r79576 | r79577 >
Date:13:42, 4 January 2011
Author:ialex
Status:deferred
Tags:
Comment:
* Removed dependencies on $wgArticle, using the Title object when possible and delayed the Article object creation until really necessary
* Changed Article::updateArticle() call to Article::doEdit()
Modified paths:
  • /trunk/extensions/DynamicPageList/DPL.php (modified) (history)
  • /trunk/extensions/DynamicPageList/DPLMain.php (modified) (history)

Diff [purge]

Index: trunk/extensions/DynamicPageList/DPL.php
@@ -1124,7 +1124,7 @@
11251125 }
11261126
11271127 function updateArticle( $title, $text, $summary ) {
1128 - global $wgUser, $wgRequest, $wgArticle, $wgOut;
 1128+ global $wgUser, $wgRequest, $wgOut;
11291129
11301130 if ( !$wgUser->matchEditToken( $wgRequest->getVal( 'token' ) ) ) {
11311131 $wgOut->addWikiMsg( 'sessionfailure' );
@@ -1132,11 +1132,11 @@
11331133 }
11341134
11351135 $titleX = Title::newFromText( $title );
1136 -
1137 - $wgArticle = $articleX = new Article( $titleX );
1138 - $permission_errors = $articleX->mTitle->getUserPermissionsErrors( 'edit', $wgUser );
 1136+ $permission_errors = $titleX->getUserPermissionsErrors( 'edit', $wgUser );
11391137 if ( count( $permission_errors ) == 0 ) {
1140 - $articleX->updateArticle( $text, $summary, false, $titleX->userIsWatching() );
 1138+ $articleX = new Article( $titleX );
 1139+ $articleX->doEdit( $text, $summary, EDIT_UPDATE | EDIT_DEFER_UPDATES | EDIT_AUTOSUMMARY );
 1140+ $wgOut->redirect( $titleX->getFullUrl( $articleX->isRedirect() ? 'redirect=no' : '' ) );
11411141 return '';
11421142 } else {
11431143 $wgOut->showPermissionsErrorPage( $permission_errors );
@@ -1425,11 +1425,9 @@
14261426 $reason .= "\nbulk delete by DPL query";
14271427
14281428 $titleX = Title::newFromText( $title );
1429 - global $wgArticle;
1430 - $wgArticle = $articleX = new Article( $titleX );
14311429 if ( $exec ) {
14321430 # Check permissions
1433 - $permission_errors = $articleX->mTitle->getUserPermissionsErrors( 'delete', $wgUser );
 1431+ $permission_errors = $titleX->getUserPermissionsErrors( 'delete', $wgUser );
14341432 if ( count( $permission_errors ) > 0 ) {
14351433 $wgOut->showPermissionsErrorPage( $permission_errors );
14361434 return 'permission error';
@@ -1437,6 +1435,7 @@
14381436 $wgOut->readOnlyPage();
14391437 return 'DPL: read only mode';
14401438 } else {
 1439+ $articleX = new Article( $titleX );
14411440 $articleX->doDelete( $reason );
14421441 }
14431442 } else {
Index: trunk/extensions/DynamicPageList/DPLMain.php
@@ -17,7 +17,7 @@
1818 error_reporting( E_ALL );
1919
2020 global $wgUser, $wgLang, $wgContLang, $wgRequest, $wgRawHtml;
21 - global $wgTitle, $wgArticle, $wgNonincludableNamespaces;
 21+ global $wgTitle, $wgNonincludableNamespaces;
2222
2323 // we use "makeKnownLinkObject" to create hyperlinks;
2424 // the code we store in the dplcache may contain <html>....</html> sequences
@@ -1413,10 +1413,8 @@
14141414
14151415 case 'dplcache':
14161416 if ( $sArg != '' ) {
1417 - if ( isset( $wgArticle ) ) {
1418 - $DPLCache = $wgArticle->getID() . '_' . $sArg . '.txt';
1419 - $DPLCachePath = $wgArticle->getID() % 10;
1420 - }
 1417+ $DPLCache = $parser->mTitle->getArticleID() . '_' . $sArg . '.txt';
 1418+ $DPLCachePath = $parser->mTitle->getArticleID() % 10;
14211419 } else {
14221420 $output .= $logger->msgWrongParam( 'dplcache', $sArg );
14231421 }
@@ -3269,7 +3267,7 @@
32703268 // update dependencies to CacheAPI if DPL is to respect the MW ParserCache and the page containing the DPL query is changed
32713269 if ( ExtDynamicPageList::$useCacheAPI && $bAllowCachedResults && $wgRequest->getVal( 'action', 'view' ) == 'submit' ) {
32723270 /*
3273 - CacheAPI::remDependencies( $wgArticle->getID());
 3271+ CacheAPI::remDependencies( $parser->mTitle->getArticleID());
32743272
32753273 // add category dependencies
32763274 $conditionTypes = array( CACHETYPE_CATEGORY );
@@ -3290,7 +3288,7 @@
32913289
32923290 // add general dependencies
32933291
3294 - // CacheAPI::addDependencies ( $wgArticle->getID(), $conditionTypes, $conditions);
 3292+ // CacheAPI::addDependencies ( $parser->mTitle->getArticleID(), $conditionTypes, $conditions);
32953293 */
32963294 }
32973295

Status & tagging log