From 63601400e476c6cf43d985f3e7b9864681695ed4 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Fri, 18 Jan 2013 16:46:04 +0100 Subject: Update to MediaWiki 1.20.2 this update includes: * adjusted Arch Linux skin * updated FluxBBAuthPlugin * patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024 --- includes/libs/CSSJanus.php | 16 ++- includes/libs/CSSMin.php | 26 ++-- includes/libs/GenericArrayObject.php | 244 +++++++++++++++++++++++++++++++++++ includes/libs/HttpStatus.php | 21 +++ includes/libs/IEContentAnalyzer.php | 6 + includes/libs/IEUrlExtension.php | 26 +++- includes/libs/JavaScriptMinifier.php | 10 +- includes/libs/jsminplus.php | 2 +- 8 files changed, 331 insertions(+), 20 deletions(-) create mode 100644 includes/libs/GenericArrayObject.php (limited to 'includes/libs') diff --git a/includes/libs/CSSJanus.php b/includes/libs/CSSJanus.php index c8fc296b..4ebbc497 100644 --- a/includes/libs/CSSJanus.php +++ b/includes/libs/CSSJanus.php @@ -1,5 +1,7 @@ + */ +abstract class GenericArrayObject extends ArrayObject { + + /** + * Returns the name of an interface/class that the element should implement/extend. + * + * @since 1.20 + * + * @return string + */ + public abstract function getObjectType(); + + /** + * @see SiteList::getNewOffset() + * @since 1.20 + * @var integer + */ + protected $indexOffset = 0; + + /** + * Finds a new offset for when appending an element. + * The base class does this, so it would be better to integrate, + * but there does not appear to be any way to do this... + * + * @since 1.20 + * + * @return integer + */ + protected function getNewOffset() { + while ( true ) { + if ( !$this->offsetExists( $this->indexOffset ) ) { + return $this->indexOffset; + } + + $this->indexOffset++; + } + } + + /** + * Constructor. + * @see ArrayObject::__construct + * + * @since 1.20 + * + * @param null|array $input + * @param int $flags + * @param string $iterator_class + */ + public function __construct( $input = null, $flags = 0, $iterator_class = 'ArrayIterator' ) { + parent::__construct( array(), $flags, $iterator_class ); + + if ( !is_null( $input ) ) { + foreach ( $input as $offset => $value ) { + $this->offsetSet( $offset, $value ); + } + } + } + + /** + * @see ArrayObject::append + * + * @since 1.20 + * + * @param mixed $value + */ + public function append( $value ) { + $this->setElement( null, $value ); + } + + /** + * @see ArrayObject::offsetSet() + * + * @since 1.20 + * + * @param mixed $index + * @param mixed $value + */ + public function offsetSet( $index, $value ) { + $this->setElement( $index, $value ); + } + + /** + * Returns if the provided value has the same type as the elements + * that can be added to this ArrayObject. + * + * @since 1.20 + * + * @param mixed $value + * + * @return boolean + */ + protected function hasValidType( $value ) { + $class = $this->getObjectType(); + return $value instanceof $class; + } + + /** + * Method that actually sets the element and holds + * all common code needed for set operations, including + * type checking and offset resolving. + * + * If you want to do additional indexing or have code that + * otherwise needs to be executed whenever an element is added, + * you can overload @see preSetElement. + * + * @since 1.20 + * + * @param mixed $index + * @param mixed $value + * + * @throws InvalidArgumentException + */ + protected function setElement( $index, $value ) { + if ( !$this->hasValidType( $value ) ) { + throw new InvalidArgumentException( + 'Can only add ' . $this->getObjectType() . ' implementing objects to ' . get_called_class() . '.' + ); + } + + if ( is_null( $index ) ) { + $index = $this->getNewOffset(); + } + + if ( $this->preSetElement( $index, $value ) ) { + parent::offsetSet( $index, $value ); + } + } + + /** + * Gets called before a new element is added to the ArrayObject. + * + * At this point the index is always set (ie not null) and the + * value is always of the type returned by @see getObjectType. + * + * Should return a boolean. When false is returned the element + * does not get added to the ArrayObject. + * + * @since 1.20 + * + * @param integer|string $index + * @param mixed $value + * + * @return boolean + */ + protected function preSetElement( $index, $value ) { + return true; + } + + /** + * @see Serializable::serialize + * + * @since 1.20 + * + * @return string + */ + public function serialize() { + return serialize( $this->getSerializationData() ); + } + + /** + * Returns an array holding all the data that should go into serialization calls. + * This is intended to allow overloading without having to reimplement the + * behaviour of this base class. + * + * @since 1.20 + * + * @return array + */ + protected function getSerializationData() { + return array( + 'data' => $this->getArrayCopy(), + 'index' => $this->indexOffset, + ); + } + + /** + * @see Serializable::unserialize + * + * @since 1.20 + * + * @param string $serialization + * + * @return array + */ + public function unserialize( $serialization ) { + $serializationData = unserialize( $serialization ); + + foreach ( $serializationData['data'] as $offset => $value ) { + // Just set the element, bypassing checks and offset resolving, + // as these elements have already gone through this. + parent::offsetSet( $offset, $value ); + } + + $this->indexOffset = $serializationData['index']; + + return $serializationData; + } + + /** + * Returns if the ArrayObject has no elements. + * + * @since 1.20 + * + * @return boolean + */ + public function isEmpty() { + return $this->count() === 0; + } + +} diff --git a/includes/libs/HttpStatus.php b/includes/libs/HttpStatus.php index 2985c652..78d81803 100644 --- a/includes/libs/HttpStatus.php +++ b/includes/libs/HttpStatus.php @@ -1,4 +1,25 @@ + * @license Choose any of Apache, MIT, GPL, LGPL + */ + +/** * This class is meant to safely minify javascript code, while leaving syntactically correct * programs intact. Other libraries, such as JSMin require a certain coding style to work * correctly. OTOH, libraries like jsminplus, that do parse the code correctly are rather * slow, because they construct a complete parse tree before outputting the code minified. * So this class is meant to allow arbitrary (but syntactically correct) input, while being * fast enough to be used for on-the-fly minifying. - * - * Author: Paul Copperman - * License: choose any of Apache, MIT, GPL, LGPL */ - class JavaScriptMinifier { /* Class constants */ diff --git a/includes/libs/jsminplus.php b/includes/libs/jsminplus.php index 8ed08d74..7c4e32bd 100644 --- a/includes/libs/jsminplus.php +++ b/includes/libs/jsminplus.php @@ -1,5 +1,4 @@