r100840 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100839‎ | r100840 | r100841 >
Date:18:47, 26 October 2011
Author:reedy
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/REL1_18/phase3 (modified) (history)
  • /branches/REL1_18/phase3/RELEASE-NOTES-1.18 (modified) (history)
  • /branches/REL1_18/phase3/includes (modified) (history)
  • /branches/REL1_18/phase3/includes/DefaultSettings.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Setup.php (modified) (history)
  • /branches/REL1_18/phase3/includes/Title.php (modified) (history)
  • /branches/REL1_18/phase3/includes/User.php (modified) (history)
  • /branches/REL1_18/phase3/includes/api (modified) (history)
  • /branches/REL1_18/phase3/includes/api/ApiWatch.php (modified) (history)
  • /branches/REL1_18/phase3/includes/db/Database.php (modified) (history)
  • /branches/REL1_18/phase3/includes/media/ExifBitmap.php (modified) (history)
  • /branches/REL1_18/phase3/includes/media/XMPInfo.php (modified) (history)
  • /branches/REL1_18/phase3/includes/specials (modified) (history)
  • /branches/REL1_18/phase3/includes/specials/SpecialEditWatchlist.php (modified) (history)
  • /branches/REL1_18/phase3/skins/MonoBook.php (modified) (history)
  • /branches/REL1_18/phase3/skins/Vector.php (modified) (history)
  • /branches/REL1_18/phase3/tests/phpunit/includes/TitleTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/phase3/skins/Vector.php
@@ -315,7 +315,7 @@
316316 <?php
317317 endforeach;
318318 if ( isset( $hook ) ) {
319 - wfRunHooks( $hook, array( &$this ) );
 319+ wfRunHooks( $hook, array( &$this, true ) );
320320 }
321321 ?>
322322 </ul>
Index: branches/REL1_18/phase3/skins/MonoBook.php
@@ -262,7 +262,7 @@
263263 <?php
264264 }
265265 wfRunHooks( 'MonoBookTemplateToolboxEnd', array( &$this ) );
266 - wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this ) );
 266+ wfRunHooks( 'SkinTemplateToolboxEnd', array( &$this, true ) );
267267 ?>
268268 </ul>
269269 </div>
Index: branches/REL1_18/phase3/RELEASE-NOTES-1.18
@@ -86,6 +86,8 @@
8787 category collations.
8888 * (bug 31233) New OutputPage::addJsConfigVars() method to make the output page specific
8989 mw.config map extendable.
 90+* $wgEnableAutoRotation enables or disables auto-rotation. Leaving it set to
 91+ null will cause MediaWiki to determine if auto-rotation is available.
9092
9193 === New features in 1.18 ===
9294 * BREAKING CHANGE: action=watch / action=unwatch now requires a token.
@@ -462,6 +464,8 @@
463465 to let styles easily hide or show things based on general JS availability
464466 * (bug 18424) Special:Prefixindex and Special:Allpages paging links are
465467 really small, and somewhat inconsistent with each other.
 468+* (bug 31213) Exception thrown when trying to move file cross-namespace
 469+* (bug 31674) Can't edit watchlist if it contains special pages
466470
467471 === API changes in 1.18 ===
468472 * BREAKING CHANGE: action=watch now requires POST and token.
Property changes on: branches/REL1_18/phase3/RELEASE-NOTES-1.18
___________________________________________________________________
Modified: svn:mergeinfo
469473 Merged /trunk/phase3/RELEASE-NOTES-1.18:r98426,99371,99632,99897,99910,99914,99952
Index: branches/REL1_18/phase3/tests/phpunit/includes/TitleTest.php
@@ -37,4 +37,43 @@
3838 array( 'Special:Version/param', 'param' ),
3939 );
4040 }
 41+
 42+ /**
 43+ * Auth-less test of Title::isValidMoveOperation
 44+ *
 45+ * @param string $source
 46+ * @param string $target
 47+ * @param array|string|true $requiredErrors
 48+ * @dataProvider dataTestIsValidMoveOperation
 49+ */
 50+ function testIsValidMoveOperation( $source, $target, $expected ) {
 51+ $title = Title::newFromText( $source );
 52+ $nt = Title::newFromText( $target );
 53+ $errors = $title->isValidMoveOperation( $nt, false );
 54+ if ( $expected === true ) {
 55+ $this->assertTrue( $errors );
 56+ } else {
 57+ $errors = $this->flattenErrorsArray( $errors );
 58+ foreach ( (array)$expected as $error ) {
 59+ $this->assertContains( $error, $errors );
 60+ }
 61+ }
 62+ }
 63+
 64+ function flattenErrorsArray( $errors ) {
 65+ $result = array();
 66+ foreach ( $errors as $error ) {
 67+ $result[] = $error[0];
 68+ }
 69+ return $result;
 70+ }
 71+
 72+ function dataTestIsValidMoveOperation() {
 73+ return array(
 74+ array( 'Test', 'Test', 'selfmove' ),
 75+ array( 'File:Test.jpg', 'Page', 'imagenocrossnamespace' )
 76+ );
 77+ }
 78+
 79+
4180 }
Index: branches/REL1_18/phase3/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/REL1_18/phase3/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/REL1_18/phase3/includes/db/Database.php
___________________________________________________________________
Modified: svn:mergeinfo
5555 Merged /trunk/phase3/includes/db/Database.php:r99897,99910,99914,99952
Index: branches/REL1_18/phase3/includes/Setup.php
@@ -187,6 +187,11 @@
188188 );
189189 }
190190
 191+if ( is_null( $wgEnableAutoRotation ) ) {
 192+ // Only enable auto-rotation when the bitmap handler can rotate
 193+ $wgEnableAutoRotation = BitmapHandler::canRotate();
 194+}
 195+
191196 if ( $wgRCFilterByAge ) {
192197 # # Trim down $wgRCLinkDays so that it only lists links which are valid
193198 # # as determined by $wgRCMaxAge.
Index: branches/REL1_18/phase3/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
Property changes on: branches/REL1_18/phase3/includes/api
___________________________________________________________________
Modified: svn:mergeinfo
5757 Merged /trunk/phase3/includes/api:r99914,99952
Index: branches/REL1_18/phase3/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/REL1_18/phase3/includes/media/ExifBitmap.php
@@ -162,6 +162,11 @@
163163 * @return int 0, 90, 180 or 270
164164 */
165165 public function getRotation( $file ) {
 166+ global $wgEnableAutoRotation;
 167+ if ( !$wgEnableAutoRotation ) {
 168+ return 0;
 169+ }
 170+
166171 $data = $file->getMetadata();
167172 return $this->getRotationForExif( $data );
168173 }
Property changes on: branches/REL1_18/phase3/includes/media/ExifBitmap.php
___________________________________________________________________
Modified: svn:mergeinfo
169174 Merged /trunk/phase3/includes/media/ExifBitmap.php:r99910,99914,99952
Index: branches/REL1_18/phase3/includes/Title.php
@@ -3105,10 +3105,8 @@
31063106
31073107 $errors = array();
31083108
3109 - if ( $nt->getNamespace() != NS_FILE ) {
3110 - $errors[] = array( 'imagenocrossnamespace' );
3111 - }
3112 -
 3109+ // wfFindFile( $nt ) / wfLocalFile( $nt ) is not allowed until below
 3110+
31133111 $file = wfLocalFile( $this );
31143112 if ( $file->exists() ) {
31153113 if ( $nt->getText() != wfStripIllegalFilenameChars( $nt->getText() ) ) {
@@ -3118,6 +3116,15 @@
31193117 $errors[] = array( 'imagetypemismatch' );
31203118 }
31213119 }
 3120+
 3121+ if ( $nt->getNamespace() != NS_FILE ) {
 3122+ $errors[] = array( 'imagenocrossnamespace' );
 3123+ // From here we want to do checks on a file object, so if we can't
 3124+ // create one, we must return.
 3125+ return $errors;
 3126+ }
 3127+
 3128+ // wfFindFile( $nt ) / wfLocalFile( $nt ) is allowed below here
31223129
31233130 $destFile = wfLocalFile( $nt );
31243131 if ( !$wgUser->isAllowed( 'reupload-shared' ) && !$destFile->exists() && wfFindFile( $nt ) ) {
Property changes on: branches/REL1_18/phase3/includes/Title.php
___________________________________________________________________
Modified: svn:mergeinfo
31253132 Merged /trunk/phase3/includes/Title.php:r98426,99371,99632,99897,99910,99914,99952
Index: branches/REL1_18/phase3/includes/DefaultSettings.php
@@ -739,6 +739,12 @@
740740 /** Obsolete, always true, kept for compatibility with extensions */
741741 $wgUseImageResize = true;
742742
 743+/**
 744+ * If set to true, images that contain certain the exif orientation tag will
 745+ * be rotated accordingly. If set to null, try to auto-detect whether a scaler
 746+ * is available that can rotate.
 747+ */
 748+$wgEnableAutoRotation = null;
743749
744750 /**
745751 * Internal name of virus scanner. This servers as a key to the
Index: branches/REL1_18/phase3/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/REL1_18/phase3/includes/specials
___________________________________________________________________
Modified: svn:mergeinfo
417426 Merged /trunk/phase3/includes/specials:r99914,99952
Property changes on: branches/REL1_18/phase3/includes
___________________________________________________________________
Modified: svn:mergeinfo
418427 Merged /trunk/phase3/includes:r98426,99371,99632,99897,99910,99914,99952
Property changes on: branches/REL1_18/phase3
___________________________________________________________________
Modified: svn:mergeinfo
419428 Merged /trunk/phase3:r98426,99371,99632,99897,99910,99914,99952

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r98426(bug 31213) Exception thrown when trying to move file cross-namespace....btongminh18:35, 29 September 2011
r99371Followup r98212; Ensure that true is passed to all uses of SkinTemplateToolbo...dantman19:54, 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
r99910Per r97671, add $wgEnableAutoRotation setting that can be used to explicitly ...btongminh20:30, 15 October 2011
r99914(bug 31674) Can't edit watchlist if it contains special pagesmaxsem21:06, 15 October 2011

Status & tagging log