r101126 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r101125‎ | r101126 | r101127 >
Date:12:09, 28 October 2011
Author:catrope
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/RELEASE-NOTES-1.18 (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/GlobalBlocking/GlobalBlocking.i18n.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/GlobalBlocking/SpecialGlobalBlock.php (modified) (history)
  • /branches/wmf/1.18wmf1/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js (modified) (history)
  • /branches/wmf/1.18wmf1/includes/CategoryPage.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/Import.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/User.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/api/ApiWatch.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/db/Database.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/media/XMPInfo.php (modified) (history)
  • /branches/wmf/1.18wmf1/includes/specials/SpecialEditWatchlist.php (modified) (history)
  • /branches/wmf/1.18wmf1/resources/jquery/jquery.tablesorter.js (modified) (history)
  • /branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/RELEASE-NOTES-1.18
@@ -456,6 +456,7 @@
457457 * (bug 30907) Special:Unusedcategories should sort ascendingly.
458458 * (bug 28545) When using the uca-default collation, sortkey's starting with a
459459 space (U+20) will sort under an invisible header like in 1.16 rather than a U+6DE
 460+* (bug 31674) Can't edit watchlist if it contains special pages
460461
461462 === API changes in 1.18 ===
462463 * BREAKING CHANGE: action=watch now requires POST and token.
Property changes on: branches/wmf/1.18wmf1/RELEASE-NOTES-1.18
___________________________________________________________________
Modified: svn:mergeinfo
463464 Merged /trunk/phase3/RELEASE-NOTES-1.18:r98669,99164,99321,99332,99632,99897,99914,99952,99994,100391,100398,100504,100656,100701,101010
Index: branches/wmf/1.18wmf1/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
@@ -779,8 +779,11 @@
780780 .addClass( 'sortable' )
781781 .insertAfter( $( '#wikieditor-toolbar-table-preview' ) )
782782 .hide();
783 - if ( typeof jQuery.fn.tablesorter == 'function' )
784 - $( '#wikieditor-toolbar-table-preview2' ).tablesorter();
 783+
 784+ mw.loader.using( 'jquery.tablesorter', function() {
 785+ $( '#wikieditor-toolbar-table-preview2' ).tablesorter();
 786+ });
 787+
785788 $( '#wikieditor-toolbar-table-sortable' ).click( function() {
786789 // Swap the currently shown one clone with the other one
787790 $( '#wikieditor-toolbar-table-preview' )
Index: branches/wmf/1.18wmf1/extensions/GlobalBlocking/SpecialGlobalBlock.php
@@ -181,7 +181,7 @@
182182 $fields = array ();
183183
184184 // Who to block
185 - $fields['ipaddress'] =
 185+ $fields['globalblocking-ipaddress'] =
186186 Xml::input( 'wpAddress',
187187 45,
188188 $this->mAddress,
@@ -246,7 +246,7 @@
247247 // Block all users, or just anonymous ones
248248 $fields['globalblocking-block-options'] =
249249 Xml::checkLabel(
250 - wfMsg( 'ipbanononly' ),
 250+ wfMsg( 'globalblocking-ipbanononly' ),
251251 'wpAnonOnly',
252252 'mw-globalblock-anon-only',
253253 $this->mAnonOnly
Index: branches/wmf/1.18wmf1/extensions/GlobalBlocking/GlobalBlocking.i18n.php
@@ -30,6 +30,8 @@
3131 'globalblocking-block-expiry-otherfield' => 'Other time:',
3232 'globalblocking-block-legend' => 'Block an IP address globally',
3333 'globalblocking-block-options' => 'Options:',
 34+ 'globalblocking-ipaddress' => 'IP address:',
 35+ 'globalblocking-ipbanononly' => 'Block anonymous users only',
3436 'globalblocking-block-errors' => "Your block was unsuccessful, for the following {{PLURAL:$1|reason|reasons}}:",
3537 'globalblocking-block-ipinvalid' => 'The IP address ($1) you entered is invalid.
3638 Please note that you cannot enter a user name!',
Index: branches/wmf/1.18wmf1/includes/CategoryPage.php
@@ -68,14 +68,27 @@
6969 // Use these as defaults for back compat --catrope
7070 $oldFrom = $wgRequest->getVal( 'from' );
7171 $oldUntil = $wgRequest->getVal( 'until' );
 72+
 73+ $reqArray = $wgRequest->getValues();
7274
7375 $from = $until = array();
7476 foreach ( array( 'page', 'subcat', 'file' ) as $type ) {
7577 $from[$type] = $wgRequest->getVal( "{$type}from", $oldFrom );
7678 $until[$type] = $wgRequest->getVal( "{$type}until", $oldUntil );
 79+
 80+ // Do not want old-style from/until propagating in nav links.
 81+ if ( !isset( $reqArray["{$type}from"] ) && isset( $reqArray["from"] ) ) {
 82+ $reqArray["{$type}from"] = $reqArray["from"];
 83+ }
 84+ if ( !isset( $reqArray["{$type}to"] ) && isset( $reqArray["to"] ) ) {
 85+ $reqArray["{$type}to"] = $reqArray["to"];
 86+ }
7787 }
7888
79 - $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $wgRequest->getValues() );
 89+ unset( $reqArray["from"] );
 90+ unset( $reqArray["to"] );
 91+
 92+ $viewer = new $this->mCategoryViewerClass( $this->mTitle, $from, $until, $reqArray );
8093 $wgOut->addHTML( $viewer->getHTML() );
8194 }
8295 }
Property changes on: branches/wmf/1.18wmf1/includes/CategoryPage.php
___________________________________________________________________
Modified: svn:mergeinfo
8396 Merged /trunk/phase3/includes/CategoryPage.php:r98669,99164,99321,99332,99632,99897,99914,99952,99994,100391,100398,100504,100656,100701,101010
Index: branches/wmf/1.18wmf1/includes/User.php
@@ -2571,6 +2571,14 @@
25722572 }
25732573
25742574 /**
 2575+ * Cleans up watchlist by removing invalid entries from it
 2576+ */
 2577+ public function cleanupWatchlist() {
 2578+ $dbw = wfGetDB( DB_MASTER );
 2579+ $dbw->delete( 'watchlist', array( 'wl_namespace < 0', 'wl_user' => $this->getId() ), __METHOD__ );
 2580+ }
 2581+
 2582+ /**
25752583 * Clear the user's notification timestamp for the given title.
25762584 * If e-notif e-mails are on, they will receive notification mails on
25772585 * the next change of the page if it's watched etc.
Index: branches/wmf/1.18wmf1/includes/db/Database.php
@@ -47,7 +47,7 @@
4848 * Fields can be retrieved with $row->fieldname, with fields acting like
4949 * member variables.
5050 *
51 - * @param $res SQL result object as returned from DatabaseBase::query(), etc.
 51+ * @param $res ResultWrapper|object as returned from DatabaseBase::query(), etc.
5252 * @return Row object
5353 * @throws DBUnexpectedError Thrown if the database returns an error
5454 */
Property changes on: branches/wmf/1.18wmf1/includes/db/Database.php
___________________________________________________________________
Modified: svn:mergeinfo
5555 Merged /trunk/phase3/includes/db/Database.php:r98669,99164,99321,99332,99632,99897,99914,99952,99994,100391,100398,100504,100656,100701,101010
Index: branches/wmf/1.18wmf1/includes/api/ApiWatch.php
@@ -49,7 +49,7 @@
5050 $params = $this->extractRequestParams();
5151 $title = Title::newFromText( $params['title'] );
5252
53 - if ( !$title ) {
 53+ if ( !$title || $title->getNamespace() < 0 ) {
5454 $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) );
5555 }
5656
Index: branches/wmf/1.18wmf1/includes/media/XMPInfo.php
@@ -557,13 +557,16 @@
558558 'map_group' => 'exif',
559559 'mode' => XMPReader::MODE_SIMPLE,
560560 ),
561 - 'Orientation' => array(
562 - 'map_group' => 'exif',
563 - 'mode' => XMPReader::MODE_SIMPLE,
564 - 'validate' => 'validateClosed',
565 - 'choices' => array( '1' => true, '2' => true, '3' => true, '4' => true, 5 => true,
566 - '6' => true, '7' => true, '8' => true ),
567 - ),
 561+ /**** Do not extract this property
 562+ * It interferes with auto exif rotation.
 563+ * 'Orientation' => array(
 564+ * 'map_group' => 'exif',
 565+ * 'mode' => XMPReader::MODE_SIMPLE,
 566+ * 'validate' => 'validateClosed',
 567+ * 'choices' => array( '1' => true, '2' => true, '3' => true, '4' => true, 5 => true,
 568+ * '6' => true, '7' => true, '8' => true ),
 569+ *),
 570+ ******/
568571 'PhotometricInterpretation' => array(
569572 'map_group' => 'exif',
570573 'mode' => XMPReader::MODE_SIMPLE,
Index: branches/wmf/1.18wmf1/includes/specials/SpecialEditWatchlist.php
@@ -392,8 +392,13 @@
393393
394394 $fields = array();
395395
 396+ $haveInvalidNamespaces = false;
396397 foreach( $this->getWatchlistInfo() as $namespace => $pages ){
397 -
 398+ if ( $namespace < 0 ) {
 399+ $haveInvalidNamespaces = true;
 400+ continue;
 401+ }
 402+
398403 $namespace == NS_MAIN
399404 ? wfMsgHtml( 'blanknamespace' )
400405 : htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) );
@@ -410,6 +415,10 @@
411416 $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText();
412417 }
413418 }
 419+ if ( $haveInvalidNamespaces ) {
 420+ wfDebug( "User {$this->getContext()->getUser()->getId()} has invalid watchlist entries, clening up...\n" );
 421+ $this->getContext()->getUser()->cleanupWatchlist();
 422+ }
414423
415424 $form = new EditWatchlistNormalHTMLForm( $fields );
416425 $form->setTitle( $this->getTitle() );
Property changes on: branches/wmf/1.18wmf1/includes/specials/SpecialEditWatchlist.php
___________________________________________________________________
Modified: svn:mergeinfo
417426 Merged /trunk/phase3/includes/specials/SpecialEditWatchlist.php:r98669,99164,99321,99332,99632,99897,99914,99952,99994,100391,100398,100504,100656,100701,101010
Index: branches/wmf/1.18wmf1/includes/Import.php
@@ -1286,7 +1286,7 @@
12871287 # quicker and sorts out user-agent problems which might
12881288 # otherwise prevent importing from large sites, such
12891289 # as the Wikimedia cluster, etc.
1290 - $data = Http::request( $method, $url );
 1290+ $data = Http::request( $method, $url, array( 'followRedirects' => true ) );
12911291 if( $data !== false ) {
12921292 $file = tmpfile();
12931293 fwrite( $file, $data );
Index: branches/wmf/1.18wmf1/resources/jquery/jquery.textSelection.js
@@ -205,12 +205,20 @@
206206 * Get the position (in resolution of bytes not nessecarily characters)
207207 * in a textarea
208208 *
 209+ * Will focus the textarea in some browsers (IE/Opera)
 210+ *
209211 * @fixme document the options parameters
210212 */
211213 getCaretPosition: function( options ) {
212214 function getCaret( e ) {
213215 var caretPos = 0, endPos = 0;
214216 if ( $.browser.msie ) {
 217+ // IE doesn't properly report non-selected caret position through
 218+ // the selection ranges when textarea isn't focused. This can
 219+ // lead to saving a bogus empty selection, which then screws up
 220+ // whatever we do later (bug 31847).
 221+ e.focus();
 222+
215223 // IE Support
216224 var preFinished = false;
217225 var periFinished = false;
Index: branches/wmf/1.18wmf1/resources/jquery/jquery.tablesorter.js
@@ -223,19 +223,36 @@
224224 * This only treats a row as a header row if it contains only <th>s (no <td>s)
225225 * and if it is preceded entirely by header rows. The algorithm stops when
226226 * it encounters the first non-header row.
 227+ *
 228+ * After this, it will look at all rows at the bottom for footer rows
 229+ * And place these in a tfoot using similar rules.
227230 * @param $table jQuery object for a <table>
228231 */
229 - function emulateTHead( $table ) {
230 - var $thead = $( '<thead>' );
231 - $table.find( 'tr' ).each( function() {
232 - if ( $(this).children( 'td' ).length > 0 ) {
233 - // This row contains a <td>, so it's not a header row
234 - // Stop here
235 - return false;
236 - }
237 - $thead.append( this );
238 - } );
239 - $table.prepend( $thead );
 232+ function emulateTHeadAndFoot( $table ) {
 233+ var $rows = $table.find( 'tr' );
 234+ if( !$table.get(0).tHead ) {
 235+ var $thead = $( '<thead>' );
 236+ $rows.each( function() {
 237+ if ( $(this).children( 'td' ).length > 0 ) {
 238+ // This row contains a <td>, so it's not a header row
 239+ // Stop here
 240+ return false;
 241+ }
 242+ $thead.append( this );
 243+ } );
 244+ $table.prepend( $thead );
 245+ }
 246+ if( !$table.get(0).tFoot ) {
 247+ var $tfoot = $( '<tfoot>' );
 248+ var len = $rows.length;
 249+ for ( var i = len-1; i >= 0; i-- ) {
 250+ if( $( $rows[i] ).children( 'td' ).length > 0 ){
 251+ break;
 252+ }
 253+ $tfoot.prepend( $( $rows[i] ));
 254+ }
 255+ $table.append( $tfoot );
 256+ }
240257 }
241258
242259 function buildHeaders( table, msg ) {
@@ -531,8 +548,8 @@
532549 }
533550 if ( !table.tHead ) {
534551 // No thead found. Look for rows with <th>s and
535 - // move them into a <thead> tag
536 - emulateTHead( $table );
 552+ // move them into a <thead> tag or a <tfoot> tag
 553+ emulateTHeadAndFoot( $table );
537554
538555 // Still no thead? Then quit
539556 if ( !table.tHead ) {
@@ -567,8 +584,13 @@
568585 cacheRegexs();
569586
570587 // Apply event handling to headers
571 - // this is to big, perhaps break it out?
 588+ // this is too big, perhaps break it out?
572589 $headers.click( function( e ) {
 590+ if ( e.target.nodeName.toLowerCase() == 'a' ) {
 591+ // The user clicked on a link inside a table header
 592+ // Do nothing and let the default link click action continue
 593+ return true;
 594+ }
573595
574596 if ( firstTime ) {
575597 firstTime = false;
@@ -578,7 +600,12 @@
579601 // and put the <tfoot> at the end of the <table>
580602 var $sortbottoms = $table.find( 'tr.sortbottom' );
581603 if ( $sortbottoms.length ) {
582 - $table.append( $( '<tfoot>' ).append( $sortbottoms ) )
 604+ var $tfoot = $table.find( 'tfoot' );
 605+ if( $tfoot.length ) {
 606+ $tfoot.eq(0).prepend( $sortbottoms );
 607+ } else {
 608+ $table.append( $( '<tfoot>' ).append( $sortbottoms ) )
 609+ }
583610 }
584611
585612 explodeRowspans( $table );
@@ -645,12 +672,7 @@
646673 };
647674 return false;
648675 }
649 - } )
650 - // Allow links in headers to be clicked
651 - .find( 'a' ).click( function( e ) {
652 - e.stopPropagation();
653676 } );
654 -
655677 } );
656678 },
657679

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98669Add tfoot emulation to tablesorter. Fixes part of the complaints in bug 31060hartman11:58, 2 October 2011
r99164Followup to r98583; ProofreadPage was inserting a new newline at the start of...brion23:01, 6 October 2011
r99321Check if there is a prexisting tfoot, before creating a new one....hartman19:28, 8 October 2011
r99332(bug 31549; follow-up r83563) Do not include old-style from links in nav link...bawolff03:50, 9 October 2011
r99632(bug 31637) Do not extract tiff:Orientation from XMP data, since then it will...bawolff14:13, 12 October 2011
r99897(bug 31361) broken messages on Special:GlobalBlock.happy-melon17:59, 15 October 2011
r99914(bug 31674) Can't edit watchlist if it contains special pagesmaxsem21:06, 15 October 2011
r99952Fixed bug in r99914, also reverted accidental tabs->spaces conversionmaxsem15:08, 16 October 2011
r99994Fix broken test by r99321krinkle22:33, 16 October 2011
r100398* (bug 31847) Fix positioning of WikiEditor 'header' insertions when selectio...brion00:15, 21 October 2011
r100504Fix bug 31604....hartman17:21, 22 October 2011
r100701(bug 31514) Followup r99031: allow clicking of links in table headers in a di...catrope14:41, 25 October 2011
r101010Fixes Bug #28277 by allowing redirects on the stream reader. Fixes a...mah17:58, 27 October 2011

Status & tagging log