Merge "Fix rendering of centered caption-less images"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Mon, 23 Jun 2014 19:32:27 +0000 (19:32 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Mon, 23 Jun 2014 19:32:27 +0000 (19:32 +0000)
13 files changed:
RELEASE-NOTES-1.24
includes/config/GlobalVarConfig.php
includes/context/DerivativeContext.php
includes/context/RequestContext.php
includes/deferred/SearchUpdate.php
includes/search/SearchDatabase.php
includes/search/SearchEngine.php
includes/specialpage/SpecialPage.php
includes/specials/SpecialMIMEsearch.php
maintenance/archives/patch-uploadstash.sql
maintenance/mssql/tables.sql
maintenance/tables.sql
tests/phpunit/includes/specials/SpecialMIMESearchTest.php [new file with mode: 0644]

index 4f0ae21..42deed7 100644 (file)
@@ -170,6 +170,7 @@ changes to languages because of Bugzilla reports.
 * ResourceLoaderFileModule#getAllStyleFiles now returns all style files and all
   skin style files used by the module.
 * Removed getLang() from IContextSource and subclasses. (deprecated since 1.19)
+* Removed setLang() from subclasses of IContextSource. (deprecated since 1.19)
 * Removed WebRequest::escapeAppendQuery(). (deprecated since 1.20)
 * Removed info(), purge(), revert() and rollback() from the Article class; they
   have since become subclasses of the Action class. (deprecated since 1.19)
index 61a76b7..0d7f3f0 100644 (file)
@@ -69,7 +69,7 @@ class GlobalVarConfig implements Config {
         */
        protected function getWithPrefix( $prefix, $name ) {
                $var = $prefix . $name;
-               if ( !isset( $GLOBALS[ $var ] ) ) {
+               if ( !array_key_exists( $var, $GLOBALS ) ) {
                        throw new ConfigException( __METHOD__ . ": undefined variable: '$var'" );
                }
                return $GLOBALS[ $var ];
index edf9e1d..f550e9e 100644 (file)
@@ -237,17 +237,6 @@ class DerivativeContext extends ContextSource {
                }
        }
 
-       /**
-        * Set the Language object
-        *
-        * @deprecated since 1.19 Use setLanguage instead
-        * @param Language|string $l Language instance or language code
-        */
-       public function setLang( $l ) {
-               wfDeprecated( __METHOD__, '1.19' );
-               $this->setLanguage( $l );
-       }
-
        /**
         * Set the Language object
         *
index 1754a9d..cb137fe 100644 (file)
@@ -268,17 +268,6 @@ class RequestContext implements IContextSource {
                return $code;
        }
 
-       /**
-        * Set the Language object
-        *
-        * @deprecated since 1.19 Use setLanguage instead
-        * @param Language|string $l Language instance or language code
-        */
-       public function setLang( $l ) {
-               wfDeprecated( __METHOD__, '1.19' );
-               $this->setLanguage( $l );
-       }
-
        /**
         * Set the Language object
         *
index 9ae9034..20f348a 100644 (file)
@@ -81,10 +81,10 @@ class SearchUpdate implements DeferrableUpdate {
                wfProfileIn( __METHOD__ );
 
                $page = WikiPage::newFromId( $this->id, WikiPage::READ_LATEST );
-               $indexTitle = $this->indexTitle();
 
                foreach ( SearchEngine::getSearchTypes() as $type ) {
                        $search = SearchEngine::create( $type );
+                       $indexTitle = $this->indexTitle( $search );
                        if ( !$search->supports( 'search-update' ) ) {
                                continue;
                        }
@@ -181,13 +181,13 @@ class SearchUpdate implements DeferrableUpdate {
         *
         * @return string A stripped-down title string ready for the search index
         */
-       private function indexTitle() {
+       private function indexTitle( SearchEngine $search ) {
                global $wgContLang;
 
                $ns = $this->title->getNamespace();
                $title = $this->title->getText();
 
-               $lc = SearchEngine::legalSearchChars() . '&#;';
+               $lc = $search->legalSearchChars() . '&#;';
                $t = $wgContLang->normalizeForSearch( $title );
                $t = preg_replace( "/[^{$lc}]+/", ' ', $t );
                $t = $wgContLang->lc( $t );
index e3aafe8..82d0907 100644 (file)
@@ -43,4 +43,15 @@ class SearchDatabase extends SearchEngine {
                        $this->db = wfGetDB( DB_SLAVE );
                }
        }
+
+       /**
+        * Return a 'cleaned up' search string
+        *
+        * @param string $text
+        * @return string
+        */
+       protected function filter( $text ) {
+               $lc = $this->legalSearchChars();
+               return trim( preg_replace( "/[^{$lc}]/", " ", $text ) );
+       }
 }
index 3a3baef..d8c6f6d 100644 (file)
@@ -419,17 +419,6 @@ class SearchEngine {
                return $formatted;
        }
 
-       /**
-        * Return a 'cleaned up' search string
-        *
-        * @param string $text
-        * @return string
-        */
-       function filter( $text ) {
-               $lc = $this->legalSearchChars();
-               return trim( preg_replace( "/[^{$lc}]/", " ", $text ) );
-       }
-
        /**
         * Load up the appropriate search engine class for the currently
         * active database backend, and return a configured instance.
index ec8635c..c062e27 100644 (file)
@@ -131,19 +131,6 @@ class SpecialPage {
                return $this->mRestriction;
        }
 
-       /**
-        * Get the file which will be included by SpecialPage::execute() if your extension is
-        * still stuck in the past and hasn't overridden the execute() method.  No modern code
-        * should want or need to know this.
-        * @return string
-        * @deprecated since 1.18
-        */
-       function getFile() {
-               wfDeprecated( __METHOD__, '1.18' );
-
-               return $this->mFile;
-       }
-
        // @todo FIXME: Decide which syntax to use for this, and stick to it
        /**
         * Whether this special page is listed in Special:SpecialPages
index cb9dac9..4d9e7da 100644 (file)
@@ -85,8 +85,8 @@ class MIMEsearchPage extends QueryPage {
                                        MEDIATYPE_TEXT,
                                        MEDIATYPE_EXECUTABLE,
                                        MEDIATYPE_ARCHIVE,
-                               ) + $minorType,
-                       ),
+                               ),
+                       ) + $minorType,
                );
 
                return $qi;
index 14eaeab..c1d93ef 100644 (file)
@@ -26,10 +26,10 @@ CREATE TABLE /*_*/uploadstash (
 
        us_status varchar(50) not null,
 
-       -- file properties from File::getPropsFromPath.  these may prove unnecessary.
+       -- file properties from FSFile::getProps().  these may prove unnecessary.
        --
        us_size int unsigned NOT NULL,
-       -- this hash comes from File::sha1Base36(), and is 31 characters
+       -- this hash comes from FSFile::getSha1Base36(), and is 31 characters
        us_sha1 varchar(31) NOT NULL,
        us_mime varchar(255),
        -- Media type as defined by the MEDIATYPE_xxx constants, should duplicate definition in the image table
index fb8db08..bccf366 100644 (file)
@@ -736,12 +736,12 @@ CREATE TABLE /*_*/uploadstash (
   -- chunk counter starts at 0, current offset is stored in us_size
   us_chunk_inx int NULL,
 
-  -- Serialized file properties from File::getPropsFromPath
+  -- Serialized file properties from FSFile::getProps()
   us_props nvarchar(max),
 
   -- file size in bytes
   us_size int NOT NULL,
-  -- this hash comes from File::sha1Base36(), and is 31 characters
+  -- this hash comes from FSFile::getSha1Base36(), and is 31 characters
   us_sha1 nvarchar(31) NOT NULL,
   us_mime nvarchar(255),
   -- Media type as defined by the MEDIATYPE_xxx constants, should duplicate definition in the image table
index 67696f2..4f1fbbd 100644 (file)
@@ -1001,12 +1001,12 @@ CREATE TABLE /*_*/uploadstash (
   -- chunk counter starts at 0, current offset is stored in us_size
   us_chunk_inx int unsigned NULL,
 
-  -- Serialized file properties from File::getPropsFromPath
+  -- Serialized file properties from FSFile::getProps()
   us_props blob,
 
   -- file size in bytes
   us_size int unsigned NOT NULL,
-  -- this hash comes from File::sha1Base36(), and is 31 characters
+  -- this hash comes from FSFile::getSha1Base36(), and is 31 characters
   us_sha1 varchar(31) NOT NULL,
   us_mime varchar(255),
   -- Media type as defined by the MEDIATYPE_xxx constants, should duplicate definition in the image table
diff --git a/tests/phpunit/includes/specials/SpecialMIMESearchTest.php b/tests/phpunit/includes/specials/SpecialMIMESearchTest.php
new file mode 100644 (file)
index 0000000..e7bb35c
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+class SpecialMIMESearchTest extends MediaWikiTestCase {
+
+       /** @var MIMESearchPage */
+       private $page;
+
+       function setUp() {
+               $this->page = new MIMESearchPage;
+               $context = new RequestContext();
+               $context->setTitle( Title::makeTitle( NS_SPECIAL, 'MIMESearch' ) );
+               $context->setRequest( new FauxRequest() );
+               $this->page->setContext( $context );
+
+               parent::setUp();
+       }
+
+       /**
+        * @dataProvider providerMimeFiltering
+        * @param $par String subpage for special page
+        * @param $major String Major mime type we expect to look for
+        * @param $minor String Minor mime type we expect to look for
+        */
+       function testMimeFiltering( $par, $major, $minor ) {
+               $this->page->run( $par );
+               $qi = $this->page->getQueryInfo();
+               $this->assertEquals( $qi['conds']['img_major_mime'], $major );
+               if ( $minor !== null ) {
+                       $this->assertEquals( $qi['conds']['img_minor_mime'], $minor );
+               } else {
+                       $this->assertArrayNotHasKey( 'img_minor_mime', $qi['conds'] );
+               }
+               $this->assertContains( 'image', $qi['tables'] );
+       }
+
+       function providerMimeFiltering() {
+               return array(
+                       array( 'image/gif', 'image', 'gif' ),
+                       array( 'image/png', 'image', 'png' ),
+                       array( 'application/pdf', 'application', 'pdf' ),
+                       array( 'image/*', 'image', null ),
+                       array( 'multipart/*', 'multipart', null ),
+               );
+       }
+}