Commit graph

1479 commits

Author SHA1 Message Date
Bartosz Dziewoński
c8ad83310f Refactor registration of OOjs UI resource modules
includes/resourceloader/ResourceLoaderOOUIModule.php
* New trait centralizing some logic for dealing with OOjs UI themes,
  previously duplicated in OutputPage, ResourcesOOUI.php and
  ResourceLoaderOOUIImageModule.
* Follow-up change I74362f0fc215b26f1f104ce7bdbbac1e106736ad uses this
  as a base to allow skins/extensions to define new OOjs UI themes.

resources/Resources.php
resources/ResourcesOOUI.php
includes/resourceloader/ResourceLoader.php
* OOjs UI resource module definitions are moved back to their rightly
  place in Resources.php. They are again (almost) normal and static.
* Theme-specific logic is now handled by the module code, definitions
  only specify 'themeScripts'/'themeStyles'/'themeImages'.
* ResourcesOOUI.php is deleted and no longer loaded by ResourceLoader.

includes/resourceloader/ResourceLoaderOOUIFileModule.php
includes/resourceloader/ResourceLoaderOOUIImageModule.php
* Glue code previously existing in ResourcesOOUI.php now lives here.
* Use the ResourceLoaderOOUIModule trait to avoid code duplication.

Change-Id: I39cc2a735d9625c87bf4ede6f5fb0ec441d47dcc
2017-06-01 17:04:05 +02:00
Bartosz Dziewoński
18d8f2aa99 OutputPage: Do not try to load non-existent 'oojs-ui.styles.icons' module
Follow-up to 0f2795d5ba.

Change-Id: I461fb179a494e00a14116361700020da577db494
2017-06-01 17:04:02 +02:00
Timo Tijhof
15ca48adf2 resourceloader: Ensure user.styles and site.styles having their own request
Regardless of whether other modules exist with group=user or group=site,
these two modules in particular must always be in their own request for
legacy reasons.

This has already always been the case because even in the few cases where
an extension uses this group (eg. MobileFrontend's custom site module) it
would load it instead of another module in that group, never at the same
time. There is one notable exception, which is GlobalCssJs. However the
ext.globalCssJs.user.styles module is usually served from another wiki
which is why that went unnoticed as well. This commit fixes that so that
even if you're viewing a page on the central wiki, the modules are still
in separate requests.

Aside from this one existing edge case, there is also need to add
group=site to gadgets by default so that they load after the DynamicStyles
marker instead of before, which is currently causing problems with the
cascading order (gadget apply before core and skin styles due to being
in the same request group and alphabetically sorting before them).

Semantically, the appropiate solution is group=site, but this wasn't
possible due to core putting "all" group=site modules in the same request
(under the assumption there is only one such module). This commit removes
that fragile assumption.

Bug: T147667
Change-Id: I9eb725c083124d22a9af3bf3d075ade6f3b970a3
2017-05-26 14:15:47 +00:00
jenkins-bot
5f764ec180 Merge "Move loading of mediawiki.toc from Parser to Skin" 2017-05-23 18:42:44 +00:00
jenkins-bot
646476af33 Merge "OutputPage: Move hardcoded default modules to Skin::getDefaultModules" 2017-05-23 18:31:20 +00:00
jenkins-bot
cfb04229b2 Merge "resourceloader: Add tests for OutputPage::buildExemptModules" 2017-05-23 01:00:55 +00:00
Timo Tijhof
c7e00974c7 Move loading of mediawiki.toc from Parser to Skin
This was the only addModules() call ever to be inside Parser.
Introduced in a54ef1a203. Prior to that, mediawiki.toc had always been loaded
by OutputPage (via mediawiki.util; and before that, via wikibits).

This patch restores that, and also fixes T130632 by making OutputPage get
it from the Skin, instead of hardcoding this somewhere in addParserOutput().

* Remove deprecated method OutputPage::enableTOC().
* Move mEnableTOC to addParserOutputText().

Bug: T130632
Change-Id: Iaad84d241a4c4348c712ac1087a664b8c9c46da4
2017-05-21 19:06:43 +02:00
Timo Tijhof
0048c3e255 OutputPage: Move hardcoded default modules to Skin::getDefaultModules
These modules should not be hardcoded in OutputPage::output() which
makes them impossible to override and also very hard to retrieve
through the API for action=parse. Move these instead to Skin which
is where all other default module loading happens already.

Moving these modules is in preparation for customising ApiParse
to support "really" returning all would-be loaded modules on a page
when setting 'useskin', which is also needed for Live Preview
and in theory for ajax navigation and other scenarios where there
is a delay between the "initial" page rendering, and a later re-render
which may not have all all the necessary modules.

Bug: T130632
Change-Id: Ic4afccf0cd0d428d7fbc36d4e747415af3ab49f5
2017-05-21 19:06:43 +02:00
Timo Tijhof
8628893d99 resourceloader: Add tests for OutputPage::buildExemptModules
Bug: T147667
Change-Id: I40245359925ef5dc4e01ada396503a758d6b95fe
2017-05-20 18:54:43 +00:00
jenkins-bot
2b5fe6e3f1 Merge "Introduce wgRelevantPageIsProbablyEditable" 2017-05-18 16:01:26 +00:00
James D. Forrester
dbfe9c99d3 Introduce wgRelevantPageIsProbablyEditable
This is equivalent to the existing variable wgIsProbablyEditable and in
keeping with wgRelevantPageName/wgRelevantArticleId; this is done as an
alternative to making a breaking change to the semantics of the former,
as that might cause issues for users who expect wgIsProbablyEditable to
return true on [[Foo]], but false on [[Special:Move/Foo]] and similar.

Change-Id: I6c6ca1cfd93e7be917952980f1e1d57aec3a1292
2017-05-18 15:29:18 +00:00
James D. Forrester
1397b21b84 OutputPage: Remove deprecated addParserOutputNoText, getHeadLinks methods
Change-Id: Idc55e7bb0f7bde8466192a81886f205de60c092c
2017-05-15 13:17:04 +01:00
Gilles Dubuc
13ffd04c5f Toggle logo preloading via the skin
Bug: T100999
Change-Id: I0e18dc7fdbf133f3e4002f48f3040604687571dc
2017-05-02 15:05:11 +02:00
Timo Tijhof
45d8cd2926 Ensure logo preload transforms urls if needed
Follows-up 5f55e9c9c2.

If the logo url is from within /w, then ResourceLoaderSkinModule
will (as it should) apply a file hash query to it.

The preloader didn't do that, so it specified the wrong url.

Refactored SkinModule to make this logic re-usable.

Bug: T100999
Change-Id: I1ba11f7c70d1a725ad72754fee4a3f33c2a4c1be
2017-04-12 21:34:31 +00:00
Fomafix
464f0c72a5 Remove multiple spaces in PHP files
Change-Id: Id9c26ec5ca730a9536f8fdccb8853eb03cbe87a4
2017-04-12 17:27:19 +02:00
jenkins-bot
85fcc8b254 Merge "Preload the logo using link rel="preload" http header" 2017-04-12 06:58:14 +00:00
Gilles Dubuc
5f55e9c9c2 Preload the logo using link rel="preload" http header
This greatly increases the priority of loading
the logo on browsers that support rel="preload".

Bug: T100999
Change-Id: I0738fcc0a575153dab65016fa87faaa9b8b97a9d
2017-04-11 19:08:53 -07:00
jenkins-bot
8ea7953ab5 Merge "Add ?safemode=1 to disable user JS/CSS" 2017-04-10 18:50:19 +00:00
Brian Wolff
14beae88b5 SECURITY: Do not directly redirect to interwikis, but use splash page
Directly redirecting based on a url paramter might potentially
be used in a phishing attack to confuse users.

Bug: T109140
Bug: T122209
Change-Id: I6c604439320fa876719933cc7f3a3ff04fb1a6ad
2017-04-06 13:42:38 -07:00
Roan Kattouw
1a9fb8cb78 Add ?safemode=1 to disable user JS/CSS
Bug: T152169
Change-Id: I112b7abf1cfa1330b2d4e6150018aad14c00b654
2017-03-29 17:01:11 -04:00
Brian Wolff
1c7889446d SECURITY: Disable <html> tag on system messages despite $wgRawHtml = true;
System messages may take parameters from untrusted sources. This
may include taking parameters from urls given by unauthenticated
users even if the wiki is a read-only wiki. Allowing <html> tags
in such a context seems like an accident waiting to happen.

Bug: T156184
Change-Id: I661f482986d319cf41da1d3e7b20a0f028a42e90
2017-03-28 21:51:44 +00:00
James D. Forrester
9635dda73a includes: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I6f59febaf8fc96e80f8cfc11f4356283f461142a
2017-02-21 18:13:24 +00:00
Timo Tijhof
835833ea8a OutputPage: Log violations of module 'target' filter
Bug: T140675
Change-Id: Icf9a2e72b663e363e8c87d5d464892c2bbbe78b2
2017-02-14 16:25:39 -08:00
Timo Tijhof
adc0e79124 OutputPage: Support UploadPath in testTransformResourcePath()
Updated tests to reflect this use case. Currently we assume all web-accessible
paths within ResourceBasePath (e.g "/w") to exist on disk at the same path
in $IP (e.g. "/var/www/mw").

While in theory any number of web server rewrites or aliases could exist,
there is one case in particular that we should support since the information
is available in the configuration: UploadDir and UploadPath. This path may
be rewritten in a way that varies by wiki in multi-wiki installs that share
the same source code. E.g. a server may rewrite "/w/images" to somewhere
else, which means it will not match the directory on disk that is shared
between wikis.

Bug: T155146
Change-Id: I320478c9c262cc012f08b585b48d290594ec2420
2017-02-11 04:45:15 +00:00
Amir Sarabadani
a1e2f07784 Allow OpenGraph RFDa meta tags
See: http://stackoverflow.com/questions/22350105/whats-the-difference-between-meta-name-and-meta-property
And https://developers.facebook.com/docs/sharing/webmasters#markup

Bug: T51859
Change-Id: Ie8fd697e8588435a69f02e779038ae5a11d67be6
2017-01-25 21:49:55 +03:30
jenkins-bot
ea23bc97ee Merge "Replaced all deprecated Linker methods with proper ones in core(1)" 2017-01-21 19:33:09 +00:00
Yuriy Shnitkovskiy
55667f024d Replaced all deprecated Linker methods with proper ones in core(1)
Change-Id: Ie3a718dc1eae1507f8829fcf419c64c6846d2cb6
2017-01-20 11:46:13 +02:00
jenkins-bot
f8a0ab3d37 Merge "Remove unused $resourceLoader" 2017-01-19 21:07:36 +00:00
addshore
641d24b3b6 Remove unused $resourceLoader
Change-Id: I6b5aebe2c6221ee101ec3bc4c84eafd9aeb7b0e2
2017-01-19 20:51:22 +00:00
Timo Tijhof
d753e330a2 OutputPage: Ignore protocol-relative urls in transformResourcePath()
transformResourcePath is only supposed to be called with something
that starts with a '/' (absolute path from document root).

While the primary caller (CSSMin) only calls this method if the path
makes sense as a local file path, ResourceLoaderSkinModule did not,
and wgLogo may be set to a full url that includes a domain.

While chance made it so that protocol-including urls were already
discarded, protocol-relative urls were mistaken for being a path
inside the file system root with a duplicate slash (e.g.
'//tmp/foo.txt', as 'foo.txt' in /fmp, instead of '/foo.txt' at
http://tmp).

This should be fixed upstream in the wikimedia/relpath library,
but workaround it for now since it really shouldn't be called
with urls in the first place.

Bug: T155310
Change-Id: I9b063f1219ddeca5cc2c8a48832cdf8c9eaffe58
2017-01-18 18:15:01 +00:00
Aaron Schulz
b03b387e5a Include JS variable for NewPP report
Adapted from reverted commit b7c4c8717f.

Bug: T110763
Change-Id: If249b679c534879bfac622592a1d2fa913a0cf9d
2017-01-05 19:11:38 -08:00
Yuriy Shnitkovskiy
b98aa152b3 Avoid passing $this by reference in hooks
Renamed $this passed by reference usages in hooks inside includes directory

Bug: T153505
Change-Id: Ib3e6a288a423958e75b5c1bfe53dc29e0f3fee6d
2017-01-02 01:07:49 +02:00
jenkins-bot
9ac29c74ed Merge "Cleanup some incorrect return annotations" 2016-12-16 07:22:24 +00:00
jenkins-bot
3a2853e218 Merge "Add <!DOCTYPE html> to HTML responses" 2016-12-16 07:16:45 +00:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
Ed Sanders
5ee5ae6f69 Move link-underline user preference rule to body class
ResourceLoaderUserCSSPrefsModule is now empty and can be removed.

Change-Id: I806e117131765b859e990c14735bb9494db9a37e
2016-12-02 11:25:03 -08:00
Yuriy Shnitkovskiy
b0bd03fb13 Replace Linker::link() with LinkRenderer in includes directory
* CategoryViewer
* OutputPage
* Preferences

Bug: T149346
Change-Id: I9f9bcd9b461884817e8ceefbc6757c436221e331
2016-12-01 09:57:05 +02:00
jenkins-bot
2c0db8f5e8 Merge "OutputPage::getCategories(): Add a possibility to distinguish "normal" and "hidden" categories" 2016-11-25 00:17:04 +00:00
Florian
f4b8549f5f OutputPage::getCategories(): Add a possibility to distinguish "normal" and "hidden" categories
There's currently no way to get, e.g., all categories except the
hidden ones just as text. The OutputPage::getCategories() method
always returns all categories as an array of strings (titles) and
the getCategoryLinks() method returns the result of Linker::link
but with the distinction between "normal" and "hidden" categories.

This change adds a new parameter to OutputPage::getCategories(),
$type, which can be used to define, what categories should be
returned. The default value is "all", which means, that all categories
are returned (the current result of the method). With the value
"normal" and "hidden", the method will return the respective values.

This could be used in I97d7de723fe72da26c7dbde0a559a13704c7099a to
remove the stupid Linker::link() and isset workaround.

Change-Id: Iadda9ae362a21fbee770240234b8f55326219932
2016-11-25 00:02:28 +00:00
Bartosz Dziewoński
0e15a6068a Revert "Move NewPP limit report HTML comments to JS variables" and followups
This change resulted in unreasonable feature loss (human-readable
limit report was gone). Three months and multiple followups later,
the functionality is still not completely restored. Given lack
of response from the original author, I think it is time to revert
and reconsider, especially since the 1.28 release is soon.

A machine-readable limit report would be a very useful feature,
but not at the cost of losing human-readable limit report.

This reverts the following commits:

* Move NewPP limit report HTML comments to JS variables
  b7c4c8717f
* Only pretty-print the parser report JS vars
  28adc4d7ee
* Show wgPageParseReport on page previews too
  1255654ed5
* Re-add human readable parser limit report
  0051f108b9
* Restore hooks.txt for ParserLimitReportFormat
  4663e7a737

Resolved minor merge conflicts in OutputPage (with 80e5b160)
and release notes.

Bug: T110763
Bug: T142210
Change-Id: Id88c8066fae3f369e8977b4b7488f67071bdeeb7
2016-11-08 22:35:15 +01:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
jenkins-bot
4ac6d60844 Merge "Fix docs for OutputPage::addLanguageLinks and OutputPage::setLanguageLinks" 2016-11-08 03:36:32 +00:00
Leszek Manicki
287bb1a064 Fix docs for OutputPage::addLanguageLinks and OutputPage::setLanguageLinks
Per what has been described and fixed in
Ie9c42ac2b4ff143e36d07642f57cca769e8c00e7.

Change-Id: I2af28ae97805f3259ca038942a84b43f89b55150
2016-11-07 16:18:37 +01:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Aaron Schulz
919992eece Break long lines in OutputPage::sendCacheControl()
Change-Id: I72d494f4c97aef9d500bb5d7b36dad30a44f501a
2016-11-03 13:06:59 -07:00
jenkins-bot
a6c5f1a815 Merge "Use adaptive CDN TTLs for page views" 2016-10-21 21:55:52 +00:00
Aaron Schulz
4a3e3c95b3 Use adaptive CDN TTLs for page views
This makes frequently changed pages be less likely to be
seen in stale forms if purges are delayed or lost. Pages
that have not been edited for somewhat longer than the
nominal CDN cache TTL will retain the nominal TTL.

Category pages will adapt based on page_touched rather
than the last revision, given the possibility of constaintly
changing membership. With their lesser overall usage,
this is less risky than for Article, and also more useful.

Change-Id: If621aca2fb68e9f87a50c891dac8dc6ec7641f5c
2016-10-20 23:22:31 +00:00
jenkins-bot
e097c61475 Merge "OutputPage: Reduce getTitleInfo() calls (improve preloading)" 2016-10-20 22:18:38 +00:00
Timo Tijhof
458d37f205 OutputPage: Reduce getTitleInfo() calls (improve preloading)
* Remove filter between $moduleStyles and preloadTitleInfo().
  Previously, this was filtering out wiki modules created by
  gadgets and extensions. Still causing a couple of direct queries
  from getTitleInfo().

* Store __METHOD__ in $fname outside getWithSetCallback.
  This way queries are logged as either getTitleInfo or preloadTitleInfo.
  This regressed in 0852a000a5, after which the latter was logged
  as "::{closure}".

Change-Id: I454e43f43f8ad3270b86f4cfdbd68192c305cc07
2016-10-20 21:59:23 +00:00