Merge "resourceloader: Remove redundant closure of some startup and base files"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 24 Sep 2019 00:56:22 +0000 (00:56 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 24 Sep 2019 00:56:22 +0000 (00:56 +0000)
autoload.php
includes/htmlform/CollapsibleFieldsetLayout.php [new file with mode: 0644]
includes/htmlform/OOUIHTMLForm.php
includes/http/HttpRequestFactory.php
includes/http/MWHttpRequest.php
includes/site/MediaWikiSite.php
includes/site/Site.php
maintenance/migrateArchiveText.php
resources/src/jquery/jquery.makeCollapsible.styles.less
resources/src/mediawiki.htmlform.ooui.styles.less

index 7ff29ce..55e5a7f 100644 (file)
@@ -285,6 +285,7 @@ $wgAutoloadLocalClasses = [
        'CloneDatabase' => __DIR__ . '/includes/db/CloneDatabase.php',
        'CodeCleanerGlobalsPass' => __DIR__ . '/maintenance/CodeCleanerGlobalsPass.inc',
        'CodeContentHandler' => __DIR__ . '/includes/content/CodeContentHandler.php',
+       'CollapsibleFieldsetLayout' => __DIR__ . '/includes/htmlform/CollapsibleFieldsetLayout.php',
        'Collation' => __DIR__ . '/includes/collation/Collation.php',
        'CollationCkb' => __DIR__ . '/includes/collation/CollationCkb.php',
        'CommandLineInc' => __DIR__ . '/maintenance/commandLine.inc',
diff --git a/includes/htmlform/CollapsibleFieldsetLayout.php b/includes/htmlform/CollapsibleFieldsetLayout.php
new file mode 100644 (file)
index 0000000..804f1b9
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+
+class CollapsibleFieldsetLayout extends OOUI\FieldsetLayout {
+       public function __construct( array $config = [] ) {
+               parent::__construct( $config );
+
+               $this->addClasses( [ 'mw-collapsible' ] );
+               if ( isset( $config[ 'collapsed' ] ) && $config[ 'collapsed' ] ) {
+                       $this->addClasses( [ 'mw-collapsed' ] );
+               }
+               $this->header->addClasses( [ 'mw-collapsible-toggle' ] );
+               $this->group->addClasses( [ 'mw-collapsible-content' ] );
+
+               $this->header->appendContent(
+                       new OOUI\IconWidget( [
+                               'icon' => 'expand',
+                               'label' => wfMessage( 'collapsible-expand' )->text(),
+                       ] ),
+                       new OOUI\IconWidget( [
+                               'icon' => 'collapse',
+                               'label' => wfMessage( 'collapsible-collapse' )->text(),
+                       ] )
+               );
+
+               $this->header->setAttributes( [
+                       'role' => 'button',
+               ] );
+       }
+}
index baafa5e..94ba75e 100644 (file)
@@ -281,17 +281,10 @@ class OOUIHTMLForm extends HTMLForm {
 
        public function wrapForm( $html ) {
                if ( is_string( $this->mWrapperLegend ) ) {
-                       $classes = $this->mCollapsible ? [ 'mw-collapsible' ] : [];
-                       if ( $this->mCollapsed ) {
-                               $classes[] = 'mw-collapsed';
-                       }
-                       $content = new OOUI\FieldsetLayout( [
+                       $phpClass = $this->mCollapsible ? CollapsibleFieldsetLayout::class : OOUI\FieldsetLayout::class;
+                       $content = new $phpClass( [
                                'label' => $this->mWrapperLegend,
-                               'classes' => $classes,
-                               'group' => new OOUI\StackLayout( [
-                                       'expanded' => false,
-                                       'classes' => [ 'mw-collapsible-content' ],
-                               ] ),
+                               'collapsed' => $this->mCollapsed,
                                'items' => [
                                        new OOUI\Widget( [
                                                'content' => new OOUI\HtmlSnippet( $html )
index 510d26d..5315ced 100644 (file)
@@ -37,8 +37,8 @@ class HttpRequestFactory {
         * Generate a new MWHttpRequest object
         * @param string $url Url to use
         * @param array $options Possible keys for the array:
-        *    - timeout             Timeout length in seconds
-        *    - connectTimeout      Timeout for connection, in seconds (curl only)
+        *    - timeout             Timeout length in seconds or 'default'
+        *    - connectTimeout      Timeout for connection, in seconds (curl only) or 'default'
         *    - postData            An array of key-value pairs or a url-encoded form data
         *    - proxy               The proxy to use.
         *                          Otherwise it will use $wgHTTPProxy (if set)
@@ -59,7 +59,7 @@ class HttpRequestFactory {
         *    - originalRequest     Information about the original request (as a WebRequest object or
         *                          an associative array with 'ip' and 'userAgent').
         * @codingStandardsIgnoreStart
-        * @phan-param array{timeout?:int,connectTimeout?:int,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,method?:string,logger?:\Psr\Log\LoggerInterface,username?:string,password?:string,originalRequest?:WebRequest|array{ip:string,userAgent:string}} $options
+        * @phan-param array{timeout?:int|string,connectTimeout?:int|string,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,method?:string,logger?:\Psr\Log\LoggerInterface,username?:string,password?:string,originalRequest?:WebRequest|array{ip:string,userAgent:string}} $options
         * @codingStandardsIgnoreEnd
         * @param string $caller The method making this request, for profiling
         * @throws RuntimeException
index d1c14ae..0f3096e 100644 (file)
@@ -89,7 +89,7 @@ abstract class MWHttpRequest implements LoggerAwareInterface {
         * @param string $url Url to use. If protocol-relative, will be expanded to an http:// URL
         * @param array $options (optional) extra params to pass (see HttpRequestFactory::create())
         * @codingStandardsIgnoreStart
-        * @phan-param array{timeout?:int,connectTimeout?:int,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,logger?:LoggerInterface,username?:string,password?:string,originalRequest?:WebRequest|array{ip:string,userAgent:string},method?:string} $options
+        * @phan-param array{timeout?:int|string,connectTimeout?:int|string,postData?:array,proxy?:string,noProxy?:bool,sslVerifyHost?:bool,sslVerifyCert?:bool,caInfo?:string,maxRedirects?:int,followRedirects?:bool,userAgent?:string,logger?:LoggerInterface,username?:string,password?:string,originalRequest?:WebRequest|array{ip:string,userAgent:string},method?:string} $options
         * @codingStandardsIgnoreEnd
         * @param string $caller The method making this request, for profiling
         * @param Profiler|null $profiler An instance of the profiler for profiling, or null
index 3e2a9a2..aa7a6d6 100644 (file)
@@ -176,13 +176,13 @@ class MediaWikiSite extends Site {
         *
         * @param string|bool $pageName Page name or false (default: false)
         *
-        * @return string|bool|null
+        * @return string|null
         */
        public function getPageUrl( $pageName = false ) {
                $url = $this->getLinkPath();
 
-               if ( $url === false ) {
-                       return false;
+               if ( $url === null ) {
+                       return null;
                }
 
                if ( $pageName !== false ) {
index 10711a6..401f6e4 100644 (file)
@@ -354,7 +354,7 @@ class Site implements Serializable {
 
        /**
         * Returns the full URL for the given page on the site.
-        * Or false if the needed information is not known.
+        * Or null if the needed information is not known.
         *
         * This generated URL is usually based upon the path returned by getLinkPath(),
         * but this is not a requirement.
@@ -365,13 +365,13 @@ class Site implements Serializable {
         *
         * @param bool|string $pageName
         *
-        * @return string|bool|null
+        * @return string|null
         */
        public function getPageUrl( $pageName = false ) {
                $url = $this->getLinkPath();
 
-               if ( $url === false ) {
-                       return false;
+               if ( $url === null ) {
+                       return null;
                }
 
                if ( $pageName !== false ) {
index 2271c39..7bbf3d0 100644 (file)
@@ -21,6 +21,8 @@
  * @ingroup Maintenance
  */
 
+use MediaWiki\MediaWikiServices;
+
 require_once __DIR__ . '/Maintenance.php';
 
 /**
@@ -57,6 +59,10 @@ class MigrateArchiveText extends LoggedUpdateMaintenance {
        protected function doDBUpdates() {
                $replaceMissing = $this->hasOption( 'replace-missing' );
                $defaultExternalStore = $this->getConfig()->get( 'DefaultExternalStore' );
+               // @phan-suppress-next-line PhanAccessMethodInternal
+               $blobStore = MediaWikiServices::getInstance()
+                       ->getBlobStoreFactory()
+                       ->newSqlBlobStore();
                $batchSize = $this->getBatchSize();
 
                $dbr = $this->getDB( DB_REPLICA, [ 'vslow' ] );
@@ -90,8 +96,9 @@ class MigrateArchiveText extends LoggedUpdateMaintenance {
 
                                // Recompress the text (and store in external storage, if
                                // applicable) if it's not already in external storage.
-                               if ( !in_array( 'external', explode( ',', $row->ar_flags ), true ) ) {
-                                       $data = Revision::getRevisionText( $row, 'ar_' );
+                               $arFlags = explode( ',', $row->ar_flags );
+                               if ( !in_array( 'external', $arFlags, true ) ) {
+                                       $data = $blobStore->decompressData( $row->ar_text, $arFlags );
                                        if ( $data !== false ) {
                                                $flags = Revision::compressRevisionText( $data );
 
index ac89616..23e86f7 100644 (file)
@@ -125,12 +125,6 @@ li,
        }
 }
 
-fieldset.mw-collapsible .mw-collapsible-toggle {
-       position: absolute;
-       right: 0;
-       z-index: 1;
-}
-
 // special treatment for list items to match above
 // !important necessary to override overly-specific float left and right above.
 ol.mw-collapsible:not( @{exclude} ):before,
index 470d826..22dc924 100644 (file)
@@ -6,6 +6,7 @@
 @ooui-font-size-browser: 16; // assumed browser default of `16px`
 @ooui-font-size-base: 0.875em; // equals `14px` at browser default of `16px`
 
+@ooui-spacing-small: 8 / @ooui-font-size-browser / @ooui-font-size-base; // equals `0.57142857em`≈`8px`
 @ooui-spacing-medium: 12 / @ooui-font-size-browser / @ooui-font-size-base; // equals `0.8571429em`≈`12px`
 @ooui-spacing-large: 16 / @ooui-font-size-browser / @ooui-font-size-base; // equals `1.1428571em`≈`16px`
 @ooui-padding-horizontal: 12 / @ooui-font-size-browser / @ooui-font-size-base;
        // Reducing `padding-top`, as the heading's `line-height` provides similar distance.
        padding: @ooui-spacing-medium @ooui-spacing-large @ooui-spacing-large;
 
-       // Trigger only when collapsible & JS is available via `.mw-collapsed`.
-       .client-js & .oo-ui-fieldsetLayout.mw-collapsed .oo-ui-fieldsetLayout-header {
-               // Negative margin to match the reduced distance on the top caused by the previous rule.
-               margin-bottom: -( @ooui-spacing-large - @ooui-spacing-medium );
+       .client-js & .oo-ui-fieldsetLayout.mw-collapsible .oo-ui-fieldsetLayout-header {
+               // Push legend up when JS is on, to increase clickable area.
+               margin-top: -@ooui-spacing-small;
+               margin-bottom: @ooui-spacing-small;
+               // Add `padding-top` to make up for negative `margin` above.
+               padding: @ooui-spacing-small;
+               // Make space for toggle icon defined below.
+               padding-left: 24 / @ooui-font-size-browser / @ooui-font-size-base;
 
                .oo-ui-labelElement-label {
                        margin-bottom: 0;
                }
        }
+
+       // Trigger only when collapsible & JS is available via `.mw-collapsed`.
+       .client-js & .oo-ui-fieldsetLayout.mw-collapsed .oo-ui-fieldsetLayout-header {
+               min-height: 30px;
+               // Negative margin to match the reduced distance on the top caused by the previous rule.
+               margin-bottom: -@ooui-spacing-medium;
+       }
 }
 
 .mw-htmlform-ooui {
 .mw-htmlform-ooui .mw-htmlform-submit-buttons {
        margin-top: @ooui-spacing-medium;
 }
+
+.oo-ui-fieldsetLayout.mw-collapsible {
+       .oo-ui-fieldsetLayout-header {
+               max-width: none;
+       }
+
+       .mw-collapsible-toggle .oo-ui-iconElement-icon {
+               position: absolute;
+               top: 0;
+               left: 0;
+               // Special case: Reduce to `16px` icon size here.
+               min-width: 16px;
+               width: 16 / @ooui-font-size-browser / @ooui-font-size-base;
+               margin-right: 0.5em;
+       }
+
+       // When expanded: only 'collapse' icon visible
+       .mw-collapsible-toggle .oo-ui-icon-expand {
+               display: none;
+       }
+
+       // When collapsed: only 'expand' icon visible
+       &.mw-collapsed {
+               .mw-collapsible-toggle .oo-ui-icon-expand {
+                       display: inline-block;
+               }
+
+               .mw-collapsible-toggle .oo-ui-icon-collapse {
+                       display: none;
+               }
+       }
+}