From: jenkins-bot Date: Tue, 24 Sep 2019 00:56:30 +0000 (+0000) Subject: Merge "resourceloader: Reduce severity of unknown page module warning" X-Git-Tag: 1.34.0-rc.0~114 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=4f26aee5de1af360777bd516126f3af8d272d133;hp=6e117a95316aacb98e5268d2c1682e16e9fc9019 Merge "resourceloader: Reduce severity of unknown page module warning" --- diff --git a/autoload.php b/autoload.php index 7ff29ce803..55e5a7f089 100644 --- a/autoload.php +++ b/autoload.php @@ -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 index 0000000000..804f1b9bdb --- /dev/null +++ b/includes/htmlform/CollapsibleFieldsetLayout.php @@ -0,0 +1,29 @@ +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', + ] ); + } +} diff --git a/includes/htmlform/OOUIHTMLForm.php b/includes/htmlform/OOUIHTMLForm.php index baafa5e721..94ba75eb0f 100644 --- a/includes/htmlform/OOUIHTMLForm.php +++ b/includes/htmlform/OOUIHTMLForm.php @@ -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 ) diff --git a/includes/http/HttpRequestFactory.php b/includes/http/HttpRequestFactory.php index 510d26d2bd..5315cede41 100644 --- a/includes/http/HttpRequestFactory.php +++ b/includes/http/HttpRequestFactory.php @@ -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 diff --git a/includes/http/MWHttpRequest.php b/includes/http/MWHttpRequest.php index d1c14aebba..0f3096ef96 100644 --- a/includes/http/MWHttpRequest.php +++ b/includes/http/MWHttpRequest.php @@ -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 diff --git a/includes/site/MediaWikiSite.php b/includes/site/MediaWikiSite.php index 3e2a9a2b40..aa7a6d6caf 100644 --- a/includes/site/MediaWikiSite.php +++ b/includes/site/MediaWikiSite.php @@ -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 ) { diff --git a/includes/site/Site.php b/includes/site/Site.php index 10711a6fbb..401f6e4829 100644 --- a/includes/site/Site.php +++ b/includes/site/Site.php @@ -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 ) { diff --git a/maintenance/migrateArchiveText.php b/maintenance/migrateArchiveText.php index 2271c393a8..7bbf3d0905 100644 --- a/maintenance/migrateArchiveText.php +++ b/maintenance/migrateArchiveText.php @@ -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 ); diff --git a/resources/src/jquery/jquery.makeCollapsible.styles.less b/resources/src/jquery/jquery.makeCollapsible.styles.less index ac896160a5..23e86f7c78 100644 --- a/resources/src/jquery/jquery.makeCollapsible.styles.less +++ b/resources/src/jquery/jquery.makeCollapsible.styles.less @@ -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, diff --git a/resources/src/mediawiki.htmlform.ooui.styles.less b/resources/src/mediawiki.htmlform.ooui.styles.less index 470d826446..22dc924b22 100644 --- a/resources/src/mediawiki.htmlform.ooui.styles.less +++ b/resources/src/mediawiki.htmlform.ooui.styles.less @@ -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; @@ -15,15 +16,26 @@ // 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 { @@ -113,3 +125,35 @@ .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; + } + } +}