r95628 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95627‎ | r95628 | r95629 >
Date:15:32, 28 August 2011
Author:hashar
Status:ok
Tags:
Comment:
MFT to REL1_18 (extensions)
r92571 r92572 parserFunctions: defense against bogus lang codes
r93036 FlaggedRevs: position tracking in populateRevTimestamp.php
r95412 UploadWizard: revert r82984, reopen bug 26090
Expand URLs in API (bug 30171)
-> r94369 SiteMatrix
-> r94371 CentralAuth
-> r94376 Collection
r94404, r94509 ArticleFeedback: fix race conditions
r95079 WikiEditor JS: use .length() instead of .size()
r95169 OIA Fatal error stopped search indexing (bug 26304)
r95178,r95342 GoogleNewsSitemap: changes to wfMessage()
Modified paths:
  • /branches/REL1_18/extensions/ArticleFeedback (modified) (history)
  • /branches/REL1_18/extensions/ArticleFeedback/api/ApiArticleFeedback.php (modified) (history)
  • /branches/REL1_18/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php (modified) (history)
  • /branches/REL1_18/extensions/ArticleFeedback/populateAFRevisions.php (modified) (history)
  • /branches/REL1_18/extensions/CentralAuth (modified) (history)
  • /branches/REL1_18/extensions/CentralAuth/ApiQueryGlobalUserInfo.php (modified) (history)
  • /branches/REL1_18/extensions/CentralAuth/specials/SpecialWikiSets.php (modified) (history)
  • /branches/REL1_18/extensions/Collection (modified) (history)
  • /branches/REL1_18/extensions/Collection/Collection.body.php (modified) (history)
  • /branches/REL1_18/extensions/Collection/Collection.templates.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/maintenance/populateRevTimestamp.inc (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/maintenance/populateRevTimestamp.php (modified) (history)
  • /branches/REL1_18/extensions/GoogleNewsSitemap (modified) (history)
  • /branches/REL1_18/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php (modified) (history)
  • /branches/REL1_18/extensions/OAI (modified) (history)
  • /branches/REL1_18/extensions/OAI/OAIRepo_body.php (modified) (history)
  • /branches/REL1_18/extensions/ParserFunctions (modified) (history)
  • /branches/REL1_18/extensions/ParserFunctions/ParserFunctions_body.php (modified) (history)
  • /branches/REL1_18/extensions/SiteMatrix (modified) (history)
  • /branches/REL1_18/extensions/SiteMatrix/SiteMatrixApi.php (modified) (history)
  • /branches/REL1_18/extensions/UploadWizard (modified) (history)
  • /branches/REL1_18/extensions/UploadWizard/resources/mw.LanguageUpWiz.js (modified) (history)
  • /branches/REL1_18/extensions/UploadWizard/resources/mw.UploadWizardDetails.js (modified) (history)
  • /branches/REL1_18/extensions/WikiEditor (modified) (history)
  • /branches/REL1_18/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js (modified) (history)

Diff [purge]

Index: branches/REL1_18/extensions/OAI/OAIRepo_body.php
@@ -875,7 +875,12 @@
876876 array( 'img_name' => $this->_row->page_title ),
877877 $fname );
878878 if( $imageRow ) {
879 - $url = wfFindFile( $imageRow->img_name )->getUrl();
 879+ $file = wfFindFile( $imageRow->img_name );
 880+ if ( !$file ) {
 881+ wfDebug( 'Invalid image row retrieved. Image name: ' . $imageRow->img_name );
 882+ return '';
 883+ }
 884+ $url = $file->getUrl();
880885
881886 if( $url{0} == '/' ) {
882887 global $wgServer;
@@ -904,8 +909,6 @@
905910 }
906911 return '<contributor>' . $tag . '</contributor>';
907912 }
908 -
909 -
910913 }
911914
912915 /** For the very first page output siteinfo, else same sa XmlDumpWriter */
Property changes on: branches/REL1_18/extensions/OAI
___________________________________________________________________
Added: svn:mergeinfo
913916 Merged /trunk/extensions/OAI:r95169
Index: branches/REL1_18/extensions/ArticleFeedback/populateAFRevisions.php
@@ -40,12 +40,11 @@
4141
4242 $lastRevID = 0;
4343 $i = 0;
44 - $dbr = wfGetDB( DB_SLAVE );
4544 $dbw = wfGetDB( DB_MASTER );
4645 $this->output( "Reading data from article_feedback ...\n" );
4746 while ( true ) {
4847 // Get the next revision ID
49 - $row = $dbr->selectRow( 'article_feedback', array( 'aa_revision', 'aa_page_id' ),
 48+ $row = $dbw->selectRow( 'article_feedback', array( 'aa_revision', 'aa_page_id' ),
5049 "aa_revision > $lastRevID", __METHOD__,
5150 array( 'ORDER BY' => 'aa_revision', 'LIMIT' => 1 )
5251 );
@@ -57,7 +56,7 @@
5857 $pageid = intval( $row->aa_page_id );
5958
6059 // Get all article_feedback rows for this revision
61 - $res = $dbr->select( 'article_feedback',
 60+ $res = $dbw->select( 'article_feedback',
6261 array( 'aa_rating_id', 'aa_rating_value', 'aa_user_id', 'aa_user_anon_token' ),
6362 array( 'aa_revision' => $revid ),
6463 __METHOD__
Index: branches/REL1_18/extensions/ArticleFeedback/api/ApiArticleFeedback.php
@@ -37,11 +37,12 @@
3838 $this->dieUsage( 'ArticleFeedback is not enabled on this page', 'invalidpage' );
3939 }
4040
41 - $dbr = wfGetDB( DB_SLAVE );
 41+ $dbw = wfGetDB( DB_MASTER );
4242
4343 // Query the latest ratings by this user for this page,
4444 // possibly for an older revision
45 - $res = $dbr->select(
 45+ // Select from the master to prevent replag-induced bugs
 46+ $res = $dbw->select(
4647 'article_feedback',
4748 array( 'aa_rating_id', 'aa_rating_value', 'aa_revision' ),
4849 array(
@@ -454,4 +455,4 @@
455456 public function getVersion() {
456457 return __CLASS__ . ': $Id$';
457458 }
458 -}
\ No newline at end of file
 459+}
Property changes on: branches/REL1_18/extensions/ArticleFeedback/api/ApiArticleFeedback.php
___________________________________________________________________
Modified: svn:mergeinfo
459460 Merged /trunk/extensions/ArticleFeedback/api/ApiArticleFeedback.php:r94404,94509
Property changes on: branches/REL1_18/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php
___________________________________________________________________
Modified: svn:mergeinfo
460461 Merged /trunk/extensions/ArticleFeedback/api/ApiQueryArticleFeedback.php:r94404,94509
Property changes on: branches/REL1_18/extensions/ArticleFeedback
___________________________________________________________________
Added: svn:mergeinfo
461462 Merged /trunk/extensions/ArticleFeedback:r94404,94509
Property changes on: branches/REL1_18/extensions/UploadWizard/resources/mw.LanguageUpWiz.js
___________________________________________________________________
Modified: svn:mergeinfo
462463 Merged /trunk/extensions/UploadWizard/resources/mw.LanguageUpWiz.js:r93384,95412
Index: branches/REL1_18/extensions/UploadWizard/resources/mw.UploadWizardDetails.js
@@ -485,9 +485,8 @@
486486 $j.each( [ 'datetimeoriginal', 'datetimedigitized', 'datetime', 'date' ], function( i, propName ) {
487487 var dateInfo = metadata[propName];
488488 if ( ! mw.isEmpty( dateInfo ) ) {
489 - var matches = $j.trim( dateInfo ).match( yyyyMmDdRegex );
490 - // EXIF was founded in 1995, so anything before that is very unlikely
491 - if ( ! mw.isEmpty( matches ) && parseInt( matches[1], 10 ) > 1994) {
 489+ var matches = $j.trim( dateInfo ).match( yyyyMmDdRegex );
 490+ if ( ! mw.isEmpty( matches ) ) {
492491 dateObj = new Date( parseInt( matches[1], 10 ),
493492 parseInt( matches[2], 10 ) - 1,
494493 parseInt( matches[3], 10 ) );
Property changes on: branches/REL1_18/extensions/UploadWizard
___________________________________________________________________
Modified: svn:mergeinfo
495494 Merged /trunk/extensions/UploadWizard:r93384,95412
Index: branches/REL1_18/extensions/GoogleNewsSitemap/GoogleNewsSitemap_body.php
@@ -56,16 +56,17 @@
5757
5858 // Check to make sure that feed type is supported.
5959 if ( FeedUtils::checkFeedOutput( $params['feed'] ) ) {
60 -
61 - if ( !wfEmptyMsg( 'feed-' . $params['feed'] ) ) {
 60+ $msg = wfMessage( 'feed-' . $params['feed'] )->inContentLanguage();
 61+ if ( $msg->exists() ) {
6262 // This seems a little icky since
6363 // its re-using another message in a
6464 // different context.
6565 // uses feed-rss and feed-atom messages.
66 - $feedType = wfMsgForContent( 'feed-' . $params['feed'] );
 66+ $feedType = $msg->text();
6767 } else {
6868 $feedType = $wgContLang->uc( $params['feed'] );
6969 }
 70+
7071 $feed = new $wgFeedClasses[ $params['feed'] ](
7172 wfMsgExt( 'googlenewssitemap_feedtitle',
7273 array( 'parsemag', 'content' ),
Property changes on: branches/REL1_18/extensions/GoogleNewsSitemap
___________________________________________________________________
Added: svn:mergeinfo
7374 Merged /trunk/extensions/GoogleNewsSitemap:r95178,95342
Index: branches/REL1_18/extensions/SiteMatrix/SiteMatrixApi.php
@@ -57,7 +57,7 @@
5858
5959 $url = $matrix->getUrl( $lang, $site );
6060 $site_out = array(
61 - 'url' => $url,
 61+ 'url' => wfExpandUrl( $url ),
6262 'dbname' => $matrix->getDBName( $lang, $site ),
6363 'code' => $site,
6464 );
@@ -91,7 +91,7 @@
9292 $url = $matrix->getUrl( $lang, $site );
9393
9494 $wiki = array();
95 - $wiki['url'] = $url;
 95+ $wiki['url'] = wfExpandUrl( $url );
9696 $wiki['dbname'] = $matrix->getDBName( $lang, $site );
9797 $wiki['code'] = str_replace( '_', '-', $lang ) . ( $site != 'wiki' ? $site : '' );
9898
Property changes on: branches/REL1_18/extensions/SiteMatrix
___________________________________________________________________
Added: svn:mergeinfo
9999 Merged /trunk/extensions/SiteMatrix:r94369
Index: branches/REL1_18/extensions/CentralAuth/ApiQueryGlobalUserInfo.php
@@ -82,7 +82,7 @@
8383
8484 $a = array(
8585 'wiki' => $dbname,
86 - 'url' => $this->getUrl( $dbname ),
 86+ 'url' => wfExpandUrl( $this->getUrl( $dbname ) ),
8787 'timestamp' => wfTimestamp( TS_ISO_8601, $account['attachedTimestamp'] ),
8888 'method' => $account['attachedMethod'],
8989 'editcount' => $account['editCount']
Property changes on: branches/REL1_18/extensions/CentralAuth/specials/SpecialWikiSets.php
___________________________________________________________________
Modified: svn:mergeinfo
9090 Merged /trunk/extensions/CentralAuth/specials/SpecialWikiSets.php:r94371
Property changes on: branches/REL1_18/extensions/CentralAuth
___________________________________________________________________
Added: svn:mergeinfo
9191 Merged /trunk/extensions/CentralAuth:r94371
Index: branches/REL1_18/extensions/FlaggedRevs/maintenance/populateRevTimestamp.php
@@ -19,7 +19,7 @@
2020 php populateRevTimestamp.php [--startrev <ID>]
2121
2222 --help : This help message
23 - --<ID> : The ID of the starting rev
 23+ --<ID> : The ID of the starting rev or 'prev' (from last run)
2424
2525 TEXT;
2626 exit(0);
@@ -27,7 +27,13 @@
2828
2929 error_reporting( E_ALL );
3030
31 -$startRev = isset( $options['startrev'] ) ?
32 - (int)$options['startrev'] : null;
 31+$startRev = null;
 32+if ( isset( $options['startrev'] ) ) {
 33+ if ( $options['startrev'] === 'prev' ) {
 34+ $startRev = (int)file_get_contents( last_pos_file() );
 35+ } else {
 36+ $startRev = (int)$options['startrev'];
 37+ }
 38+}
3339
3440 populate_fr_rev_timestamp( $startRev );
Index: branches/REL1_18/extensions/FlaggedRevs/maintenance/populateRevTimestamp.inc
@@ -1,12 +1,12 @@
22 <?php
33
44 function populate_fr_rev_timestamp( $start = null ) {
5 - echo "Populating and correcting flaggedrevs columns\n";
6 -
 5+ echo "Populating and correcting flaggedrevs columns from $start\n";
 6+
77 $BATCH_SIZE = 1000;
8 -
 8+
99 $db = wfGetDB( DB_MASTER );
10 -
 10+
1111 if ( $start === null ) {
1212 $start = $db->selectField( 'flaggedrevs', 'MIN(fr_rev_id)', false, __FUNCTION__ );
1313 }
@@ -26,7 +26,7 @@
2727 $cond = "fr_rev_id BETWEEN $blockStart AND $blockEnd AND fr_rev_timestamp = ''";
2828 $res = $db->select(
2929 array( 'flaggedrevs', 'revision', 'archive' ),
30 - array( 'fr_rev_id', 'rev_timestamp', 'ar_timestamp' ),
 30+ array( 'fr_rev_id', 'rev_timestamp', 'ar_timestamp' ),
3131 $cond,
3232 __FUNCTION__,
3333 array(),
@@ -59,5 +59,10 @@
6060 $blockEnd += $BATCH_SIZE;
6161 wfWaitForSlaves( 5 );
6262 }
 63+ file_put_contents( last_pos_file(), $end );
6364 echo "fr_rev_timestamp columns update complete ... {$count} rows [{$changed} changed]\n";
6465 }
 66+
 67+function last_pos_file() {
 68+ return dirname( __FILE__ ) . "/popRevTimestampLast-" . wfWikiID();
 69+}
Property changes on: branches/REL1_18/extensions/FlaggedRevs
___________________________________________________________________
Modified: svn:mergeinfo
6570 Merged /trunk/extensions/FlaggedRevs:r93036
Index: branches/REL1_18/extensions/Collection/Collection.body.php
@@ -944,11 +944,7 @@
945945 }
946946
947947 function renderCollection( $collection, $referrer, $writer ) {
948 - global $wgOut;
949 - global $wgContLang;
950 - global $wgServer;
951 - global $wgScriptPath;
952 - global $wgScriptExtension;
 948+ global $wgOut, $wgContLang, $wgScriptPath, $wgScriptExtension;
953949
954950 if ( !$writer ) {
955951 $writer = 'rl';
@@ -956,7 +952,7 @@
957953
958954 $response = self::mwServeCommand( 'render', array(
959955 'metabook' => $this->buildJSONCollection( $collection ),
960 - 'base_url' => $wgServer . $wgScriptPath,
 956+ 'base_url' => wfExpandUrl( $wgScriptPath ),
961957 'script_extension' => $wgScriptExtension,
962958 'template_blacklist' => wfMsgForContent( 'coll-template_blacklist_title' ),
963959 'template_exclusion_category' => wfMsgForContent( 'coll-exclusion_category_title' ),
@@ -982,19 +978,14 @@
983979 }
984980
985981 function forceRenderCollection() {
986 - global $wgOut;
987 - global $wgContLang;
988 - global $wgRequest;
989 - global $wgServer;
990 - global $wgScriptPath;
991 - global $wgScriptExtension;
 982+ global $wgOut, $wgContLang, $wgRequest, $wgScriptPath, $wgScriptExtension;
992983
993984 $collectionID = $wgRequest->getVal( 'collection_id', '' );
994985 $writer = $wgRequest->getVal( 'writer', 'rl' );
995986
996987 $response = self::mwServeCommand( 'render', array(
997988 'collection_id' => $collectionID,
998 - 'base_url' => $wgServer . $wgScriptPath,
 989+ 'base_url' => wfExpandUrl( $wgScriptPath ),
999990 'script_extension' => $wgScriptExtension,
1000991 'template_blacklist' => wfMsgForContent( 'coll-template_blacklist_title' ),
1001992 'template_exclusion_category' => wfMsgForContent( 'coll-exclusion_category_title' ),
@@ -1020,13 +1011,7 @@
10211012 }
10221013
10231014 function renderRenderingPage() {
1024 - global $wgCollectionVersion;
1025 - global $wgJsMimeType;
1026 - global $wgLang;
1027 - global $wgOut;
1028 - global $wgRequest;
1029 - global $wgScriptPath;
1030 - global $wgServer;
 1015+ global $wgCollectionVersion, $wgJsMimeType, $wgLang, $wgOut, $wgRequest, $wgScriptPath;
10311016
10321017 $response = self::mwServeCommand( 'render_status', array(
10331018 'collection_id' => $wgRequest->getVal( 'collection_id' ),
@@ -1075,7 +1060,7 @@
10761061 $wgOut->setPageTitle( wfMsg( 'coll-rendering_finished_title' ) );
10771062
10781063 $template = new CollectionFinishedTemplate();
1079 - $template->set( 'download_url', $wgServer . SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=download&' . $query ) );
 1064+ $template->set( 'download_url', wfExpandUrl( SkinTemplate::makeSpecialUrl( 'Book', 'bookcmd=download&' . $query ) ) );
10801065 $template->set( 'is_cached', $wgRequest->getVal( 'is_cached' ) );
10811066 $template->set( 'query', $query );
10821067 $template->set( 'return_to', $return_to );
@@ -1156,10 +1141,7 @@
11571142 }
11581143
11591144 function postZIP( $collection, $partner ) {
1160 - global $wgServer;
1161 - global $wgScriptPath;
1162 - global $wgScriptExtension;
1163 - global $wgOut;
 1145+ global $wgScriptPath, $wgScriptExtension, $wgOut;
11641146
11651147 if ( !isset( $this->mPODPartners[$partner] ) ) {
11661148 $wgOut->showErrorPage( 'coll-invalid_podpartner_title', 'coll-invalid_podpartner_msg' );
@@ -1168,7 +1150,7 @@
11691151
11701152 $response = self::mwServeCommand( 'zip_post', array(
11711153 'metabook' => $this->buildJSONCollection( $collection ),
1172 - 'base_url' => $wgServer . $wgScriptPath,
 1154+ 'base_url' => wfExpandUrl( $wgScriptPath ),
11731155 'script_extension' => $wgScriptExtension,
11741156 'template_blacklist' => wfMsgForContent( 'coll-template_blacklist_title' ),
11751157 'template_exclusion_category' => wfMsgForContent( 'coll-exclusion_category_title' ),
Index: branches/REL1_18/extensions/Collection/Collection.templates.php
@@ -444,11 +444,10 @@
445445
446446 // needed for Ajax functions
447447 function getProposalList () {
448 - global $wgServer;
449 - global $wgScript;
 448+ global $wgScript, $wgScriptPath;
450449
451 - $mediapath = $GLOBALS['wgScriptPath'] . '/extensions/Collection/images/';
452 - $baseUrl = $wgServer . $wgScript . "/";
 450+ $mediapath = $wgScriptPath . '/extensions/Collection/images/';
 451+ $baseUrl = $wgScript . "/";
453452
454453 $prop = $this->data['proposals'];
455454 $out = '';
Property changes on: branches/REL1_18/extensions/Collection
___________________________________________________________________
Added: svn:mergeinfo
456455 Merged /trunk/extensions/Collection:r94376
Index: branches/REL1_18/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
@@ -86,10 +86,12 @@
8787 }
8888 // If the dialog already exists, but for another textarea, simply remove it
8989 var $existingDialog = $( '#' + module.id );
90 - if ( $existingDialog.size() > 0 && $existingDialog.data( 'context' ).$textarea != context.$textarea ) {
 90+ if ( $existingDialog.length > 0 && $existingDialog.data( 'context' ).$textarea != context.$textarea ) {
9191 $existingDialog.remove();
9292 }
93 - if ( !filtered && $.wikiEditor.isSupported( module ) && $existingDialog.size() == 0 ) {
 93+ // Re-select from the DOM, we might have removed the dialog just now
 94+ $existingDialog = $( '#' + module.id );
 95+ if ( !filtered && $.wikiEditor.isSupported( module ) && $existingDialog.size() === 0 ) {
9496 $.wikiEditor.modules.dialogs.modules[mod] = module;
9597 // If this dialog requires the iframe, set it up
9698 if ( typeof context.$iframe == 'undefined' && $.wikiEditor.isRequired( module, 'iframe' ) ) {
Property changes on: branches/REL1_18/extensions/WikiEditor
___________________________________________________________________
Added: svn:mergeinfo
9799 Merged /trunk/extensions/WikiEditor:r95079
Index: branches/REL1_18/extensions/ParserFunctions/ParserFunctions_body.php
@@ -505,10 +505,12 @@
506506 return '<strong class="error">' . wfMsgForContent( 'pfunc_time_too_long' ) . '</strong>';
507507 } else {
508508 if ( $ts < 100000000000000 ) { // Language can't deal with years after 9999
509 - if ( $language !== '' ) { // use whatever language is passed as a parameter
 509+ if ( Language::isValidBuiltInCode( $language ) ) {
 510+ // use whatever language is passed as a parameter
510511 $langObject = Language::factory( $language );
511512 $result = $langObject->sprintfDate( $format, $ts );
512 - } else { // use wiki's content language
 513+ } else {
 514+ // use wiki's content language
513515 $result = $parser->getFunctionLang()->sprintfDate( $format, $ts );
514516 }
515517 } else {
Property changes on: branches/REL1_18/extensions/ParserFunctions
___________________________________________________________________
Added: svn:mergeinfo
516518 Merged /trunk/extensions/ParserFunctions:r92571-92572

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r82984article -> pagesiebrand23:52, 28 February 2011
r87984Bug 26090 : Ignore unlikely EXIF dates in UploadWizarddiebuche15:16, 13 May 2011
r91364OAIRepo tweak: make the number of records returned in ListRecords requests co...brion18:40, 2 July 2011
r92571follow up to r87308 - defensive programming for bogus language codeskaldari20:29, 19 July 2011
r92572follow up to r87308 - fix redundancykaldari20:31, 19 July 2011
r93036Added simple position tracking to populateRevTimestamp.php scriptaaron02:58, 25 July 2011
r94369Expand URLs in the SiteMatrix API. This should fix bug 30171catrope19:09, 12 August 2011
r94371Expand another URL in the CentralAuth APIcatrope19:18, 12 August 2011
r94376Collection: Use wfExpandUrl() instead of prepending $wgServer everywhere. In ...catrope20:00, 12 August 2011
r94404Hopefully prevent race conditions in ArticleFeedback by reading from the mast...catrope10:46, 13 August 2011
r94509Followup r94404: remove LOCK IN SHARE MODE because locking reads are evil, pe...catrope13:06, 15 August 2011
r95079Followup r82900: per CR, use .length instead of size(), strict comparison wit...catrope12:47, 20 August 2011
r95169Bug 26304 - OAIRepository fatal error stops search indexing...reedy18:39, 21 August 2011
r95178(follow-up r91812) change to wfMessage per Roan's suggestion....bawolff20:22, 21 August 2011
r95342Follow-up r95178 - use ->text() instead of toString() on the message per Nike...bawolff22:05, 23 August 2011
r95412Revert r87984...reedy18:38, 24 August 2011

Status & tagging log