Merge "Streamline code involving .= string concatenations"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 11 Mar 2019 12:39:04 +0000 (12:39 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 11 Mar 2019 12:39:04 +0000 (12:39 +0000)
1  2 
includes/libs/objectcache/BagOStuff.php
languages/Language.php

@@@ -87,6 -87,12 +87,6 @@@ abstract class BagOStuff implements IEx
        /** @var int[] Map of (ATTR_* class constant => QOS_* class constant) */
        protected $attrMap = [];
  
 -      /** Possible values for getLastError() */
 -      const ERR_NONE = 0; // no error
 -      const ERR_NO_RESPONSE = 1; // no response
 -      const ERR_UNREACHABLE = 2; // can't connect
 -      const ERR_UNEXPECTED = 3; // response gave some error
 -
        /** Bitfield constants for get()/getMulti() */
        const READ_LATEST = 1; // use latest data for replicated stores
        const READ_VERIFIED = 2; // promise that caller can tell when keys are stale
         *
         * @param string $key
         * @return bool True if the item was deleted or not found, false on failure
 +       * @param int $flags Bitfield of BagOStuff::WRITE_* constants
         */
 -      abstract public function delete( $key );
 +      abstract public function delete( $key, $flags = 0 );
  
        /**
         * Merge changes into the existing cache value (possibly creating a new one)
         * The callbacks may or may not be called ever, in any particular order.
         * They are likely to be invoked when something WRITE_SYNC is used used.
         * They should follow a caching pattern as shown below, so that any code
 -       * using the word will get it's result no matter what happens.
 +       * using the work will get it's result no matter what happens.
         * @code
         *     $result = null;
         *     $workCallback = function () use ( &$result ) {
                $this->busyCallbacks[] = $workCallback;
        }
  
 -      /**
 -       * Modify a cache update operation array for EventRelayer::notify()
 -       *
 -       * This is used for relayed writes, e.g. for broadcasting a change
 -       * to multiple data-centers. If the array contains a 'val' field
 -       * then the command involves setting a key to that value. Note that
 -       * for simplicity, 'val' is always a simple scalar value. This method
 -       * is used to possibly serialize the value and add any cache-specific
 -       * key/values needed for the relayer daemon (e.g. memcached flags).
 -       *
 -       * @param array $event
 -       * @return array
 -       * @since 1.26
 -       */
 -      public function modifySimpleRelayEvent( array $event ) {
 -              return $event;
 -      }
 -
        /**
         * @param string $text
         */
        public function makeKeyInternal( $keyspace, $args ) {
                $key = $keyspace;
                foreach ( $args as $arg ) {
-                       $arg = str_replace( ':', '%3A', $arg );
-                       $key .= ':' . $arg;
+                       $key .= ':' . str_replace( ':', '%3A', $arg );
                }
                return strtr( $key, ' ', '_' );
        }
diff --combined languages/Language.php
@@@ -3593,14 -3593,12 +3593,12 @@@ class Language 
                                $length -= $ellipsisLength;
                                $string = $getSubstring( $string, 0, $length ); // xyz...
                                $string = $this->removeBadCharLast( $string );
-                               $string = rtrim( $string );
-                               $string = $string . $ellipsis;
+                               $string = rtrim( $string ) . $ellipsis;
                        } else {
                                $length += $ellipsisLength;
                                $string = $getSubstring( $string, $length ); // ...xyz
                                $string = $this->removeBadCharFirst( $string );
-                               $string = ltrim( $string );
-                               $string = $ellipsis . $string;
+                               $string = $ellipsis . ltrim( $string );
                        }
                }
  
                $this->mConverter->updateConversionTable( $title );
        }
  
 -      /**
 -       * Prepare external link text for conversion. When the text is
 -       * a URL, it shouldn't be converted, and it'll be wrapped in
 -       * the "raw" tag (-{R| }-) to prevent conversion.
 -       *
 -       * This function is called "markNoConversion" for historical
 -       * reasons *BUT DIFFERS SIGNIFICANTLY* from
 -       * LanguageConverter::markNoConversion(), with which it is easily
 -       * confused.
 -       *
 -       * @param string $text Text to be used for external link
 -       * @param bool $noParse Wrap it without confirming it's a real URL first
 -       * @return string The tagged text
 -       * @deprecated since 1.32, use LanguageConverter::markNoConversion()
 -       *  instead.
 -       */
 -      public function markNoConversion( $text, $noParse = false ) {
 -              wfDeprecated( __METHOD__, '1.32' );
 -              // Excluding protocal-relative URLs may avoid many false positives.
 -              if ( $noParse || preg_match( '/^(?:' . wfUrlProtocolsWithoutProtRel() . ')/', $text ) ) {
 -                      return $this->mConverter->markNoConversion( $text );
 -              } else {
 -                      return $text;
 -              }
 -      }
 -
        /**
         * A regular expression to match legal word-trailing characters
         * which should be merged onto a link of the form [[foo]]bar.