Merge "Use the MWDebug class to display debug log back in the request."
authorNikerabbit <niklas.laxstrom@gmail.com>
Tue, 28 Aug 2012 05:49:41 +0000 (05:49 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 28 Aug 2012 05:49:41 +0000 (05:49 +0000)
37 files changed:
RELEASE-NOTES-1.20
extensions/README
includes/AutoLoader.php
includes/Category.php
includes/DefaultSettings.php
includes/Defines.php
includes/GlobalFunctions.php
includes/Message.php
includes/Skin.php
includes/Uri.php [deleted file]
includes/db/Database.php
includes/db/DatabasePostgres.php
includes/installer/DatabaseUpdater.php
includes/normal/UtfNormal.php
includes/specials/SpecialDeletedContributions.php
includes/upload/UploadFromUrl.php
languages/classes/LanguageKk.php
maintenance/Maintenance.php
maintenance/importSiteScripts.php
maintenance/language/languages.inc
maintenance/parse.php
opensearch_desc.php
serialized/serialize.php
skins/Simple.php
tests/phpunit/includes/GlobalFunctions/GlobalTest.php
tests/phpunit/includes/UriTest.php [deleted file]
tests/phpunit/includes/db/DatabaseSQLTest.php
tests/selenium/installer/MediaWikiButtonsAvailabilityTestCase.php
tests/selenium/installer/MediaWikiInstallationCommonFunction.php
tests/selenium/installer/MediaWikiMySQLDataBaseTestCase.php
tests/selenium/installer/MediaWikiMySQLiteDataBaseTestCase.php
tests/selenium/installer/MediaWikiOnAlreadyInstalledTestCase.php
tests/selenium/installer/MediaWikiRestartInstallationTestCase.php
tests/selenium/installer/MediaWikiRightFrameworkLinksTestCase.php
tests/selenium/installer/MediaWikiUpgradeExistingDatabaseTestCase.php
tests/selenium/installer/MediaWikiUserInterfaceTestCase.php
thumb.php

index e06dc7d..1791d4d 100644 (file)
@@ -260,6 +260,7 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 38904) prop=revisions&rvstart=... no longer blows up when continuing.
 * (bug 39032) ApiQuery generates help in constructor.
 * (bug 11142) Improve file extension blacklist error reporting in API upload
+* (bug 39635) PostgreSQL LOCK IN SHARE MODE option is a syntax error
 
 === Languages updated in 1.20 ===
 
index 22f4710..e810286 100644 (file)
@@ -21,10 +21,10 @@ Please note that under POSIX systems (Linux...), parent of a symbolic path
 refers to the link source, NOT to the target! You should check the env
 variable MW_INSTALL_PATH in case the extension is not in the default location.
 
-The following code snippet let you override the default path: 
+The following code snippet lets you override the default path: 
 
  $IP = getenv( 'MW_INSTALL_PATH' );
  if( $IP === false ) {
-       $IP = dirname( __FILE__ ) . '/../..';
+       $IP = __DIR__ . '/../..';
  }
  require_once( "$IP/maintenance/Maintenance.php" ); // a MediaWiki core file
index b299796..23b88fc 100644 (file)
@@ -252,7 +252,6 @@ $wgAutoloadLocalClasses = array(
        'UnlistedSpecialPage' => 'includes/SpecialPage.php',
        'UploadSourceAdapter' => 'includes/Import.php',
        'UppercaseCollation' => 'includes/Collation.php',
-       'Uri' => 'includes/Uri.php',
        'User' => 'includes/User.php',
        'UserArray' => 'includes/UserArray.php',
        'UserArrayFromResult' => 'includes/UserArray.php',
index d9ca234..b7b12e8 100644 (file)
@@ -297,8 +297,8 @@ class Category {
                        'IGNORE'
                );
 
-               $cond1 = $dbw->conditional( 'page_namespace=' . NS_CATEGORY, 1, 'NULL' );
-               $cond2 = $dbw->conditional( 'page_namespace=' . NS_FILE, 1, 'NULL' );
+               $cond1 = $dbw->conditional( array( 'page_namespace' => NS_CATEGORY ), 1, 'NULL' );
+               $cond2 = $dbw->conditional( array( 'page_namespace' => NS_FILE ), 1, 'NULL' );
                $result = $dbw->selectRow(
                        array( 'categorylinks', 'page' ),
                        array( 'pages' => 'COUNT(*)',
index c58746b..045eb98 100644 (file)
@@ -5212,7 +5212,7 @@ $wgExtensionFunctions = array();
  *
  * @par Example:
  * @code
- *    $wgExtensionMessagesFiles['ConfirmEdit'] = dirname(__FILE__).'/ConfirmEdit.i18n.php';
+ *    $wgExtensionMessagesFiles['ConfirmEdit'] = __DIR__.'/ConfirmEdit.i18n.php';
  * @endcode
  */
 $wgExtensionMessagesFiles = array();
index 55d9a7a..be9f981 100644 (file)
@@ -205,7 +205,7 @@ define( 'LIST_SET_PREPARED', 8);  // List of (?, ?, ?) for DatabaseIbm_db2
 /**
  * Unicode and normalisation related
  */
-require_once dirname(__FILE__).'/normal/UtfNormalDefines.php';
+require_once __DIR__.'/normal/UtfNormalDefines.php';
 
 /**@{
  * Hook support constants
index 3e38435..328d429 100644 (file)
@@ -391,7 +391,7 @@ function wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) {
 
        $cgi = '';
        foreach ( $array1 as $key => $value ) {
-               if ( $value !== false ) {
+               if ( !is_null($value) && $value !== false ) {
                        if ( $cgi != '' ) {
                                $cgi .= '&';
                        }
@@ -412,11 +412,8 @@ function wfArrayToCgi( $array1, $array2 = null, $prefix = '' ) {
                        } else {
                                if ( is_object( $value ) ) {
                                        $value = $value->__toString();
-                               } elseif( !is_null( $value ) ) {
-                                       $cgi .= urlencode( $key ) . '=' . urlencode( $value );
-                               } else {
-                                       $cgi .= urlencode( $key );
                                }
+                               $cgi .= urlencode( $key ) . '=' . urlencode( $value );
                        }
                }
        }
@@ -443,15 +440,14 @@ function wfCgiToArray( $query ) {
                        continue;
                }
                if ( strpos( $bit, '=' ) === false ) {
-                       // Pieces like &qwerty become 'qwerty' => null
-                       $key = urldecode( $bit );
-                       $value = null;
+                       // Pieces like &qwerty become 'qwerty' => '' (at least this is what php does)
+                       $key = $bit;
+                       $value = '';
                } else {
                        list( $key, $value ) = explode( '=', $bit );
-                       $key = urldecode( $key );
-                       $value = urldecode( $value );
                }
-
+               $key = urldecode( $key );
+               $value = urldecode( $value );
                if ( strpos( $key, '[' ) !== false ) {
                        $keys = array_reverse( explode( '[', $key ) );
                        $key = array_pop( $keys );
@@ -476,15 +472,23 @@ function wfCgiToArray( $query ) {
  * Append a query string to an existing URL, which may or may not already
  * have query string parameters already. If so, they will be combined.
  *
- * @deprecated in 1.20. Use Uri class.
  * @param $url String
  * @param $query Mixed: string or associative array
  * @return string
  */
 function wfAppendQuery( $url, $query ) {
-       $obj = new Uri( $url );
-       $obj->extendQuery( $query );
-       return $obj->toString();
+       if ( is_array( $query ) ) {
+               $query = wfArrayToCgi( $query );
+       }
+       if( $query != '' ) {
+               if( false === strpos( $url, '?' ) ) {
+                       $url .= '?';
+               } else {
+                       $url .= '&';
+               }
+               $url .= $query;
+       }
+       return $url;
 }
 
 /**
@@ -572,13 +576,49 @@ function wfExpandUrl( $url, $defaultProto = PROTO_CURRENT ) {
  * @todo Need to integrate this into wfExpandUrl (bug 32168)
  *
  * @since 1.19
- * @deprecated
  * @param $urlParts Array URL parts, as output from wfParseUrl
  * @return string URL assembled from its component parts
  */
 function wfAssembleUrl( $urlParts ) {
-       $obj = new Uri( $urlParts );
-       return $obj->toString();
+       $result = '';
+
+       if ( isset( $urlParts['delimiter'] ) ) {
+               if ( isset( $urlParts['scheme'] ) ) {
+                       $result .= $urlParts['scheme'];
+               }
+
+               $result .= $urlParts['delimiter'];
+       }
+
+       if ( isset( $urlParts['host'] ) ) {
+               if ( isset( $urlParts['user'] ) ) {
+                       $result .= $urlParts['user'];
+                       if ( isset( $urlParts['pass'] ) ) {
+                               $result .= ':' . $urlParts['pass'];
+                       }
+                       $result .= '@';
+               }
+
+               $result .= $urlParts['host'];
+
+               if ( isset( $urlParts['port'] ) ) {
+                       $result .= ':' . $urlParts['port'];
+               }
+       }
+
+       if ( isset( $urlParts['path'] ) ) {
+               $result .= $urlParts['path'];
+       }
+
+       if ( isset( $urlParts['query'] ) ) {
+               $result .= '?' . $urlParts['query'];
+       }
+
+       if ( isset( $urlParts['fragment'] ) ) {
+               $result .= '#' . $urlParts['fragment'];
+       }
+
+       return $result;
 }
 
 /**
@@ -725,13 +765,58 @@ function wfUrlProtocolsWithoutProtRel() {
  * 2) Handles protocols that don't use :// (e.g., mailto: and news: , as well as protocol-relative URLs) correctly
  * 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2))
  *
- * @deprecated
  * @param $url String: a URL to parse
  * @return Array: bits of the URL in an associative array, per PHP docs
  */
 function wfParseUrl( $url ) {
-       $obj = new Uri( $url );
-       return $obj->getComponents();
+       global $wgUrlProtocols; // Allow all protocols defined in DefaultSettings/LocalSettings.php
+
+       // Protocol-relative URLs are handled really badly by parse_url(). It's so bad that the easiest
+       // way to handle them is to just prepend 'http:' and strip the protocol out later
+       $wasRelative = substr( $url, 0, 2 ) == '//';
+       if ( $wasRelative ) {
+               $url = "http:$url";
+       }
+       wfSuppressWarnings();
+       $bits = parse_url( $url );
+       wfRestoreWarnings();
+       // parse_url() returns an array without scheme for some invalid URLs, e.g.
+       // parse_url("%0Ahttp://example.com") == array( 'host' => '%0Ahttp', 'path' => 'example.com' )
+       if ( !$bits || !isset( $bits['scheme'] ) ) {
+               return false;
+       }
+
+       // most of the protocols are followed by ://, but mailto: and sometimes news: not, check for it
+       if ( in_array( $bits['scheme'] . '://', $wgUrlProtocols ) ) {
+               $bits['delimiter'] = '://';
+       } elseif ( in_array( $bits['scheme'] . ':', $wgUrlProtocols ) ) {
+               $bits['delimiter'] = ':';
+               // parse_url detects for news: and mailto: the host part of an url as path
+               // We have to correct this wrong detection
+               if ( isset( $bits['path'] ) ) {
+                       $bits['host'] = $bits['path'];
+                       $bits['path'] = '';
+               }
+       } else {
+               return false;
+       }
+
+       /* Provide an empty host for eg. file:/// urls (see bug 28627) */
+       if ( !isset( $bits['host'] ) ) {
+               $bits['host'] = '';
+
+               /* parse_url loses the third / for file:///c:/ urls (but not on variants) */
+               if ( substr( $bits['path'], 0, 1 ) !== '/' ) {
+                       $bits['path'] = '/' . $bits['path'];
+               }
+       }
+
+       // If the URL was protocol-relative, fix scheme and delimiter
+       if ( $wasRelative ) {
+               $bits['scheme'] = '';
+               $bits['delimiter'] = '//';
+       }
+       return $bits;
 }
 
 /**
index 68eb650..776a52f 100644 (file)
@@ -297,6 +297,7 @@ class Message {
        /**
         * Add parameters that are numeric and will be passed through
         * Language::formatNum before substitution
+        * @since 1.18
         * @param Varargs: numeric parameters (or single argument that is array of numeric parameters)
         * @return Message: $this
         */
index c13fed5..0b0b616 100644 (file)
@@ -437,7 +437,7 @@ abstract class Skin extends ContextSource {
                if ( !empty( $allCats['normal'] ) ) {
                        $t = $embed . implode( "{$pop}{$embed}" , $allCats['normal'] ) . $pop;
 
-                       $msg = $this->msg( 'pagecategories', count( $allCats['normal'] ) )->escaped();
+                       $msg = $this->msg( 'pagecategories' )->numParams( count( $allCats['normal'] ) )->escaped();
                        $linkPage = wfMessage( 'pagecategorieslink' )->inContentLanguage()->text();
                        $s .= '<div id="mw-normal-catlinks" class="mw-normal-catlinks">' .
                                Linker::link( Title::newFromText( $linkPage ), $msg )
@@ -455,7 +455,7 @@ abstract class Skin extends ContextSource {
                        }
 
                        $s .= "<div id=\"mw-hidden-catlinks\" class=\"mw-hidden-catlinks$class\">" .
-                               $this->msg( 'hidden-categories', count( $allCats['hidden'] ) )->escaped() .
+                               $this->msg( 'hidden-categories' )->numParams( count( $allCats['hidden'] ) )->escaped() .
                                $colon . '<ul>' . $embed . implode( "{$pop}{$embed}" , $allCats['hidden'] ) . $pop . '</ul>' .
                                '</div>';
                }
diff --git a/includes/Uri.php b/includes/Uri.php
deleted file mode 100644 (file)
index deabbb2..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-<?php
-/**
- * Class for simple URI parsing and manipulation.
- * Intended to simplify things that were using wfParseUrl and
- * had to do manual concatenation for various needs.
- * Built to match our JS mw.Uri in naming patterns.
- * @file
- * @author Daniel Friesen
- * @since 1.20
- */
-
-class Uri {
-
-       /**
-        * The parsed components of the URI
-        */
-       protected $components;
-
-       protected static $validComponents = array( 'scheme', 'delimiter', 'host', 'port', 'user', 'pass', 'path', 'query', 'fragment' );
-       protected static $componentAliases = array( 'protocol' => 'scheme', 'password' => 'pass' );
-
-       /**
-        * parse_url() work-alike, but non-broken.  Differences:
-        *
-        * 1) Does not raise warnings on bad URLs (just returns false)
-        * 2) Handles protocols that don't use :// (e.g., mailto: and news: , as well as protocol-relative URLs) correctly
-        * 3) Adds a "delimiter" element to the array, either '://', ':' or '//' (see (2))
-        *
-        * @param $url String: a URL to parse
-        * @return Array: bits of the URL in an associative array, per PHP docs
-        */
-       protected static function parseUri( $url ) {
-               global $wgUrlProtocols; // Allow all protocols defined in DefaultSettings/LocalSettings.php
-
-               // Protocol-relative URLs are handled really badly by parse_url(). It's so bad that the easiest
-               // way to handle them is to just prepend 'http:' and strip the protocol out later
-               $wasRelative = substr( $url, 0, 2 ) == '//';
-               if ( $wasRelative ) {
-                       $url = "http:$url";
-               }
-               wfSuppressWarnings();
-               $bits = parse_url( $url );
-               wfRestoreWarnings();
-               // parse_url() returns an array without scheme for some invalid URLs, e.g.
-               // parse_url("%0Ahttp://example.com") == array( 'host' => '%0Ahttp', 'path' => 'example.com' )
-               if ( !$bits ||
-                    !isset( $bits['scheme'] ) && strpos( $url, "://" ) !== false ) {
-                       wfDebug( __METHOD__ . ": Invalid URL: $url" );
-                       return false;
-               } else {
-                       $scheme = isset( $bits['scheme'] ) ? $bits['scheme'] : null;
-               }
-
-               // most of the protocols are followed by ://, but mailto: and sometimes news: not, check for it
-               if ( in_array( $scheme . '://', $wgUrlProtocols ) ) {
-                       $bits['delimiter'] = '://';
-               } elseif ( !is_null( $scheme ) && !in_array( $scheme . ':', $wgUrlProtocols ) ) {
-                       wfDebug( __METHOD__ . ": Invalid scheme in URL: $scheme" );
-                       return false;
-               } elseif( !is_null( $scheme ) ) {
-                       if( !in_array( $scheme . ':', $wgUrlProtocols ) ) {
-                               // For URLs that don't have a scheme, but do have a user:password, parse_url
-                               // detects the user as the scheme.
-                               unset( $bits['scheme'] );
-                               $bits['user'] = $scheme;
-                       } else {
-                               $bits['delimiter'] = ':';
-                               // parse_url detects for news: and mailto: the host part of an url as path
-                               // We have to correct this wrong detection
-                               if ( isset( $bits['path'] ) ) {
-                                       $bits['host'] = $bits['path'];
-                                       $bits['path'] = '';
-                               }
-                       }
-               }
-
-               /* Provide an empty host for eg. file:/// urls (see bug 28627) */
-               if ( !isset( $bits['host'] ) && $scheme == "file" ) {
-                       $bits['host'] = '';
-
-                       /* parse_url loses the third / for file:///c:/ urls (but not on variants) */
-                       if ( isset( $bits['path'] ) && substr( $bits['path'], 0, 1 ) !== '/' ) {
-                               $bits['path'] = '/' . $bits['path'];
-                       }
-               }
-
-               // If the URL was protocol-relative, fix scheme and delimiter
-               if ( $wasRelative ) {
-                       $bits['scheme'] = '';
-                       $bits['delimiter'] = '//';
-               }
-               return $bits;
-       }
-
-       /**
-        *
-        * @param $uri mixed URI string or array
-        */
-       public function __construct( $uri ) {
-               $this->components = array();
-               $this->setUri( $uri );
-       }
-
-       /**
-        * Set the Uri to the value of some other URI.
-        *
-        * @param $uri mixed URI string or array
-        */
-       public function setUri( $uri ) {
-               if ( is_string( $uri ) ) {
-                       $parsed = self::parseUri( $uri );
-                       if( $parsed === false ) {
-                               return false;
-                       }
-                       $this->setComponents( $parsed );
-               } elseif ( is_array( $uri ) ) {
-                       $this->setComponents( $uri );
-               } elseif ( $uri instanceof Uri ) {
-                       $this->setComponents( $uri->getComponents() );
-               } else {
-                       throw new MWException( __METHOD__ . ": $uri is not of a valid type." );
-               }
-       }
-
-       /**
-        * Set the components of this array.
-        * Will output warnings when invalid components or aliases are found.
-        *
-        * @param $components Array The components to set on this Uri.
-        */
-       public function setComponents( array $components ) {
-               foreach ( $components as $name => $value ) {
-                       if ( isset( self::$componentAliases[$name] ) ) {
-                               $canonical = self::$componentAliases[$name];
-                               wfDebug( __METHOD__ . ": Converting alias $name to canonical $canonical." );
-                               $components[$canonical] = $value;
-                               unset( $components[$name] );
-                       } elseif ( !in_array( $name, self::$validComponents ) ) {
-                               throw new MWException( __METHOD__ . ": $name is not a valid component." );
-                       }
-               }
-
-               $this->components = $components;
-       }
-
-       /**
-        * Return the components for this Uri
-        * @return Array
-        */
-       public function getComponents() {
-               return $this->components;
-       }
-
-       /**
-        * Return the value of a specific component
-        *
-        * @param $name string The name of the component to return
-        * @param string|null
-        */
-       public function getComponent( $name ) {
-               if ( isset( self::$componentAliases[$name] ) ) {
-                       // Component is an alias. Get the actual name.
-                       $alias = $name;
-                       $name = self::$componentAliases[$name];
-                       wfDebug( __METHOD__ . ": Converting alias $alias to canonical $name." );
-               }
-
-               if( !in_array( $name, self::$validComponents ) ) {
-                       // Component is invalid
-                       throw new MWException( __METHOD__ . ": $name is not a valid component." );
-               } elseif( !empty( $this->components[$name] ) ) {
-                       // Component is valid and has a value.
-                       return $this->components[$name];
-               } else {
-                       // Component is empty
-                       return null;
-               }
-       }
-
-       /**
-        * Set a component for this Uri
-        * @param $name string The name of the component to set
-        * @param $value string|null The value to set
-        */
-       public function setComponent( $name, $value ) {
-               if ( isset( self::$componentAliases[$name] ) ) {
-                       $alias = $name;
-                       $name = self::$componentAliases[$name];
-                       wfDebug( __METHOD__ . ": Converting alias $alias to canonical $name." );
-               } elseif ( !in_array( $name, self::$validComponents ) ) {
-                       throw new MWException( __METHOD__ . ": $name is not a valid component." );
-               }
-               $this->components[$name] = $value;
-       }
-
-       public function getProtocol() { return $this->getComponent( 'scheme' ); }
-       public function getUser() { return $this->getComponent( 'user' ); }
-       public function getPassword() { return $this->getComponent( 'pass' ); }
-       public function getHost() { return $this->getComponent( 'host' ); }
-       public function getPort() { return $this->getComponent( 'port' ); }
-       public function getPath() { return $this->getComponent( 'path' ); }
-       public function getQueryString() { return $this->getComponent( 'query' ); }
-       public function getFragment() { return $this->getComponent( 'fragment' ); }
-
-       public function setProtocol( $scheme ) { $this->setComponent( 'scheme', $scheme ); }
-       public function setUser( $user ) { $this->setComponent( 'user', $user ); }
-       public function setPassword( $pass ) { $this->setComponent( 'pass', $pass ); }
-       public function setHost( $host ) { $this->setComponent( 'host', $host ); }
-       public function setPort( $port ) { $this->setComponent( 'port', $port ); }
-       public function setPath( $path ) { $this->setComponent( 'path', $path ); }
-       public function setFragment( $fragment ) { $this->setComponent( 'fragment', $fragment ); }
-
-       /**
-        * Gets the protocol-authority delimiter of a URI (:// or //).
-        * @return string|null
-        */
-       public function getDelimiter() {
-               $delimiter = $this->getComponent( 'delimiter' );
-               if ( $delimiter ) {
-                       // A specific delimiter is set, so return it.
-                       return $delimiter;
-               }
-               if ( $this->getAuthority() && $this->getProtocol() ) {
-                       // If the URI has a protocol and a body (i.e., some sort of host, etc.)
-                       // the default delimiter is "://", e.g., "http://test.com".
-                       return '://';
-               }
-               return null;
-       }
-
-       /**
-        * Gets query portion of a URI in array format.
-        * @return string
-        */
-       public function getQuery() {
-               return wfCgiToArray( $this->getQueryString() );
-       }
-
-       /**
-        * Gets query portion of a URI.
-        * @param string|array $query
-        */
-       public function setQuery( $query ) {
-               if ( is_array( $query ) ) {
-                       $query = wfArrayToCGI( $query );
-               }
-               $this->setComponent( 'query', $query );
-       }
-
-       /**
-        * Extend the query -- supply query parameters to override or add to ours
-        * @param Array|string $parameters query parameters to override or add
-        * @return Uri this URI object
-        */
-       public function extendQuery( $parameters ) {
-               if ( !is_array( $parameters ) ) {
-                       $parameters = wfCgiToArray( $parameters );
-               }
-
-               $query = $this->getQuery();
-               foreach( $parameters as $key => $value ) {
-                       $query[$key] = $value;
-               }
-
-               $this->setQuery( $query );
-               return $this;
-       }
-
-       /**
-        * Returns user and password portion of a URI.
-        * @return string
-        */
-       public function getUserInfo() {
-               $user = $this->getComponent( 'user' );
-               $pass = $this->getComponent( 'pass' );
-               return $pass ? "$user:$pass" : $user;
-       }
-
-       /**
-        * Gets host and port portion of a URI.
-        * @return string
-        */
-       public function getHostPort() {
-               $host = $this->getComponent( 'host' );
-               $port = $this->getComponent( 'port' );
-               return $port ? "$host:$port" : $host;
-       }
-
-       /**
-        * Returns the userInfo and host and port portion of the URI.
-        * In most real-world URLs, this is simply the hostname, but it is more general.
-        * @return string
-        */
-       public function getAuthority() {
-               $userinfo = $this->getUserInfo();
-               $hostinfo = $this->getHostPort();
-               return $userinfo ? "$userinfo@$hostinfo" : $hostinfo;
-       }
-
-       /**
-        * Returns everything after the authority section of the URI
-        * @return String
-        */
-       public function getRelativePath() {
-               $path = $this->getComponent( 'path' );
-               $query = $this->getComponent( 'query' );
-               $fragment = $this->getComponent( 'fragment' );
-
-               $retval = $path;
-               if( $query ) {
-                       $retval .= "?$query";
-               }
-               if( $fragment ) {
-                       $retval .= "#$fragment";
-               }
-               return $retval;
-       }
-
-       /**
-        * Gets the entire URI string. May not be precisely the same as input due to order of query arguments.
-        * @return String the URI string
-        */
-       public function toString() {
-               return $this->getComponent( 'scheme' ) . $this->getDelimiter() . $this->getAuthority() . $this->getRelativePath();
-       }
-
-       /**
-        * Gets the entire URI string. May not be precisely the same as input due to order of query arguments.
-        * @return String the URI string
-        */
-       public function __toString() {
-               return $this->toString();
-       }
-
-}
index 61061b2..ae5335b 100644 (file)
@@ -2621,12 +2621,15 @@ abstract class DatabaseBase implements DatabaseType {
         * Returns an SQL expression for a simple conditional.  This doesn't need
         * to be overridden unless CASE isn't supported in your DBMS.
         *
-        * @param $cond String: SQL expression which will result in a boolean value
+        * @param $cond string|array SQL expression which will result in a boolean value
         * @param $trueVal String: SQL expression to return if true
         * @param $falseVal String: SQL expression to return if false
         * @return String: SQL fragment
         */
        public function conditional( $cond, $trueVal, $falseVal ) {
+               if ( is_array( $cond ) ) {
+                       $cond = $this->makeList( $cond, LIST_AND );
+               }
                return " (CASE WHEN $cond THEN $trueVal ELSE $falseVal END) ";
        }
 
index 8f8f5e8..457bf38 100644 (file)
@@ -1406,9 +1406,6 @@ SQL;
                if ( isset( $noKeyOptions['FOR UPDATE'] ) ) {
                        $postLimitTail .= ' FOR UPDATE';
                }
-               if ( isset( $noKeyOptions['LOCK IN SHARE MODE'] ) ) {
-                       $postLimitTail .= ' LOCK IN SHARE MODE';
-               }
                if ( isset( $noKeyOptions['DISTINCT'] ) || isset( $noKeyOptions['DISTINCTROW'] ) ) {
                        $startOpts .= 'DISTINCT';
                }
index d989427..ff0a99e 100644 (file)
@@ -21,7 +21,7 @@
  * @ingroup Deployment
  */
 
-require_once( dirname(__FILE__) . '/../../maintenance/Maintenance.php' );
+require_once( __DIR__ . '/../../maintenance/Maintenance.php' );
 
 /**
  * Class for handling database updates. Roughly based off of updaters.inc, with
index 2b400e5..08f85bd 100644 (file)
@@ -190,7 +190,7 @@ class UtfNormal {
         */
        static function loadData() {
                if( !isset( self::$utfCombiningClass ) ) {
-                       require_once( dirname(__FILE__) . '/UtfNormalData.inc' );
+                       require_once( __DIR__ . '/UtfNormalData.inc' );
                }
        }
 
index ff2a901..991e7a2 100644 (file)
@@ -94,17 +94,17 @@ class DeletedContribsPager extends IndexPager {
                if ( isset( $this->mNavigationBar ) ) {
                        return $this->mNavigationBar;
                }
-               $lang = $this->getLanguage();
-               $fmtLimit = $lang->formatNum( $this->mLimit );
+
                $linkTexts = array(
-                       'prev' => $this->msg( 'pager-newer-n', $fmtLimit )->escaped(),
-                       'next' => $this->msg( 'pager-older-n', $fmtLimit )->escaped(),
+                       'prev' => $this->msg( 'pager-newer-n' )->numParams( $this->mLimit )->escaped(),
+                       'next' => $this->msg( 'pager-older-n' )->numParams( $this->mLimit )->escaped(),
                        'first' => $this->msg( 'histlast' )->escaped(),
                        'last' => $this->msg( 'histfirst' )->escaped()
                );
 
                $pagingLinks = $this->getPagingLinks( $linkTexts );
                $limitLinks = $this->getLimitLinks();
+               $lang = $this->getLanguage();
                $limits = $lang->pipeList( $limitLinks );
 
                $this->mNavigationBar = "(" . $lang->pipeList( array( $pagingLinks['first'], $pagingLinks['last'] ) ) . ") " .
index fdd2b1a..c11d719 100644 (file)
@@ -70,14 +70,13 @@ class UploadFromUrl extends UploadBase {
                if ( !count( $wgCopyUploadsDomains ) ) {
                        return true;
                }
-               $uri = new Uri( $url );
-               $parsedDomain = $uri->getHost();
-               if ( $parsedDomain === null ) {
+               $parsedUrl = wfParseUrl( $url );
+               if ( !$parsedUrl ) {
                        return false;
                }
                $valid = false;
                foreach( $wgCopyUploadsDomains as $domain ) {
-                       if ( $parsedDomain === $domain ) {
+                       if ( $parsedUrl['host'] === $domain ) {
                                $valid = true;
                                break;
                        }
index 5cf1afd..de0f4ff 100644 (file)
@@ -62,7 +62,7 @@ class KkConverter extends LanguageConverter {
        }
 
        function loadDefaultTables() {
-               // require( dirname(__FILE__)."/../../includes/KkConversion.php" );
+               // require( __DIR__."/../../includes/KkConversion.php" );
                // Placeholder for future implementing. Remove variables declarations
                // after generating KkConversion.php
                $kk2Cyrl = array();
index af549d7..6da5815 100644 (file)
  * @defgroup Maintenance Maintenance
  */
 
+// Make sure we're on PHP5 or better
+if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.3.2' ) < 0 ) {
+       require_once( dirname( __FILE__ ) . '/../includes/PHPVersionError.php' );
+       wfPHPVersionError( 'cli' );
+}
+
 /**
  * @defgroup MaintenanceArchive Maintenance archives
  * @ingroup Maintenance
  */
 
 // Define this so scripts can easily find doMaintenance.php
-define( 'RUN_MAINTENANCE_IF_MAIN', dirname( __FILE__ ) . '/doMaintenance.php' );
+define( 'RUN_MAINTENANCE_IF_MAIN', __DIR__ . '/doMaintenance.php' );
 define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless
 
 $maintClass = false;
 
-// Make sure we're on PHP5 or better
-if ( !function_exists( 'version_compare' ) || version_compare( PHP_VERSION, '5.3.2' ) < 0 ) {
-       require_once( dirname( __FILE__ ) . '/../includes/PHPVersionError.php' );
-       wfPHPVersionError( 'cli' );
-}
 
 /**
  * Abstract maintenance class for quickly writing and churning out
index ae28567..e369cb1 100644 (file)
@@ -56,12 +56,9 @@ class ImportSiteScripts extends Maintenance {
                        }
 
                        $this->output( "Importing $page\n" );
-                       $uri = new Uri( $baseUrl );
-                       $uri->extendQuery( array(
+                       $url = wfAppendQuery( $baseUrl, array(
                                'action' => 'raw',
                                'title' => "MediaWiki:{$page}" ) );
-                       $url = $uri->toString();
-
                        $text = Http::get( $url );
 
                        $wikiPage = WikiPage::factory( $title );
@@ -82,9 +79,7 @@ class ImportSiteScripts extends Maintenance {
                $pages = array();
 
                do {
-                       $uri = new Uri( $baseUrl );
-                       $uri->extendQuery( $data );
-                       $url = $uri->toString();
+                       $url = wfAppendQuery( $baseUrl, $data );
                        $strResult = Http::get( $url );
                        //$result = FormatJson::decode( $strResult ); // Still broken
                        $result = unserialize( $strResult );
index 15fa712..b76f921 100644 (file)
@@ -46,7 +46,7 @@ class languages {
         * @param $exif bool Treat the EXIF messages?
         */
        function __construct( $exif = true ) {
-               require( dirname(__FILE__) . '/messageTypes.inc' );
+               require( __DIR__ . '/messageTypes.inc' );
                $this->mIgnoredMessages = $wgIgnoredMessages;
                if ( $exif ) {
                        $this->mOptionalMessages = array_merge( $wgOptionalMessages );
index c1a890b..b0ab624 100644 (file)
@@ -49,7 +49,7 @@
  * @license GNU General Public License 2.0 or later
  */
 
-require_once( dirname(__FILE__) . '/Maintenance.php' );
+require_once( __DIR__ . '/Maintenance.php' );
 
 /**
  * Maintenance script to parse some wikitext.
index 630b05c..95f028a 100644 (file)
@@ -20,7 +20,7 @@
  * @file
  */
 
-require_once( dirname(__FILE__) . '/includes/WebStart.php' );
+require_once( __DIR__ . '/includes/WebStart.php' );
 
 if( $wgRequest->getVal( 'ctype' ) == 'application/xml' ) {
        // Makes testing tweaks about a billion times easier
index d8fb2b3..0e0ce80 100644 (file)
@@ -3,7 +3,7 @@
 if ( !defined( 'MEDIAWIKI' ) ) {
        $wgNoDBParam = true;
        $optionsWithArgs = array( 'o' );
-       require_once( dirname(__FILE__).'/../maintenance/commandLine.inc' );
+       require_once( __DIR__ .'/../maintenance/commandLine.inc' );
 
        $stderr = fopen( 'php://stderr', 'w' );
        if ( !isset( $args[0] ) ) {
index d06bdfd..9a3ab94 100644 (file)
@@ -26,7 +26,7 @@ if( !defined( 'MEDIAWIKI' ) )
        die( -1 );
 
 /** */
-require_once( dirname(__FILE__) . '/MonoBook.php' );
+require_once( __DIR__ . '/MonoBook.php' );
 
 /**
  * Inherit main code from SkinTemplate, set the CSS and template filter.
index 129f271..9097d30 100644 (file)
@@ -108,7 +108,7 @@ class GlobalTest extends MediaWikiTestCase {
                        array( array( 'foo' => 1 ), 'foo=1' ), // number test
                        array( array( 'foo' => true ), 'foo=1' ), // true test
                        array( array( 'foo' => false ), '' ), // false test
-                       array( array( 'foo' => null ), 'foo' ), // null test
+                       array( array( 'foo' => null ), '' ), // null test
                        array( array( 'foo' => 'A&B=5+6@!"\'' ), 'foo=A%26B%3D5%2B6%40%21%22%27' ), // urlencoding test
                        array( array( 'foo' => 'bar', 'baz' => 'is', 'asdf' => 'qwerty' ), 'foo=bar&baz=is&asdf=qwerty' ), // multi-item test
                        array( array( 'foo' => array( 'bar' => 'baz' ) ), 'foo%5Bbar%5D=baz' ),
diff --git a/tests/phpunit/includes/UriTest.php b/tests/phpunit/includes/UriTest.php
deleted file mode 100644 (file)
index 3b78f47..0000000
+++ /dev/null
@@ -1,164 +0,0 @@
-<?php
-
-class UriTest extends MediaWikiTestCase {
-
-       function setUp() {
-               AutoLoader::loadClass( 'Uri' );
-       }
-
-       function dataUris() {
-               return array(
-                       array(
-                               'http://example.com/',
-                               array(
-                                       'scheme'    => 'http',
-                                       'delimiter' => '://',
-                                       'user'      => null,
-                                       'pass'      => null,
-                                       'host'      => 'example.com',
-                                       'port'      => null,
-                                       'path'      => '/',
-                                       'query'     => null,
-                                       'fragment'  => null,
-                               ),
-                       ),
-                       array(
-                               '//mediawiki.org/wiki/Main_Page',
-                               array(
-                                       'scheme'    => null,
-                                       'delimiter' => '//',
-                                       'user'      => null,
-                                       'pass'      => null,
-                                       'host'      => 'mediawiki.org',
-                                       'port'      => null,
-                                       'path'      => '/wiki/Main_Page',
-                                       'query'     => null,
-                                       'fragment'  => null,
-                               ),
-                       ),
-                       array(
-                               'http://user:pass@example.com/',
-                               array(
-                                       'scheme'    => 'http',
-                                       'delimiter' => '://',
-                                       'user'      => 'user',
-                                       'pass'      => 'pass',
-                                       'host'      => 'example.com',
-                                       'port'      => null,
-                                       'path'      => '/',
-                                       'query'     => null,
-                                       'fragment'  => null,
-                               ),
-                       ),
-                       array(
-                               '/?asdf=asdf',
-                               array(
-                                       'scheme'    => null,
-                                       'delimiter' => null,
-                                       'user'      => null,
-                                       'pass'      => null,
-                                       'host'      => null,
-                                       'port'      => null,
-                                       'path'      => '/',
-                                       'query'     => 'asdf=asdf',
-                                       'fragment'  => null,
-                               ),
-                       ),
-                       array(
-                               '?asdf=asdf#asdf',
-                               array(
-                                       'scheme'    => null,
-                                       'delimiter' => null,
-                                       'user'      => null,
-                                       'pass'      => null,
-                                       'host'      => null,
-                                       'port'      => null,
-                                       'path'      => null,
-                                       'query'     => 'asdf=asdf',
-                                       'fragment'  => 'asdf',
-                               ),
-                       )
-               );
-       }
-
-       /**
-        * Ensure that get* methods properly match the appropriate getComponent( key ) value
-        * @dataProvider dataUris
-        */
-       function testGetters( $uri ) {
-               $uri = new Uri( $uri );
-               $getterMap = array(
-                       'getProtocol' => 'scheme',
-                       'getUser' => 'user',
-                       'getPassword' => 'pass',
-                       'getHost' => 'host',
-                       'getPort' => 'port',
-                       'getPath' => 'path',
-                       'getQueryString' => 'query',
-                       'getFragment' => 'fragment',
-               );
-               foreach ( $getterMap as $fn => $c ) {
-                       $this->assertSame( $uri->{$fn}(), $uri->getComponent( $c ), "\$uri->{$fn}(); matches \$uri->getComponent( '$c' );" );
-               }
-       }
-
-       /**
-        * Ensure that Uri has the proper components for our example uris
-        * @dataProvider dataUris
-        */
-       function testComponents( $uri, $components ) {
-               $uri = new Uri( $uri );
-
-               $this->assertSame( $components['scheme'], $uri->getProtocol(), 'Correct scheme' );
-               $this->assertSame( $components['delimiter'], $uri->getDelimiter(), 'Correct delimiter' );
-               $this->assertSame( $components['user'], $uri->getUser(), 'Correct user' );
-               $this->assertSame( $components['pass'], $uri->getPassword(), 'Correct pass' );
-               $this->assertSame( $components['host'], $uri->getHost(), 'Correct host' );
-               $this->assertSame( $components['port'], $uri->getPort(), 'Correct port' );
-               $this->assertSame( $components['path'], $uri->getPath(), 'Correct path' );
-               $this->assertSame( $components['query'], $uri->getQueryString(), 'Correct query' );
-               $this->assertSame( $components['fragment'], $uri->getFragment(), 'Correct fragment' );
-       }
-
-       /**
-        * Ensure that the aliases work for various components.
-        */
-       function testAliases() {
-               $url = "//myuser@test.com";
-               $uri = new Uri( $url );
-
-               // Set the aliases.
-               $uri->setComponent( 'protocol', 'https' );
-               $uri->setComponent( 'password', 'mypass' );
-
-               // Now try getting them.
-               $this->assertSame( 'https', $uri->getComponent( 'protocol' ), 'Correct protocol (alias for scheme)' );
-               $this->assertSame( 'mypass', $uri->getComponent( 'password' ), 'Correct password (alias for pass)' );
-
-               // Finally check their actual names.
-               $this->assertSame( 'https', $uri->getProtocol(), 'Alias for scheme works' );
-               $this->assertSame( 'mypass', $uri->getPassword(), 'Alias for pass works' );
-       }
-
-       /**
-        * Ensure that Uri's helper methods return the correct data
-        */
-       function testHelpers() {
-               $uri = new Uri( 'http://a:b@example.com:8080/path?query=value' );
-
-               $this->assertSame( 'a:b', $uri->getUserInfo(), 'Correct getUserInfo' );
-               $this->assertSame( 'example.com:8080', $uri->getHostPort(), 'Correct getHostPort' );
-               $this->assertSame( 'a:b@example.com:8080', $uri->getAuthority(), 'Correct getAuthority' );
-               $this->assertSame( '/path?query=value', $uri->getRelativePath(), 'Correct getRelativePath' );
-               $this->assertSame( 'http://a:b@example.com:8080/path?query=value', $uri->toString(), 'Correct toString' );
-       }
-
-       /**
-        * Ensure that Uri's extend method properly overrides keys
-        */
-       function testExtend() {
-               $uri = new Uri( 'http://example.org/?a=b&hello=world' );
-               $uri->extendQuery( 'a=c&foo=bar' );
-               $this->assertSame( 'a=c&hello=world&foo=bar', $uri->getQueryString() );
-       }
-}
index d56e632..0df5a46 100644 (file)
@@ -16,9 +16,9 @@ class DatabaseSQLTest extends MediaWikiTestCase {
        }
 
        /**
-        * @dataProvider dataSQL
+        * @dataProvider dataSelectSQLText
         */
-       function testSQL( $sql, $sqlText ) {
+       function testSelectSQLText( $sql, $sqlText ) {
                $this->assertEquals( trim( $this->db->selectSQLText(
                        isset( $sql['tables'] ) ? $sql['tables'] : array(),
                        isset( $sql['fields'] ) ? $sql['fields'] : array(),
@@ -29,7 +29,7 @@ class DatabaseSQLTest extends MediaWikiTestCase {
                ) ), $sqlText );
        }
 
-       function dataSQL() {
+       function dataSelectSQLText() {
                return array(
                        array(
                                array(
@@ -72,4 +72,36 @@ class DatabaseSQLTest extends MediaWikiTestCase {
                        ),
                );
        }
+
+       /**
+        * @dataProvider dataConditional
+        */
+       function testConditional( $sql, $sqlText ) {
+               $this->assertEquals( trim( $this->db->conditional(
+                       $sql['conds'],
+                       $sql['true'],
+                       $sql['false']
+               ) ), $sqlText );
+       }
+
+       function dataConditional() {
+               return array(
+                       array(
+                               array(
+                                       'conds' => array( 'field' => 'text' ),
+                                       'true' => 1,
+                                       'false' => 'NULL',
+                               ),
+                               "(CASE WHEN field = 'text' THEN 1 ELSE NULL END)"
+                       ),
+                       array(
+                               array(
+                                       'conds' => 'field=1',
+                                       'true' => 1,
+                                       'false' => 'NULL',
+                               ),
+                               "(CASE WHEN field=1 THEN 1 ELSE NULL END)"
+                       ),
+               );
+       }
 }
\ No newline at end of file
index bf5b379..8bca4b0 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 30 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
@@ -99,4 +99,4 @@ class MediaWikiButtonsAvailabilityTestCase extends MediaWikiInstallationCommonFu
         $this->assertTrue( $this->isElementPresent( "submit-back" ));
         $this->assertTrue( $this->isElementPresent( "submit-continue" ));
     }
-}
\ No newline at end of file
+}
index 9e60391..353fa2e 100644 (file)
@@ -28,8 +28,8 @@
 
 require_once 'PHPUnit/Extensions/SeleniumTestCase.php';
 require_once ( __DIR__ . '/MediaWikiInstallationConfig.php' );
-require_once ( dirname(__FILE__) . '/MediaWikiInstallationMessage.php' );
-require_once ( dirname(__FILE__) . '/MediaWikiInstallationVariables.php');
+require_once ( __DIR__ . '/MediaWikiInstallationMessage.php' );
+require_once ( __DIR__ . '/MediaWikiInstallationVariables.php');
 
 
 class MediaWikiInstallationCommonFunction extends PHPUnit_Extensions_SeleniumTestCase {
index 399ed4e..16d065c 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 01 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
index f57c1a5..4ca6916 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 06 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
index 4c05266..7a1b615 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 
 /**
index b9ca830..ea87de0 100644 (file)
@@ -29,7 +29,7 @@
 
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 11, 12 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
index 700172c..7b0fcf3 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 14, 15, 16, 17 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
index eb82071..5cdc8d4 100644 (file)
@@ -28,7 +28,7 @@
  */
 
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 05 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
@@ -114,4 +114,4 @@ class MediaWikiUpgradeExistingDatabaseTestCase extends MediaWikiInstallationComm
         $this->chooseCancelOnNextConfirmation();
         parent::restartInstallation();
     }
-}
\ No newline at end of file
+}
index 0994892..15fad95 100644 (file)
@@ -27,7 +27,7 @@
  *
  */
 
-require_once (dirname(__FILE__).'/'.'MediaWikiInstallationCommonFunction.php');
+require_once (__DIR__.'/'.'MediaWikiInstallationCommonFunction.php');
 
 /**
  * Test Case ID   : 18 - 27 (http://www.mediawiki.org/wiki/New_installer/Test_plan)
index d4c6165..8307b48 100644 (file)
--- a/thumb.php
+++ b/thumb.php
@@ -71,9 +71,10 @@ function wfThumbHandle404() {
        }
        # Just get the URI path (REDIRECT_URL/REQUEST_URI is either a full URL or a path)
        if ( substr( $uriPath, 0, 1 ) !== '/' ) {
-               $uri = new Uri( $uriPath );
-               $uriPath = $uri->getPath();
-               if ( $uriPath === null ) {
+               $bits = wfParseUrl( $uriPath );
+               if ( $bits && isset( $bits['path'] ) ) {
+                       $uriPath = $bits['path'];
+               } else {
                        wfThumbError( 404, 'The source file for the specified thumbnail does not exist.' );
                        return;
                }