Commit graph

108 commits

Author SHA1 Message Date
Timo Tijhof
b7c70526a9 resourceloader: Add missing Module->setConfig() calls in tests and installer
There is a fallback in Module->getConfig() to the global services
container. This is not meant to be used in practice, but there were
two places where this was missing: WebInstallerOutput, and various
PHPUnit tests.

* Add missing setConfig() to WebInstallerOutput.

* Add missing setConfig() to various tests. Most tests were already
  doing this correctly and using the standard mock from
  ResourceLoaderTestCase. Upon switching the last few tests as well,
  I uncovered various errors due to the mock missing some settings
  that the tested code uses, so these have been added now to
  ResourceLoaderTestCase.

Bug: T277728
Change-Id: I44f16ec4e00423fb6f641e58fffc1d40e4571f01
2021-06-13 21:20:58 +00:00
jdlrobson
046c0b8a9a Installer: Simplify stylesheet
The installer needs a handful of the styles provided by
ResourceLoaderSkinModule. Reduce it to the minimum required in
preparation for the deprecation of the `legacy` feature.

Bug: T232903
Change-Id: I6a718232897448a94fe1ddda547ae5a5c671b7aa
2021-04-20 00:53:13 +00:00
jdlrobson
251405ed02 Installer: The installer should use .warningbox for styling warnings, not .mw-infobox
Bug: T232903
Change-Id: Ibf6426ab90445d7aac94d59336e25957cf48fc1f
2021-04-15 20:55:44 +00:00
jdlrobson
e5f09fd1bb Installer: Do not use mediawiki.skinning.interface module
The `mediawiki.skinning.interface` module includes the `toc` feature
which is enabled by default,
which requires a working localization environment which requires
DBLoadBalancer which is disabled at this entry point.

Instead use ResourceLoaderSkinModule directly with an opt-in
policy where toc feature is not disbled.

This means the definition in Resources.php is no longer
necessary so it is marked for deprecation. The installer
now works.

A unit test is added to make sure the installer stylesheet
doesn't break again.

Bug: T270027
Change-Id: I851fcd0e50e3a70158d5bfa1fdcae3cd278694d6
2021-04-15 11:11:32 -07:00
daniel
f59bf8a22f Use @internal instead of @private per policy
https://www.mediawiki.org/wiki/Stable_interface_policy mandates the use
of @internal. The semantics of @private was never properly defined.

Bug: T247862
Change-Id: I4c7c6e7b5a80e86456965521f88d1dfa7d698f84
2020-06-26 14:14:23 +02:00
Timo Tijhof
9c7dc9e760 installer: Add intro to Welcome page, add Help/Bug/Contribute links
This removes the readme page embedding in the installer.

Bug: T256062
Change-Id: I453a8e691371266634638e81e54ce18e19cb4467
2020-06-22 21:58:43 +01:00
jdlrobson
00e8bde685 installer: Replace Vector dependency in WebInstallerOutput with fallback skin
Rather than hardcode a Vector module, the installer should use the fallback
skin.

This leaves it mostly unstyled, which will be restored in a separate change
that adds a minimal stylesheet for the web installer (see Ibdb0a7208).

Bug: T248133
Change-Id: I5c7f16ec9efda35b94355b6c81ec78d9bdfb574b
2020-04-01 18:17:43 +00:00
jenkins-bot
751fcb315e Merge "resourceloader: Export ResourceModules as extension attribute" 2020-03-30 23:26:29 +00:00
Timo Tijhof
a999da181e resourceloader: Export ResourceModules as extension attribute
Instead of exporting this as a global variable, export it as an extension
attribute.

The $wgResourceModules configuration variable will continue to be supported
for its main purpose of adding modules. However it may no longer be used to
access the complete registry. In actuality, it was already incomplete because
modules defined via 'ResourceLoaderRegisterModules' hooks were already absent.

The full copy is now owned only by the ResourceLoader class and publicly
available via isModuleRegistered() and getModuleNames().

This opens the door to making it a lazy-loaded attribute, which would help
reduce the size of the "main" APCu cache key for ExtensionRegistry.
This is not possible with global variables as those must be exported
unconditionally from Setup.php.

Bug: T32956
Bug: T247265
Change-Id: I13cf05af458131ce8439eee770d7a62bd9404288
2020-03-30 23:11:05 +00:00
jdlrobson
73c20062e0 mediawiki.legacy.shared is merged into existing skin modules and removed
Skins that are using ResourceLoaderSkinModule will need to update their
features to include `legacy`

Note that Ic7af947cfd5a5df4218f006232ede4ee7ed36c62 for Vector
and I6471bc169f3c2a1f51e17b8ee26ac245b0374c18 for Monobook should
be merged in the same release as this patch to ensure these styles
do not disappear from those skins. Minerva or Timeless will not be impacted.

Changes for other skins including Modern and CologneBlue to follow
where needed.

Bug: T242177
Change-Id: Icb910a563273bde92a09b1bb92857d5b6e348baa
2020-03-12 13:17:24 -07:00
Timo Tijhof
f575721a06 Update all use of $wgVersion to MW_VERSION
Follows-up I04628de4152dd5.

Bug: T212738
Change-Id: I718474ec0d9fd29ac2c05477f0f2493615d8aff5
2020-02-25 02:16:12 +00:00
Roan Kattouw
ca7fa28615 resourceloader: Separate style processing from style file loading
ResourceLoaderFileModule::readStyleFile() both reads a style file from
disk and processes it through LESS, CSSJanus and CSSMin. Factor out the
processing part into ResourceLoaderFileModule::processStyle(), which
takes a string of unprocessed CSS/LESS rather than a file. This is
needed for future support for styles that don't come (directly) from a
file, but are generated through packageFiles.

Other changes:
- Use a hash of the source instead of the file name in the cache keys
  for the LESS compilation output
- Also prefix the cache key with 'resourceloader' while we're changing
  it anyway
- LESS compilation no longer adds the source file itself as a dependency
- Don't pass down $flip, just use $this>getFlip()

Change-Id: I86e880d06af724f0fbae93e042c85e0395771912
2020-02-12 20:23:24 +00:00
Timo Tijhof
b118bddc15 installer: Rename Doxygen group from "Deployment" to "Installer"
Also improve the description a bit and explain at a high level
how this code is used, and which classes back those entry points.

Change-Id: Ia69531858e714d0b43a29a7d5b6dcc5c7edd8240
2019-11-25 23:26:20 +00:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Daimona Eaytoy
c659bc6308 Unsuppress another phan issue (part 7)
Bug: T231636
Depends-On: I2cd24e73726394e3200a570c45d5e86b6849bfa9
Depends-On: I4fa3e6aad872434ca397325ed7a83f94973661d0
Change-Id: Ie6233561de78457cae5e4e44e220feec2d1272d8
2019-09-03 17:19:21 +00:00
Timo Tijhof
43ec5d6a9d installer: Avoid <doclink/> hack for 'config-sidebar' rendering
Use separate messages for the link labels instead.

Bug: T227297
Change-Id: I2fda6ef98117781231a0d42c039d333ef829ea98
2019-07-05 18:26:53 +00:00
Derick Alangi
2163259235 installer: Remove deprecated method WebInstallerOutput::addWikiText()
Was deprecated in 1.32 and no longer used, hence removing from MW core.

Change-Id: I93c5dc1d74fd856c07b09e4c3028e223d2939522
2019-06-20 18:11:48 +01:00
jenkins-bot
8b22883a66 Merge "WebInstaller: Add ARIA role="main" to overall div" 2019-06-18 16:00:41 +00:00
Volker E
4149b597df WebInstaller: Add ARIA role="main" to overall div
Adding ARIA `main` role on appropriate element to keep in sync with
WMF deployed themes.

Change-Id: I9436fd4478e2b108a7ec588db0a628d7d5c26fcd
2019-06-18 15:46:17 +00:00
Fomafix
360f741d39 Installer: Make short header and normal header of WebInstaller equivalent
Change-Id: I8ae0cca582c2dab87a4b3b050030f6c96897939e
2019-06-17 19:21:38 +00:00
Fomafix
0f346d6822 Installer: Move style of background image from HTML to CSS
Change-Id: I5fb8a9fc87290c407be123238397accbc5a886dc
2019-06-14 10:46:40 +02:00
Timo Tijhof
a186dc62fd resourceloader: Instantiate main class via ServiceWiring
It also removes some code duplication which is nice.

This unlocks various future changes, including:

* Making the `$config` parameter mandatory for the ResourceLoader class
  constructor, which currently falls back to global state.
  This should be deprecated and removed.

* Making it possible to instantiate the ResourceLoader class
  without all the default MW modules being registered from
  global state. E.g. move MW module registration from main class
  constructor to ServiceWiring, and remove the 'EmptyResourceLoader'
  class hack from unit tests, and use regular 'new ResourceLoader'
  instead.

* Making ResourceLoader a standalone library (some day),
  e.g. allowing it to be instantiated from a basic PHP script,
  in a way that is still useful and perhaps able to serve
  (most) RL modules without MW itself.

Bug: T32956
Change-Id: I4939f296c705b268e9cf8de635e923a739410470
2019-02-18 17:55:09 +00:00
Fomafix
627e2c9b16 WebInstallerOutput: Add getLanguage()
Combine the functions getLanguageCode() and getDir() to the single
function getLanguage().

Also mark the class WebInstallerOutput as @private.

Change-Id: Ic7deea5f3040fe8f1211b96622bdae222ca9e072
2019-01-19 19:53:56 +01:00
Fomafix
0ac7404d38 installer: Use getUrl() for CSS link in WebInstallerOutput
This change changes the CSS URL in the stylesheet link from

  <link rel="stylesheet" href="/mediawiki/mw-config/index.php?css=1"/>

to

  <link rel="stylesheet" href="/mediawiki/mw-config/?css=1"/>

on the website /mediawiki/mw-config/.

Change-Id: Ib46c4d944df862cf928d3ebd050ff2d1e16ba6a5
2018-11-04 21:00:00 +00:00
C. Scott Ananian
b3141dac43 Rename WebInstallerOutput::addWikiTextInterface
Follow up to I89f3398cffa771afcd5a33cfd11eb8510af3e7f7: this patch
was intended to mirror a new method added to OutputPage in
Ia58910164baaca608cea3b24333b7d13ed773339 but the bikeshed was painted
a slightly different color before the OutputPage patch was merged, and
somehow this patch wasn't changed to match.  The `addWikiTextInterface`
name was never included in a released MW version, so we don't need to
deprecate it, just fix it.

Change-Id: I636cb0ea0f9631c4c5e2bc118f479aec76d2b231
2018-10-21 23:02:32 -04:00
C. Scott Ananian
1c10bfb034 Tidy and rename WebInstallerOutput::addWikiText() to addWikiTextInterface()
This change parallels the new method added to OutputPage in
Ia58910164baaca608cea3b24333b7d13ed773339 and ensures that the
content added is always tidied.  We leave the old alias in
place for now in accordance with our deprecation policy.

Change-Id: I89f3398cffa771afcd5a33cfd11eb8510af3e7f7
2018-09-25 14:47:33 -04:00
Timo Tijhof
9849db9c79 skins: Move default style modules to getDefaultModules
This advances T140664 as well, because it encourages module
loading logic from the skin to be in this single method.

Update the tests for setupSkinUserCss(), to now target
getDefaultModules() instead, given setupSkinUserCss() no longer
provides these behaviours. Had to move where the mock object
was created so that it can be injected in the skin (previously
it could be passed as parameter). Besides, its generally best-
practice to create mocks and stubs within the test anyhow, not in
the data provider.

Bug: T140664
Depends-On: Ib2b19ba165a9d646a770702cdf1724509156b93e
Change-Id: I3404c1c2a7e8eae0b803b31f333cb9b837f43d4a
2018-05-04 23:52:02 +00:00
Fomafix
ea0bd74a94 Refactor global function wfBCP47 to static function LanguageCode::bcp47
Deprecate global function wfBCP47.

Change-Id: Ie6bb061b5d6ca67289bb18bc468a87421f38fc94
2017-10-05 09:54:45 +02:00
Bartosz Dziewoński
ecdef925bb Miscellaneous indentation tweaks
I was bored. What? Don't look at me that way.

I mostly targetted mixed tabs and spaces, but others were not spared.
Note that some of the whitespace changes are inside HTML output,
extended regexps or SQL snippets.

Change-Id: Ie206cc946459f6befcfc2d520e35ad3ea3c0f1e0
2017-02-27 19:23:54 +01:00
Timo Tijhof
f47d1eee0e OutputPage: Fix blank line between <html> and <head>
Follows-up a464d1d41 which changed OutputPage::headElement()
to join pieces by a line break instead of hardcoding line breaks
after (some) generated pieces.

This caused a minor regression in the form of a blank line between
<html> and <head> on every page, because I missed the one that
came from this class.

Change-Id: I5e48b852809699b205f4581c833605f3e232610a
2016-07-21 21:08:24 +01:00
daniel
fc1d4d7960 Fix installer issues introduces by MediaWikiServices
This fixes three issues with the installer:

1) Make sure LocalizationCache can find the installer's i18n files.
2) Make sure we don't try to use an SqlBagOStuff for caching before we have
   a functioning database.
3) Don't try to output HTML when redirecting (this is unrelated to
   MediaWikiServices, but came up during testing)

Bug: T135169
Change-Id: I7caa932024cd771d6fa226a3ac6001c3148ecc9c
2016-05-17 15:24:31 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Ori Livneh
3f1e9fa268 resourceloader: Tidy up RL to simplify ResourceLoaderEditToolbarModule
* Remove ResourceLoaderFileModule::getLessCompiler(). There is no reason for a
  module to need to get a compiler in a different manner than
  ResourceLoader::getLessCompiler().
* Add ResourceLoaderModule::getLessVars(). This method provides a means for
  subclasses to easily inject custom LESS variables. The default implementation
  simply returns an empty array.
* Make the $context parameter for ResourceLoaderFileModule::readStyleFiles()
  non-optional (via graceful deprecation). The only callers I found were either
  already calling it with a ResourceLoader context, or had a perfectly usable
  ResourceLoaderContext in local scope.
* Make ResourceLoaderFileModule::{readStyleFile,getLessCompiler} require a
  context. These methods are protected, so I didn't bother with a deprecation.
* Call ksort() on the LESS variables array in the only place it matters -- when
  hashing its serialized representation to construct a cache lookup key. This
  relieves getLessVars() subclasses from having to remember to re-sort the
  variables array if they modify it.
* These changes make it possible to substantially simplify
  ResourceLoaderEditToolbarModule, because the only thing it needs to do now is
  implement its own getLessVars() method.
* This also allows it to be versioned like any other ResourceLoaderFileModule,
  rather than having to use enableModuleContentVersion().

Change-Id: Ic3eab71691e502bfe19bdf4eb6f82cc679a7782f
2015-09-28 12:18:12 -07:00
Kunal Mehta
3c1d3e2bc6 installer: Read styles from Vector's skin.json
Vector now has a skin.json and the PHP entry point is just a stub, so
including it doesn't do anything. We can read from the skin.json file
and register the module properly instead of depending upon implicit
globals.

Also make ExtensionRegistry::__construct() not fail if $wgObjectCaches
is not set up properly, which is the case sometimes in the installer.

Bug: T98043
Change-Id: I5a653b095665092f8a27416b8a7f28ebf7d4d8c1
2015-05-04 11:41:13 -07:00
umherirrender
489d793882 Fixed spacing
- Added/removed spaces around parenthesis
- Added newline in empty blocks
- Added space after switch/foreach/function
- Use tabs at begin of line
- Add newline at end of file

Change-Id: I244cdb2c333489e1020931bf4ac5266a87439f0d
2014-12-05 22:28:07 +01:00
m4tx
6345e8aea5 Fix group separator in installer's sidebar
Uses explode() to split the sections and puts correct separators between them.

Bug: T39362
Change-Id: I9a287b6ac206debb9bd93dbfad0703a8fad0931f
2014-12-01 20:31:36 +01:00
Fomafix
78f103fdec WebInstallerOutput: Apply wfBCP47() to lang attribute
Change-Id: I7dce46380f56ff2960de7f6d9644c4cdc972a372
2014-11-13 22:43:52 +00:00
saper
8ac77bfbd3 Installer: Do not use Vector skin if not installed
MediaWiki installer works fine in a bareskin
mode without Vector features, so do not
throw errors in the PHP error log just because
we don't have "skins" project extracted.

The message in the PHP error log:

Warning:  include_once(w/skins/Vector/Vector.php): failed to open stream: No such file or directory in w/includes/installer/WebInstallerOutput.php on line 135
Stack trace:
  1. {main}() w/mw-config/index.php:0
  2. wfInstallerMain() w/mw-config/index.php:38
  3. WebInstaller->execute() w/mw-config/index.php:79
  4. WebInstaller->outputCss() w/includes/installer/WebInstaller.php:185
  5. WebInstallerOutput->getCSS() w/includes/installer/WebInstaller.php:1200

Change-Id: I7b8bd77f5868af2ccf464e48db771f2e8e0472ff
2014-08-31 00:34:53 +02:00
Florianschmidtwelzow
33fd7765b8 Fix WebInstaller style
The WebInstaller don't use classes, so it broke after Vector skin changed
to use classes instead of ID's

See: Iae873906abcd8b2a986e5f728f0ce207256de770

Bug: 70190
Change-Id: Ia70498a0ee7c99d000790223c44feddce73a5416
2014-08-29 23:13:32 +02:00
Bartosz Dziewoński
a8e474c1f2 Move installer files from skins/common/ to mw-config/
The CSS and JS files are definitely used only by the installer.

As for the images:
* mediawiki.png is still used directly by some error pages
  (includes/PHPVersionError.php, includes/templates/NoLocalSettings.php)
* ajax-loader.gif is still used by shared.css
* bullet.gif is mysteriously used by *something*, according to the
  logs at bug 69277 comment 11; I currently have no idea what, so
  let's keep it here for a while
* All other ones don't grep (outside of the installer itself) and
  don't appear in the logs on bug 69277.

Bug: 69277
Change-Id: I9146d9211a807911a5e0cfaa1dd3ab8170f333ca
2014-08-17 22:32:25 +00:00
Bartosz Dziewoński
c1c334efa5 WebInstallerOutput: Restore 'global $wgResourceModules'
Deleted in 301a7f3d, previously added in a96afeb2.

Change-Id: If0889bc003320abd0b74fc57b8975255f0efcc7e
2014-08-17 19:18:52 +00:00
umherirrender
301a7f3d1d Remove unused global declarations
Change-Id: I05a9bc5c0c0447c045714a445b0ed44f001db1dc
2014-07-19 22:44:54 +02:00
Bartosz Dziewoński
a96afeb262 Separate Vector skin from core
This makes it behave exactly like a custom skin, with the caveat that
it is still hardcoded in several places :(, most notably lots of
skinStyles in Resources.php, the installer and some tests.

* Renamed directory to reflect skin name.
* Split skin classes to separate PHP files.
* Removed core autoloader entries for skin classes.
* Changed the hack in Setup.php to require_once the skin PHP file, as
  the skin is now registered there.
* Extracted skin-specific localisation messages.
* Extracted skin-specific resources. Did not touch skinStyles yet.
* Hacked up the installer not to fall over entirely if Vector is
  missing.
* Adjusted hardcoded paths in some more places...

Change-Id: Idfffc1430790b3a104cc9835a6367137bcbf0e4e
2014-06-21 00:01:04 +02:00
Timo Tijhof
0888ccbcad Installer: Re-use ResourceLoader methods instead of duplicating
Also:
* Fix incorrect documentation comment of ResourceLoaderModule::getStyles(),
  it doesn't return a string, it never has.
* Remove spurious space in count() call.
* Fix spelling of in "proper".

Change-Id: I000393636f7b9015ad1bacfbb3eb8a6ad8695d72
2014-06-07 10:02:55 +02:00
Timo Tijhof
81e74e8d69 Installer: Simplify css request
Instead of passing around the direction in the request, just set
'css=1'. We already have the language code and directionality
available and even rely on it between requests to set other
localisation-related things.

Change-Id: I717cb299b3639024e79880039e0d1f2ff273ab44
2014-06-04 21:25:55 +02:00
Bartosz Dziewoński
fc69e6c645 Rename basic skinning modules: skins.common.* → mediawiki.skinning.*
For consistency in module naming: skins.* contains the modules for
particular skins, mediawiki.* contains the modules for core MediaWiki
itself. Clearly this belongs more to the latter than the former.
'skinning' is probably the best thing to name these to not sound silly
and avoid confusion with actual skins.

(The fact that there are files in skins/ that are not skin-related is
a remnant of bad decisions in the past. I want to clean that up as
well this year.)

Updated release notes and usages, kept old definitions for HTML
backwards-compatibility (for 30 days on WMF deployment).

I intend to backport this to 1.23 (sans the compatibility modules).
Otherwise the current module names become "public API" and we either
break compatibility later or support them forever.

Change-Id: I3947eaacd389eaba32f6fc8370395caec4aa1edb
2014-05-02 17:24:09 +00:00
umherirrender
f5f1e38b9a Fixed some @params documentation (includes/[db|installer])
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: I3595e9aac69ac42fbb74b0783fae0ad9bcc831aa
2014-04-19 13:55:27 +02:00
Bartosz Dziewoński
ebcfbdfd87 WebInstallerOutput: Fix path to jquery.js
Follow-up to Id5ead145 and I335e4c08.

Bug: 64091
Change-Id: If40f479df7d68071d6ce5d2f3b8251e6bf3eb80e
2014-04-18 15:31:49 +00:00
Fomafix
d1176624a4 Fix Webinstaller after file move
Follow-Up to Id5ead1453412e763bdb3763084e43694517088fd

Change-Id: I335e4c08bbafd136c3a8734c9b077a62cb9d989d
2014-04-09 17:47:34 +00:00
Thiemo Mättig
6419dc7e26 WebInstaller inline documentation cleanup
This is a follow-up to Ide17d5af13c416c62a40029848ac17ba24eb5563.
However, I could not fix the "minor style" issue mentioned there
because this would make the line to long.

I fixed lots and lots of other issues instead, e.g.:

* "void" isn't a thing. Added "return null" instead.
* Removed documentation that said "a constructor is a constructor".
* Use "string[]" and such instead of "array" if possible.

Change-Id: I9658c2af58862f1d634cf1b2ba4c9d0f27ee7608
2014-04-08 12:22:43 +02:00