Commit graph

1525 commits

Author SHA1 Message Date
MGChecker
8af76decf8 registration: Let extensions add PHP version requirements
While MediaWiki Core already sets requirements for PHP versions, it should be
possible for extensions to tighten these requirements. This mirrors the PHP
parameter of extension infoboxes as well.

This change introduces a new 'platform' key (in addition to 'MediaWiki', 'skins'
and 'extensions', where non-MediaWiki software requirements will be listed
in the future, starting with a PHP version constraint. Further keys are
supposed to be added to allow setting constraints against php extensions
and other abilities of the platform.

Bug: T197535
Change-Id: I6744cc0be2363b603331af9dc860eb8603a1a89a
2018-09-22 03:43:28 +02:00
Agabi10
580041be56 Add a hook to allow changing the query of Special:AncientPages in extensions
Bug: T76287
Change-Id: I6aa4d8e6140d405476a6f480156f24f2c05019cb
2018-08-31 15:54:45 +00:00
Gergő Tisza
2ed7bdc46d
Require editsitecss/editsitejs for editing raw messages
Bug: T45646
Change-Id: Ib16db04e499ad28216ee08b8cccccf3f141e2bad
2018-08-26 23:56:06 +02:00
Gergő Tisza
d31580eeb0
[MCR] Render multi-slot diffs
Move logic for rendering a diff between two content objects out of
DifferenceEngine, into a new SlotDiffRenderer class. Make
DifferenceEngine use multiple SlotDiffRenderers, one per slot.

This separates the class tree for changing high-level diff properties
such as the header or the revision selection method (same as before:
subclass DifferenceEngine and override ContentHandler::getDiffEngineClass
or implement GetDifferenceEngine) and the one for changing the actual
diff rendering for a given content type (subclass SlotDiffRenderer and
override ContentHandler::getSlotDiffRenderer or implement
GetSlotDiffRenderer). To keep B/C, when SlotDiffRenderer is not overridden
for a given content type but DifferenceEngine is, that DifferenceEngine
will be used instead.
The weak point of the scheme is overriding the DifferenceEngine methods
passing control to the SlotDiffRenderers (the ones calling
getDifferenceEngines), without calling the parent. These are:
showDiffStyle, getDiffBody, getDiffBodyCacheKeyParams. Extensions doing
that will probably break in unpredictable ways (most likely, only
showing the main slot diff). Nothing in gerrit does it, at least.

A new GetSlotDiffRenderer hook is added to modify rendering for content
models not owned by the extension, much like how GetDifferenceEngine
works.

Also deprecates public access to mNewRev/mOldRev and creates public
getters instead. DifferenceEngine never supported external changes to
those properties, this just acknowledges it.

Bug: T194731
Change-Id: I2f8a9dbebd2290b7feafb20e2bb2a2693e18ba11
Depends-On: I04e885a33bfce5bccc807b9bcfe1eaa577a9fd47
Depends-On: I203d8895bf436b7fee53fe4718dede8a3b1768bc
2018-08-20 15:39:12 +02:00
Gergő Tisza
47b5d95f12 Create DifferenceEngine before calling GetDifferenceEngine
This way the hook is able to consider what kind of DifferenceEngine
was created by default, or even wrap/decorate it.

Change-Id: Ibb6b1b087a2dda445be2b5e8c7518c7d169b5192
2018-08-20 13:32:49 +00:00
Timo Tijhof
6ff469e57f Improve profileinfo.php documentation
* Move $wgEnableProfileInfo to DefaultSettings.php

* The configuration variable to enable the entry point was added
  together with the entry point itself in 9af3c09e5c (r9846).

* Change references to StartProfiler.php to refer to LocalSettings.php,
  given the former is deprecated since 1.31 (I4e8dd9558132).

Change-Id: I7ca5f2deace8645f06bebd915630c1de05c84bc5
2018-08-17 16:00:45 +01:00
jenkins-bot
329a72120e Merge "resourceloader: Remove $wgResourceLoaderLESSVars support" 2018-08-15 01:24:36 +00:00
Timo Tijhof
ca510f742f resourceloader: Remove $wgResourceLoaderLESSVars support
The use of global variables was deprecated in favour of
ResourceLoaderModule::getLessVars() on a per-module basis.

Also moved testLessFileCompilation case to the appropiate file as it
covers ResourceLoaderFileModule.php, not ResourceLoader.php.

Bug: T140804
Depends-On: Ib1b2808df2384473bfac47f53a5d25d7c9bbca2b
Depends-On: I96047f69d01c4736306df2719267e6347daf556f
Change-Id: If708087c85c80355c7e78f1768529b5f2e16ed07
2018-08-14 18:57:45 +00:00
Fomafix
0a0d5cb7f7 Fix typos
Bug: T201491
Change-Id: I25a27d11faabe2f5fa02950c7a4fb58b13fb3662
2018-08-14 09:52:19 +00:00
petarpetkovic
600df4e83e Fix common typos
Bug: T201491
Change-Id: Ia5abc6ae327ee9b5aeecb4b40f00ebb0285283a9
2018-08-08 13:16:45 +02:00
Bartosz Dziewoński
7b3da79f50 Pass $title to 'GetLinkColours' hook
I think it's reasonable for link "colours" to depend on the page on
which they are shown. It seems similar to how self-links are handled.
The $colours variable is not cached, so title-specific link colours
will not "leak" to other titles.

Used in ProofreadPage in Ic910c2c33a6f1f8a70d9a122fbd2128428f29bd5.

Bug: T199288
Change-Id: I7378102a3e06544e9e695b255982c9bb0cfbf3a2
2018-07-31 05:00:00 +02:00
jenkins-bot
eadc306573 Merge "HistoryAction: Implement HistoryPageToolLinks hook for adding more links" 2018-07-26 23:20:35 +00:00
jenkins-bot
0df3355fba Merge "docs: Remove table-layout documentation from core" 2018-07-19 16:11:24 +00:00
Volker E
00096d8f4a docs: Remove table-layout documentation from core
This doesn't belong here and also doesn't make a lot of sense
with current browser support any more.
We shouldn't provide basic HTML documentation in 2018 as part of
core.

Change-Id: I1a3516e45902d16f0d9efbe97cb2dbd6efd566be
2018-07-19 14:39:34 +02:00
tinajohnson.1234
1f88334983 HistoryAction: Implement HistoryPageToolLinks hook for adding more links
This allows AbuseFilter to add an extra link in the tool links section of
the subtitle on a history page

Co-authored-by: Matěj Suchánek
Bug: T28934
Change-Id: I2e0e9e92d3fc303135b0eb9acf06b5fd120178a5
2018-07-19 11:43:43 +02:00
jenkins-bot
867349438a Merge "LogEventsListGetExtraInputs: Keep $input and add $formDescriptor" 2018-07-17 18:52:18 +00:00
Prateek Saxena
52c62c65cd LogEventsListGetExtraInputs: Keep $input and add $formDescriptor
Follows-up on Iba3c6aa5ac40dcdee0792c2d045b238b02d76521.

Bug: T117737
Bug: T199495
Change-Id: I697e158887fcca1da88763a4c929a981d9211490
2018-07-17 20:35:55 +02:00
Jack Phoenix
0ed71cb0e0 New 'OutputPageAfterGetHeadLinksArray' hook, allowing extensions to modify the return value of OutputPage#getHeadLinksArray
Code from wikiHow codebase, where this hook is used by the following extensions:
* AlternateDomain -- used to remove certain links altogether and change the contents of other elements (e.g. <meta description="..." />)
* hooks (PageHooks) -- used to hide certain links for anons on noindexed pages to avoid leaking article info to Googlebot
* QADomain -- used to remove certain elements and correct <meta keywords="..." /> tags not to mention "wikiHow" if that string is present
* search (LSearch) -- used to remove canonical URL on Special:LSearch for SEO

Change-Id: I4a9ceb343bb5c0b4eb79e4589d36c3790938f8a9
2018-07-15 02:08:16 +03:00
Jack Phoenix
358b2d1d77 Pass $opts by reference to subscribers of 'SpecialSearchPowerBox' hook to allow them to modify it
wikiHow added a new hook called 'SpecialSearchPowerBoxOpts', which was passed only &$opts, so that the Finner extension can unset the $opts array. Enhancing the pre-existing hook is a better solution in this case.

Change-Id: I091cbdc78fc779144554d8420a95435b7048c407
2018-07-14 22:42:41 +00:00
jenkins-bot
0e2e1254df Merge "Add new 'ArticleShowPatrolFooter' hook to allow extensions to decide if the [mark as patrolled] link should not be shown" 2018-07-14 22:33:29 +00:00
Jack Phoenix
72f1866b92 Add new 'ArticleShowPatrolFooter' hook to allow extensions to decide if the [mark as patrolled] link should not be shown
Used on wikiHow to simply never show this particular link.

Change-Id: Id6b11135cc062798964a6b3e927ad665fd757616
2018-07-11 11:08:48 +03:00
Prateek Saxena
38756eae46 Special:Log: Convert to HTMLForm
* All Xml generation code has been removed.

* The LogEventsListGetExtraInputs hook now needs a form
  descriptor array and not plain HTML.
  See I37e0d3e81a46239750465b9299279fbbd7c7f87a.

* LogPager and LogEventList also take the $day parameter
  for 'From date (and earlier)' and pass it to getDateCond
  as well.

* Since FormOptions can't automatically extract the date
  from the request this is being done manually in the
  execute method of Special:Log using MWTimestamp.

Bug: T117737
Change-Id: Iba3c6aa5ac40dcdee0792c2d045b238b02d76521
2018-07-10 16:55:33 +05:30
jdlrobson
89b2e1eb2c registration: Document ResourceLoaderImageModule's useDataURI option
Without these rules, validation will fail in any skin or
extension that tries to use it.

Follows-up 36252b7.

Bug: T198930
Change-Id: Iee77655d4868a7d921be8cc23776a7859d9acf0c
2018-07-10 00:23:33 +00:00
jdlrobson
8faba225fe ResourceLoaderImage module definitions can define a defaultColor
Bug: T197909
Change-Id: I0745e112d11026ed59d8daca990b313305cd094a
2018-06-27 20:36:47 +00:00
daniel
731a113aac MCR: rename $baseRevId paramter to match actual semantics.
The $baseRevId in WikiPage::doEditContent is used only to indicate what
revision an edit reverted to. It is not used to indicate the actual base
revision of an edit in any sense. Specifically, EditPage never sets it.

So, this change renames the parameter to $originalRevId to match $undidRevId.
It also renames PageUpdater::setBaseRevisionId to setOriginalRevisionId.
Further, this introduces a paramter to PageUpdater::hasEditConflict():

Before this change, PageUpdater::hasEditConflict() was based on the
revision set via PageUpdater::setBaseRevisionId(), assuming the semantics
of "base revision" used by EditPage. However, this is NOT how the $baseRevId
parameter in WikiPage works.

Bug: T197685
Change-Id: Ib78257d4d6ee7c4ec093d5706904c599b02c73e0
2018-06-22 11:57:59 +00:00
jenkins-bot
e9ed100496 Merge "docs/hooks.txt: fix incorrect description of UploadForm:* hooks" 2018-06-18 18:07:33 +00:00
Edward Chernenko
54344ac962 docs/hooks.txt: fix incorrect description of UploadForm:* hooks
Hooks [UploadForm:BeforeProcessing] and [UploadForm:initial] get SpecialUpload
object as their parameter (NOT the UploadForm object).

Also replaced obsolete note "use UploadVerification and UploadVerifyFile"
with modern "use UploadVerifyUpload".

Change-Id: I09ac5b238c8619c94978bdc771653127d3a6264d
2018-06-18 00:33:26 +03:00
Timo Tijhof
7fa718072d hooks.txt: Use "array" in a sentence instead of []
Follows-up 49806d37, which accidentally replaced this "array()"
with "[]".

Change-Id: Ib61e377cc66523aae2df2d42f7b3af2e5bf6c841
2018-06-14 23:33:27 +01:00
daniel
e8632ab0f6 [MCR] Factor PageUpdater out of WikiPage
This introduces PageUpdater to replace WikiPage::doEditContent,
and DerivedPageDataUpdater, to replace WikiPage::doEditUpdates
and WikiPage::prepareContentForEdit.

See docs/pageupdater.txt for a description of their
functionality.

MCR migration notes:

* The interface of PageUpdater is expected to
remain mostly stable after this patch. Code that has been using
WikiPage::doEditContent can be confidently migrated to using the
new mechanism for revision creation.

* This patch keeps the code inside PageUpdater largely aligned
with the old code in WikiPage, to make review easier to to avoid
mistakes. It is intended to be refactored further, moving
application logic into stateless services.

* DerivedPageDataUpdate is intended as a stepping stone for further
refactoring. Its behavior is designed to be compatible with
callback code that currently relies on
WikiPage::prepareContentForEdit. Much of the code that currently
lives in DerivedPageDataUpdate should be factored out into
services, all behavior relevant to calling code should be exposed
via narrow interfaces.

Bug: T174038
Bug: T196653
Change-Id: If610c68f4912e89af616cdcac1d35a1be3946afa
2018-06-14 13:22:13 +00:00
jenkins-bot
c451267578 Merge "Pass $parser, &$query and &$widthOption to the 'ImageBeforeProduceHTML' hook" 2018-06-13 15:31:01 +00:00
James D. Forrester
49806d3748 hooks.txt: Clean-up whitespace and wrapping for consistency
This file is a disaster, but now at least we actually wrap at 80 chars
for all the hooks, not just the ones where the developer felt like it.

Change-Id: I10d3d51412af29b135fd7e9a0393ff0b57eb25aa
2018-06-12 13:22:58 -07:00
James D. Forrester
06ac71f9a6 hooks.txt: Label which hooks are deprecated when
Many of these are still soft-deprecated, so tracking down their age
and kicking off the full deprecation process is hard, let alone
actually removing them. Doing this makes that future work easier.

Change-Id: Ib096190accceabf9082f621ba96243f7dedb025d
2018-06-12 13:22:58 -07:00
Bartosz Dziewoński
8a7b7c3f11 Remove deprecated hook EditPageBeforeEditChecks
Change-Id: I525a3a81787214dae42d3ce641d8c62761d17797
2018-06-12 01:00:39 +02:00
Jack Phoenix
088c6db48b Pass $parser, &$query and &$widthOption to the 'ImageBeforeProduceHTML' hook
This allows extensions to essentially reimplement Linker#makeImageLink
completely. Before this wasn't 100% possible as these three are needed for
that.

Inspired by wikiHow's core hacks to /includes/Linker.php, which can now be
moved to an ImageBeforeProduceHTML hook subscriber. wikiHow uses those
changes together with the WikihowArticle extension to heavily modify the
article DOM for various extensions and the default skin.

Change-Id: I8b5ab42d9cf021d66b90d15be68a0239643c10e3
2018-06-10 18:31:56 +03:00
jenkins-bot
998b8afae9 Merge "Introduce ApiMaxLagInfo hook" 2018-06-05 18:01:49 +00:00
Amir Sarabadani
5a7e9ba954 Introduce ApiMaxLagInfo hook
This will be useful when an extension does something expensive and wants to
make sure users don't put too much pressure on the system.

Bug: T194950
Change-Id: I8a396d07c2d5764a680d0e5536cd1f99edbe141e
2018-06-05 19:46:09 +02:00
Timo Tijhof
a930bf7d7b Remove deprecated global $parserMemc and wfGetParserCacheStorage
Deprecated since 1.30, no longer used in core, bundled components,
and WMF-deployed extensions.

Change-Id: I09715f94750f083712719ef599a2ea4260297681
2018-05-31 14:28:42 +01:00
Timo Tijhof
8c116df0f5 docs: Update for deprecated $parserMemc
Remove mention of this deprecated global in favour of documenting
the backend configuration instead.

Also update the outdated docs for where the sidebar is cached,
which was changed a while ago to use WANObjectCache instead.
See Skin::buildSidebar().

Change-Id: I3d34a760cc05cab6fe7ddd8684257d6ec6b49309
2018-05-31 14:25:13 +01:00
Suriyaa Kudo
b3e930c48b
Add 'Special:MyLanguage' in 'All skins' category link
Change-Id: I5f9f6c3c9151ea1570d0ec3f361af40fba8abd20
2018-05-26 16:06:02 +02:00
Bartosz Dziewoński
c513ec19ef Restore 'PreferencesForm' as alias for 'PreferencesFormLegacy'
In change 4633f4d46a it was changed
to an interface implemented by both PreferencesFormLegacy and
PreferencesFormOOUI so that existing typehints for some functions
parameter would accept them both. Replace those typehints to use
HTMLForm instead. There was really no guarantee in the past that
they would only be given PreferencesForm or its subclasses, either.

Because the typehint change affects some hooks, note it as a
deprecation in MW 1.31 and a breaking change in MW 1.32.

Also add @since tags and correct some typos in code comments.

Follow-up to 4633f4d46a.

Change-Id: I61749f1d864cf68afe90cd9e15ba2d7a74252501
2018-05-24 21:20:50 +00:00
Kunal Mehta
bf9bc2ae49 registration: Validate AutoloadNamespaces keys have trailing \
The PSR-4 autoloader requires "AutoloadNamespaces" keys to have a
trailing \ (\\ in JSON), so add a validation check for that.

Unfortunately the validation error isn't great, since it checks to see
if the property matches patternProperties, and when it doesn't, it
claims the property isn't defined since additionalProperties is false.
But it's still better than not failing when they are missing.

Bug: T189136
Change-Id: If01bd06cdd767fb704a8ff85cdf1c143e53fa4ca
2018-05-20 12:13:05 -07:00
Brian Wolff
70941efd35 Initial support for Content Security Policy, disabled by default
The primary goal here is a defense in depth measure to
stop an attacker who found a bug in the parser allowing
them to insert malicious attributes.

This wouldn't stop someone who could insert a full
script tag (since at current it can't distinguish between
malicious and legit user js). It also would not prevent
DOM-based or reflected XSS for anons, as the nonce value
is guessable for anons when receiving a response cached
by varnish. However, the limited protection of just stopping
stored XSS where the attacker only has control of attributes,
is still a big win in my opinion. (But it wouldn't prevent
someone who has that type of xss from abusing things like
data-ooui attribute).

This will likely break many gadgets. Its expected that any
sort of rollout on Wikimedia will be done very slowly, with
lots of testing and the report-only option to begin with.

This is behind feature flags that are off by default, so
merging this patch should not cause any change in default
behaviour.

This may break some extensions (The most obvious one
is charinsert (See fe648d41005), but will probably need
some testing in report-only mode to see if anything else breaks)

This uses the unsafe-eval option of CSP, in order to
support RL's local storage thingy. For better security,
we may want to remove some of the sillier uses of eval
(e.g. jquery.ui.datepicker.js).

For more info, see spec: https://www.w3.org/TR/CSP2/
Additionally see:
https://www.mediawiki.org/wiki/Requests_for_comment/Content-Security-Policy

Bug: T135963
Change-Id: I80f6f469ba4c0b608385483457df96ccb7429ae5
2018-05-13 21:01:11 -07:00
Timo Tijhof
16c8d89357 resources: Move the remaining src/mediawiki/ files
Single-file modules to src/, the remaining as sub directories.

A few highlights:
* mediawiki.Upload.BookletLayout. (stylesheet: no image references)
* mediawiki.feedback - Also move the image to its own images/ subdir.
* mediawiki.searchSuggest. (stylesheet: no image references)
* mediawiki.toc. (stylesheet: no image references)

Also updated any other references to 'src/mediawiki/' that I could find
in core:
* Fixed references in docs/uidesign/*.html
* Remove redundant exclude from jsduck.json.

After this, there are 4 files remaining in src/mediawiki,
which are the 4 files used by the actual 'mediawiki' base module.

Bug: T193826
Change-Id: I8058652892a78b3f5976397bd850741dd5c92427
2018-05-09 23:44:22 +01:00
Umherirrender
e1a203603c Replace wfGetLB
@deprecated since 1.27

Change-Id: Ibdd49fdfc0d1511503e1ed2173a592c612996c53
2018-05-02 22:30:24 +02:00
Brad Jorsch
3f1142045f Generalize ResourceLoader 'excludepage' functionality
There has long been a hack for previewing edits to user JS/CSS, where
OutputPage would pass an 'excludepage' parameter to
ResourceLoaderUserModule to tell it not to load one particular page and
would instead embed that page statically. That's nice, but there are
other places where we could use the same thing.

This patch generalizes it:
* DerivativeResourceLoaderContext may now contain a callback for mapping
  titles to replacement Content objects.
* ResourceLoaderWikiModule::getContent() uses the overrides, and
  requests embedding when they're used. All subclasses in Gerrit should
  pick it up automatically.
* OutputPage gains methods for callers to add to the override mapping,
  which it passes on to RL. It loses a bunch of the special casing it
  had for the 'user' and 'user.styles' modules.
* EditPage sets the overrides on OutputPage when doing the preview, as
  does ApiParse for prop=headhtml. TemplateSandbox does too in I83fa0856.
* OutputPage::userCanPreview() gets less specific to editing user CSS
  and JS, since RL now handles the embedding based on the actual
  modules' dependencies and EditPage only requests it on preview.

ApiParse also gets a new hook to support TemplateSandbox's API
integration (used in I83fa0856).

Bug: T112474
Change-Id: Ib9d2ce42931c1de8372e231314a1f672d7e2ac0e
2018-04-25 00:37:08 +00:00
Aaron Schulz
19b71ac216 rdbms: remove deprecated getLaggedSlaveMode() method alias
Change-Id: Iecdd39270d27ee1a2f9e1d714ec02c710fa241ef
2018-04-23 12:57:10 -07:00
James D. Forrester
de6dab71e3 Remove $wgScriptExtension (deprecated and ignored since 1.25)
* Remove left-over mention of the .php5 entry points in docs.

* Remove dead logic in NoLocalSettings for php5 entry points.

* Remove dead match in WebRequest for php5 entry points (they'd
  redirect since 1.25, and not seen by PHP).

Change-Id: Ia0ee8588591860b8fe34030c8503f38e9bce31f3
2018-04-19 01:11:23 +01:00
Timo Tijhof
cec597e2b3 resourceloader: Remove deprecated ResourceLoaderGetLessVars hook
Deprecated since 1.30, only had one caller (MobileFrontend)
which has been fixed since.

Bug: T140804
Change-Id: I39b594e3082ebe321bae463780cfadbfb3de1d5c
2018-04-10 15:11:00 +01:00
jenkins-bot
25e6d74443 Merge "installer: Add support for PlatformSettings.php" 2018-04-10 02:59:07 +00:00
Kunal Mehta
50212e6d0e installer: Add support for PlatformSettings.php
PlatformSettings.php is a standardized and recommended way for
re-distributors and packagers of MediaWiki to be able to tune
DefaultSettings.php as appropriate.

If includes/PlatformSettings.php exists, the installer will
automatically include it as part of the generated LocalSettings.php.

The main advantage of this system is that if the distributor wants to
change the default settings, all users will benefit immediately. And if
people want a vanilla MediaWiki experience, they can just remove the
inclusion from their LocalSettings.php.

This RfC
(<https://www.mediawiki.org/wiki/Requests_for_comment/PlatformSettings.php>)
was approved by TechCom.

Bug: T182020
Change-Id: I34f9a4acbe86b9c5c80ac16451b317ce5f6640f9
2018-04-10 02:51:02 +00:00