Merge "rdbms: Avoid declaration incompatibility IDEA warnings in safeWaitForMasterPos()"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 7 Feb 2017 18:48:13 +0000 (18:48 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 7 Feb 2017 18:48:13 +0000 (18:48 +0000)
12 files changed:
autoload.php
includes/LinkFilter.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/IDatabase.php
includes/libs/rdbms/encasing/LikeMatch.php
includes/specials/SpecialJavaScriptTest.php
includes/specials/pagers/ContribsPager.php
includes/widget/search/InterwikiSearchResultSetWidget.php
includes/widget/search/SimpleSearchResultSetWidget.php
tests/phpunit/autoload.ide.php [new file with mode: 0644]
tests/phpunit/includes/LinkFilterTest.php
tests/phpunit/includes/db/DatabaseSQLTest.php

index 970dff0..4a97e7c 100644 (file)
@@ -727,7 +727,6 @@ $wgAutoloadLocalClasses = [
        'LegacyLogFormatter' => __DIR__ . '/includes/logging/LogFormatter.php',
        'License' => __DIR__ . '/includes/Licenses.php',
        'Licenses' => __DIR__ . '/includes/Licenses.php',
-       'LikeMatch' => __DIR__ . '/includes/libs/rdbms/encasing/LikeMatch.php',
        'LinkBatch' => __DIR__ . '/includes/cache/LinkBatch.php',
        'LinkCache' => __DIR__ . '/includes/cache/LinkCache.php',
        'LinkFilter' => __DIR__ . '/includes/LinkFilter.php',
@@ -1593,6 +1592,7 @@ $wgAutoloadLocalClasses = [
        'Wikimedia\\Rdbms\\LBFactoryMulti' => __DIR__ . '/includes/libs/rdbms/lbfactory/LBFactoryMulti.php',
        'Wikimedia\\Rdbms\\LBFactorySimple' => __DIR__ . '/includes/libs/rdbms/lbfactory/LBFactorySimple.php',
        'Wikimedia\\Rdbms\\LBFactorySingle' => __DIR__ . '/includes/libs/rdbms/lbfactory/LBFactorySingle.php',
+       'Wikimedia\\Rdbms\\LikeMatch' => __DIR__ . '/includes/libs/rdbms/encasing/LikeMatch.php',
        'Wikimedia\\Rdbms\\LoadMonitor' => __DIR__ . '/includes/libs/rdbms/loadmonitor/LoadMonitor.php',
        'Wikimedia\\Rdbms\\LoadMonitorMySQL' => __DIR__ . '/includes/libs/rdbms/loadmonitor/LoadMonitorMySQL.php',
        'Wikimedia\\Rdbms\\LoadMonitorNull' => __DIR__ . '/includes/libs/rdbms/loadmonitor/LoadMonitorNull.php',
index 7b3d72b..2f50558 100644 (file)
@@ -19,6 +19,7 @@
  *
  * @file
  */
+use Wikimedia\Rdbms\LikeMatch;
 
 /**
  * Some functions to help implement an external link filter for spam control.
index d15d6f1..17c9fda 100644 (file)
@@ -27,6 +27,7 @@ use Psr\Log\LoggerAwareInterface;
 use Psr\Log\LoggerInterface;
 use Wikimedia\ScopedCallback;
 use Wikimedia\Rdbms\TransactionProfiler;
+use Wikimedia\Rdbms\LikeMatch;
 
 /**
  * Relational database abstraction object
index c6055db..f1613eb 100644 (file)
@@ -24,6 +24,7 @@
  * @ingroup Database
  */
 use Wikimedia\ScopedCallback;
+use Wikimedia\Rdbms\LikeMatch;
 
 /**
  * Basic database interface for live and lazy-loaded relation database handles
index b0b3c87..98812a5 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+
+namespace Wikimedia\Rdbms;
+
 /**
  * Used by Database::buildLike() to represent characters that have special
  * meaning in SQL LIKE clauses and thus need no escaping. Don't instantiate it
index 0e2e7db..dc6a619 100644 (file)
@@ -137,7 +137,9 @@ class SpecialJavaScriptTest extends SpecialPage {
                $code .= '(function () {'
                        . 'var start = window.__karma__ ? window.__karma__.start : QUnit.start;'
                        . 'try {'
-                       . 'mw.loader.using( ' . Xml::encodeJsVar( $modules ) . ' ).always( start );'
+                       . 'mw.loader.using( ' . Xml::encodeJsVar( $modules ) . ' )'
+                       . '.always( start )'
+                       . '.fail( function ( e ) { throw e; } );'
                        . '} catch ( e ) { start(); throw e; }'
                        . '}());';
 
index 0c3a211..47a2aed 100644 (file)
@@ -402,7 +402,7 @@ class ContribsPager extends ReverseChronologicalPager {
                                $difftext = $linkRenderer->makeKnownLink(
                                        $page,
                                        new HtmlArmor( $this->messages['diff'] ),
-                                       [],
+                                       [ 'class' => 'mw-changeslist-diff' ],
                                        [
                                                'diff' => 'prev',
                                                'oldid' => $row->rev_id
@@ -414,7 +414,7 @@ class ContribsPager extends ReverseChronologicalPager {
                        $histlink = $linkRenderer->makeKnownLink(
                                $page,
                                new HtmlArmor( $this->messages['hist'] ),
-                               [],
+                               [ 'class' => 'mw-changeslist-history' ],
                                [ 'action' => 'history' ]
                        );
 
index af1ed05..76b9b01 100644 (file)
@@ -109,7 +109,7 @@ class InterwikiSearchResultSetWidget implements SearchResultSetWidget {
                        Html::rawElement(
                                'p',
                                [ 'class' => 'iw-headline' ],
-                               $this->specialSearch->msg( 'search-interwiki-caption' )->escaped()
+                               $this->specialSearch->msg( 'search-interwiki-caption' )->parse()
                        ) .
                        Html::rawElement(
                                'ul', [ 'class' => 'iw-results', ], $iwResultListOutput
index 49ebc4e..04e1e21 100644 (file)
@@ -77,7 +77,7 @@ class SimpleSearchResultSetWidget implements SearchResultSetWidget{
                return
                        "<div id='mw-search-interwiki'>" .
                                "<div id='mw-search-interwiki-caption'>" .
-                                       $this->specialSearch->msg( 'search-interwiki-caption' )->escaped() .
+                                       $this->specialSearch->msg( 'search-interwiki-caption' )->parse() .
                                '</div>' .
                                $out .
                        "</div>";
diff --git a/tests/phpunit/autoload.ide.php b/tests/phpunit/autoload.ide.php
new file mode 100644 (file)
index 0000000..074fab0
--- /dev/null
@@ -0,0 +1,109 @@
+<?php
+
+/**
+ * This file is PHPUnit autoload file for PhpStorm IDE and other JetBrains IDEs.
+ *
+ * This file should be set in `Languages and frameworks > PHP > PhpUnit`
+ * select `Use Composer autoloader` and set `Path to script` to `<path to this file>`.
+ * After that, tests can be run in PhpStorm using Right-click > Run or `Ctrl + Shift + F10`.
+ * Also, tests can be run with debugger very easily.
+ *
+ * This file basically does almost the same thing as `tests/phpunit/phpunit.php`, except that all
+ * code is going to be executed inside some function, so some hacks needed to make old code to be
+ * executed as if it was executed on top of the execution stack.
+ *
+ * PS: Mostly it is copy-paste from `phpunit.php` and `doMaintenance.php`.
+ *
+ * @file
+ */
+
+// Set a flag which can be used to detect when other scripts have been entered
+// through this entry point or not.
+use MediaWiki\MediaWikiServices;
+
+global $argv;
+$argv[1] = '--wiki';
+$argv[2] = getenv( 'WIKI_NAME' ) ?: 'wiki';
+
+require_once __DIR__ . "/phpunit.php";
+
+// Get an object to start us off
+/** @var Maintenance $maintenance */
+$maintenance = new PHPUnitMaintClass();
+
+// Basic sanity checks and such
+$maintenance->setup();
+
+// We used to call this variable $self, but it was moved
+// to $maintenance->mSelf. Keep that here for b/c
+$self = $maintenance->getName();
+global $IP;
+# Start the autoloader, so that extensions can derive classes from core files
+require_once "$IP/includes/AutoLoader.php";
+# Grab profiling functions
+require_once "$IP/includes/profiler/ProfilerFunctions.php";
+
+# Start the profiler
+$wgProfiler = [];
+if ( file_exists( "$IP/StartProfiler.php" ) ) {
+       require "$IP/StartProfiler.php";
+}
+
+$requireOnceGlobalsScope = function ( $file ) use ( $self ) {
+       foreach ( array_keys( $GLOBALS ) as $varName ) {
+               eval( sprintf( 'global $%s;', $varName ) );
+       }
+
+       require_once $file;
+
+       unset( $file );
+       $definedVars = get_defined_vars();
+       foreach ( $definedVars as $varName => $value ) {
+               eval( sprintf( 'global $%s; $%s = $value;', $varName, $varName ) );
+       }
+};
+
+// Some other requires
+$requireOnceGlobalsScope( "$IP/includes/Defines.php" );
+$requireOnceGlobalsScope( "$IP/includes/DefaultSettings.php" );
+$requireOnceGlobalsScope( "$IP/includes/GlobalFunctions.php" );
+
+foreach ( array_keys( $GLOBALS ) as $varName ) {
+       eval( sprintf( 'global $%s;', $varName ) );
+}
+
+# Load composer's autoloader if present
+if ( is_readable( "$IP/vendor/autoload.php" ) ) {
+       require_once "$IP/vendor/autoload.php";
+}
+
+if ( defined( 'MW_CONFIG_CALLBACK' ) ) {
+       # Use a callback function to configure MediaWiki
+       call_user_func( MW_CONFIG_CALLBACK );
+} else {
+       // Require the configuration (probably LocalSettings.php)
+       require $maintenance->loadSettings();
+}
+
+if ( $maintenance->getDbType() === Maintenance::DB_NONE ) {
+       if ( $wgLocalisationCacheConf['storeClass'] === false
+                && ( $wgLocalisationCacheConf['store'] == 'db'
+                         || ( $wgLocalisationCacheConf['store'] == 'detect' && !$wgCacheDirectory ) )
+       ) {
+               $wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';
+       }
+}
+
+$maintenance->finalSetup();
+// Some last includes
+$requireOnceGlobalsScope( "$IP/includes/Setup.php" );
+
+// Initialize main config instance
+$maintenance->setConfig( MediaWikiServices::getInstance()->getMainConfig() );
+
+// Sanity-check required extensions are installed
+$maintenance->checkRequiredExtensions();
+
+// A good time when no DBs have writes pending is around lag checks.
+// This avoids having long running scripts just OOM and lose all the updates.
+$maintenance->setAgentAndTriggers();
index 428b012..ed4958f 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\LikeMatch;
+
 /**
  * @group Database
  */
index 656e661..57754bc 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Wikimedia\Rdbms\LikeMatch;
+
 /**
  * Test the abstract database layer
  * This is a non DBMS depending test.