Merge "Fix typo in [[MediaWiki:Botpasswords-editexisting/en]]"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 14 Jan 2016 19:04:22 +0000 (19:04 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 14 Jan 2016 19:04:22 +0000 (19:04 +0000)
includes/api/ApiQueryWatchlist.php
includes/jobqueue/JobQueueMemory.php
includes/parser/CoreParserFunctions.php
includes/specials/SpecialBlock.php
languages/i18n/en.json
languages/i18n/qqq.json
tests/phpunit/includes/jobqueue/JobQueueMemoryTest.php [new file with mode: 0644]

index 75fc33e..ffbd75a 100644 (file)
@@ -105,7 +105,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                        $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid );
                        $this->addFieldsIf( 'rc_user_text', $this->fld_user );
                        $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
-                       $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol );
+                       $this->addFieldsIf( array( 'rc_patrolled', 'rc_log_type' ), $this->fld_patrol );
                        $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
                        $this->addFieldsIf( 'wl_notificationtimestamp', $this->fld_notificationtimestamp );
                        $this->addFieldsIf(
index c5d7257..d9b30c7 100644 (file)
@@ -57,7 +57,7 @@ class JobQueueMemory extends JobQueue {
        }
 
        protected function optimalOrder() {
-               return array( 'fifo' );
+               return 'fifo';
        }
 
        protected function doIsEmpty() {
@@ -160,7 +160,7 @@ class JobQueueMemory extends JobQueue {
                        if ( $init !== null ) {
                                self::$data[$this->type][$this->wiki][$field] = $init;
                        } else {
-                               return null;
+                               return $init;
                        }
                }
 
index d25d11a..91b6080 100644 (file)
@@ -813,7 +813,7 @@ class CoreParserFunctions {
                        $titleObject = $parser->mTitle;
                }
                if ( $titleObject->areRestrictionsLoaded() || $parser->incrementExpensiveFunctionCount() ) {
-                       $expiry = $parser->mTitle->getRestrictionExpiry( strtolower( $type ) );
+                       $expiry = $titleObject->getRestrictionExpiry( strtolower( $type ) );
                        // getRestrictionExpiry() returns false on invalid type; trying to
                        // match protectionlevel() function that returns empty string instead
                        if ( $expiry === false ) {
index 226d633..f10c6e1 100644 (file)
@@ -646,12 +646,25 @@ class SpecialBlock extends FormSpecialPage {
                        return array( 'badipaddress' );
                }
 
-               if ( ( strlen( $data['Expiry'] ) == 0 ) || ( strlen( $data['Expiry'] ) > 50 )
-                       || !self::parseExpiryInput( $data['Expiry'] )
+               $expiryTime = self::parseExpiryInput( $data['Expiry'] );
+
+               if (
+                       // an expiry time is needed
+                       ( strlen( $data['Expiry'] ) == 0 ) ||
+                       // can't be a larger string as 50 (it should be a time format in any way)
+                       ( strlen( $data['Expiry'] ) > 50 ) ||
+                       // check, if the time could be parsed
+                       !$expiryTime
                ) {
                        return array( 'ipb_expiry_invalid' );
                }
 
+               // an expiry time should be in the future, not in the
+               // past (wouldn't make any sense) - bug T123069
+               if ( $expiryTime < wfTimestampNow() ) {
+                       return array( 'ipb_expiry_old' );
+               }
+
                if ( !isset( $data['DisableEmail'] ) ) {
                        $data['DisableEmail'] = false;
                }
@@ -695,7 +708,7 @@ class SpecialBlock extends FormSpecialPage {
                $block->setBlocker( $performer );
                # Truncate reason for whole multibyte characters
                $block->mReason = $wgContLang->truncate( $data['Reason'][0], 255 );
-               $block->mExpiry = self::parseExpiryInput( $data['Expiry'] );
+               $block->mExpiry = $expiryTime;
                $block->prevents( 'createaccount', $data['CreateAccount'] );
                $block->prevents( 'editownusertalk', ( !$wgBlockAllowsUTEdit || $data['DisableUTEdit'] ) );
                $block->prevents( 'sendemail', $data['DisableEmail'] );
index fcf1109..602c290 100644 (file)
        "block-log-flags-hiddenname": "username hidden",
        "range_block_disabled": "The administrator ability to create range blocks is disabled.",
        "ipb_expiry_invalid": "Expiry time invalid.",
+       "ipb_expiry_old": "Expiry time is in the past.",
        "ipb_expiry_temp": "Hidden username blocks must be permanent.",
        "ipb_hide_invalid": "Unable to suppress this account; it has more than {{PLURAL:$1|one edit|$1 edits}}.",
        "ipb_already_blocked": "\"$1\" is already blocked.",
index 39873c5..8654523 100644 (file)
        "block-log-flags-hiddenname": "Used as a block log flag in [[Special:Log/block]] and in [[Special:Block]].\n\n{{Related|Block-log-flags}}",
        "range_block_disabled": "Used as error message in [[Special:Block]].\n\nSee also:\n* {{msg-mw|Range block disabled}}\n* {{msg-mw|Ip range invalid}}\n* {{msg-mw|Ip range toolarge}}",
        "ipb_expiry_invalid": "Used as error message in [[Special:Block]].",
+       "ipb_expiry_old": "Used as error message in [[Special:Block]], if the expiry time is in the past.\n{{Identical|protect_expiry_old}}",
        "ipb_expiry_temp": "Warning message displayed on [[Special:BlockIP]] if the option \"hide username\" is selected but the expiry time is not infinite.",
        "ipb_hide_invalid": "Used as error message in [[Special:Block]].\n* $1 - Number of edits (Value of [[mw:Manual:$wgHideUserContribLimit]])",
        "ipb_already_blocked": "{{Identical|$1 is already blocked}}",
diff --git a/tests/phpunit/includes/jobqueue/JobQueueMemoryTest.php b/tests/phpunit/includes/jobqueue/JobQueueMemoryTest.php
new file mode 100644 (file)
index 0000000..a9f7e0e
--- /dev/null
@@ -0,0 +1,30 @@
+<?php
+
+/**
+ * @covers JobQueueMemory
+ *
+ * @group JobQueue
+ *
+ * @licence GNU GPL v2+
+ * @author Thiemo Mättig
+ */
+class JobQueueMemoryTest extends PHPUnit_Framework_TestCase {
+
+       public function testGetAllQueuedJobs() {
+               $instance = JobQueueMemoryDouble::newInstance( array(
+                       'wiki' => null,
+                       'type' => null,
+               ) );
+               $actual = $instance->getAllQueuedJobs();
+               $this->assertEquals( new ArrayIterator(), $actual );
+       }
+
+}
+
+class JobQueueMemoryDouble extends JobQueueMemory {
+
+       public static function newInstance( array $params ) {
+               return new self( $params );
+       }
+
+}