Commit graph

212 commits

Author SHA1 Message Date
Daimona Eaytoy
947ff7c0f5 build: Update mediawiki/mediawiki-phan-config to 0.12.0
This patch only adds and removes suppressions, which must be done in the
same patch as the version bump.

Bug: T298571
Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
2022-10-08 15:45:42 +02:00
jenkins-bot
6dd43ac12e Merge "WebInstaller::infoBox(): Remove extra indenting" 2022-10-05 20:12:26 +00:00
Reedy
97bb2def38 WebInstaller::infoBox(): Remove extra indenting
Change-Id: I52fec30d0c1907f497f58b0cc3f0950e5d724ad8
2022-10-05 00:39:39 +01:00
Reedy
1cc60bba83 WebInstaller: Don't try and run trim() on null
Bug: T319000
Change-Id: I12142ccfe22f1c1776f2364f8c154cbd69800739
2022-10-05 00:31:41 +01:00
Umherirrender
5c5498a202 Remove unused key variable from foreach loops
Change-Id: Id2d91e30a6f7cc4eb93427b50efc1c5c77f14b75
2022-09-21 21:18:43 +02:00
daniel
5fcedc88c9 Add wiki-farm support
Added support for an easy to configure multi-tenant ("wiki farm") mode:
Settings for each site can be placed in a directory specified by
$wgWikiFarmSettingsDirectory. Site detection is controlled by
$wgWikiFarmSiteDetector and defaults to the requested host name.

Instructions for manual testing: https://etherpad.wikimedia.org/p/T221535

Bug: T221535
Change-Id: I7581921b7d99ba1fe7e25523fde691d76b67a99c
2022-04-01 14:29:22 +02:00
Umherirrender
1f71eccf63 phan: Disable null_casts_as_any_type setting
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
2022-03-21 18:25:07 +00:00
Umherirrender
19925ef026 Add various fallback values for null return values
Found by phan strict checks

Change-Id: I83187b5fd25b015d2c75e22d4b5202803653d743
2022-03-09 20:15:36 +01:00
jenkins-bot
b8fc033e34 Merge "installer: Fix docs for getInfoBox/label" 2022-02-26 22:08:38 +00:00
Umherirrender
b126dbe3f2 Fix various documentation related to null types
The functions returning null or the class property is set explict null

Found by phan strict checks

Change-Id: I4a271093fb6526564d8083a08249c64cb21f2453
2022-02-26 10:31:24 +01:00
Umherirrender
f721b5f3b1 installer: Fix docs for getInfoBox/label
The $class in getInfoBox cannot default to false, because there is no
check for false. It just ends in an implode(). The empty string is also
the default for the called self::infoBox

Found by phan strict checks

Change-Id: I04586c7dc0b32b9eaf01b86a6789b30931d606fb
2022-02-26 08:15:50 +00:00
Daimona Eaytoy
32c86a2621 installer: Various tweaks for taint-check
Taint-check really doesn't like assigning things from $GLOBALS this way,
because it knows that stuff inside $GLOBALS can be tainted (e.g.
$GLOBALS['_GET'], $GLOBALS['_POST']), and since it cannot determine
which key is used in the assignment, it assumes that it's tainted.
As such, the new code patch generates the default values in a separate
method, whose return value is annotated as safe, so taintedness from
$GLOBALS doesn't get into $this->settings.

Also annotate getAcceptLanguage() as untainted, since the raw values
from the HTTP header are matched against a list of known codes.

Change-Id: Ifc44d3703d505962e3b07db7613b5bbf5e448320
2022-02-10 11:25:53 +01:00
Alexander Vorwerk
3aa5b6643b Use LanguageNameUtils constants instead of strings
Change-Id: I8521d00675008da0d7c8c768ab75352212653c66
2021-12-05 22:13:34 +01:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
Kevin Israel
c82d3a8632 Installer: Fix mediawiki-announce auto subscription code
This new version of the auto subscription code works with Wikimedia's
Mailman 3 installation. It follows the existing approach of sending a
POST request to the same URL that a web browser would, rather than
introducing a new API. I did add a check for the expected success
message, as well as two types of "duplicate request" failures I would
expect to occur fairly often.

No attempt is made to pass the user's language to Mailman 3, since its
web interface for list management (Postorius) does not seem to allow
selecting a language for anonymous requests. (While the Accept-Language
header does have an effect within Postorius, it does not seem to affect
the messages coming from Mailman Core, including confirmation emails.)

Because the WebInstaller and CliInstaller classes are not documented as
stable to extend (even though it is documented that packagers should
override them instead of altering the original files), the list of
supported language codes is removed without deprecation.

Bug: T281549
Change-Id: Ib4cf03597e9c9b8408c9ca076c2c7cc3cabb5cfc
2021-08-29 07:49:58 -04:00
Umherirrender
864068d000 Remove unneeded explicit true/false inside conditions
The non-strict conditions in if/while are true/false without the check.

In some situation the true/false is removed, because it is known to be a
bool (by is_bool check or type hint)

Change-Id: I5ca4c4771af25d2e785e82732df204a73653886e
2021-08-17 21:52:34 +02: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
James D. Forrester
bdddfb92ba Drop wgContLang, deprecated in 1.32
Bug: T245940
Depends-On: Ib7fe7318100c0aadc3aa759416bf787913a9b788
Change-Id: I75c3b6715abd5eaf3619337cab8b1844e9a8349a
2021-03-08 13:27:28 -06:00
Umherirrender
e9e784a09e build: Enable phan-taint-check-plugin and suppress issues
Taint check checks for possible security issues by tracking html
escaping and more by using phan.
This slows done the phan-job a bit and requires more ram

Keep the DoubleEscaped issues out to make reviewer easier

Adds suppression for false positives
Adds taint-annotation to help taint-check
Removes suppression for code phan now understand better by the tracking
of keys in taint-check
Fix some small issues by adding int cast or htmlspecialchars calls

Bug: T216348
Bug: T268920
Change-Id: I849ac4f120fd15b483e8939d4db45c98dc351259
2020-12-30 19:02:22 +01:00
Ammar Abdulhamid
388391eacf Move Html::infoBox logic to WebInstaller
Bug: T268078
Change-Id: I5923f8402dfab435e29b40484884ae9053c24564
2020-11-19 09:03:20 +01:00
Timo Tijhof
e03e870421 installer: Remove deprecated getWarningBox() and getErrorBox()
Bug: T232903
Change-Id: I9cd32a87b15f8006b9277e6a45282c0b36907e68
2020-07-29 01:19:00 +01:00
Kunal Mehta
597c514547 installer: Undeprecate WebInstaller::getInfoBox(), still used
getInfoBox() is still widely used in the installer itself and shouldn't have
been hard deprecated in the first place. There's also no proposed replacement
documented, unlike the other *Box functions that were deprecated at the
same time.

Also update HISTORY to reflect backing out this deprecation.

This follows up d6ed082b6d.

Bug: T232903
Bug: T257997
Change-Id: I2ea8d1fd49a87ce4eb0382744312c7ffaefa5f81
2020-07-14 15:50:39 -07:00
Tim Starling
9ba8f8d124 In the web installer, use secure session cookies
When starting a session when the detected protocol is HTTPS, use
cookie_secure=1 so that the session cookie has the secure attribute.

Without the secure attribute, a CSRF attack could be used to send
cookies over an insecure channel, leaking the session ID to an attacker
with network access.

Change-Id: I1a4b612425a16da1a7a8fd855f376a377b0b48d7
2020-06-25 16:10:41 +10: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
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
jenkins-bot
0ca286a1cc Merge "installer: Parse error message" 2020-02-18 20:52:10 +00:00
Tobi_406
6d88beee07
installer: Parse error message
Use $msg->useDatabase( false )->parse() instead of $msg->useDatabase(
false )->plain() to parse wikitext.

Bug: T238464
Change-Id: Ie75a53afd801c506935719e6290999ec040723c5
2020-02-18 21:02:01 +01:00
Petr Pchelko
204fa7e509 Remove usages of deprecated Language methods
Change-Id: Iad3375b141b1d87c890baec6ecd16ed92f93e699
2020-02-16 00:45:48 +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
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
Volker E
d6ed082b6d installer: Deprecate WebInstaller::getInfoBox, getWarningBox and getErrorBox
Since MW 1.31 there are messageBox, warningBox, errorBox and successBox
available which should be used instead.

These are simple wrappers around Html::messageBox and related methods
which should be used directly instead. Internal usage has been migrated
as of a9252abb1c, but these public methods remain for now. Once
removed we can also removed the internal Html::infoBox() method.

Bug: T232903
Change-Id: I2756c88987754c4e3f84d98c531d8396098cd7fe
2019-09-26 19:26:33 +00:00
Volker E
a9252abb1c Replace infobox usages and extend successbox, warningbox and errorbox
Adding optional $className parameter to provide additional
styling options.
Optional parameter $heading was introduced for MobileFrontend. Therefore
leaving inconsistent parameter order is necessary for the time being.

Bug: T232903
Change-Id: I5857b2c58a47a83156c32f086a73fe2bd48ab0c8
2019-09-24 16:29:32 -07: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
1b60564ce7 installer: Remove <doclink/> parser function and last use of it
Pass the url to the Copying page as a message parameter instead.
This results in identical text and styling. Not even "external link"
vs plain link styling difference, because that doesn't exist in the
installer stylesheet.

The message is renamed in this commit because it is a breaking
change (due to <doclink> being removed, and due to $2 being
required).

Bug: T227297
Change-Id: I73efd9ecb193523a7e384a7a40c768d32b2361b8
2019-07-18 01:29:12 +01: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
Timo Tijhof
95c468f778 installer: Convert <downloadlink/> hack to raw message param
Bug: T227297
Change-Id: I9a50342aa0c9525893085e1b8d428556f0262f5c
2019-07-05 18:26:43 +00:00
Timo Tijhof
51e00a4f26 installer: Fix Html::infoBox param docs and mark as internal
This method is very specific to the installer and is only used in one
place, in WebInstaller, and should probably be moved there.

For now, make its documentation less confusing, more correct, and
mark it as `@internal`, this is not a supported public interface.

Bug: T227297
Change-Id: I8902fe34b80c5152bfd37e9c24427ad48b5f4167
2019-07-05 18:26:18 +00:00
Fomafix
1dc40b1cb3 Installer: Use HTML/CSS instead of JavaScript to toggle the help message
Changes in the behavior:
* The expanding/collapsing now works even with disabled JavaScript.
* There is no FOUC on loading anymore.
* The animation on show/hide is absent.

Change-Id: I1b88d8e2cdbb1c969670a7a8637dba10bf447330
2019-06-15 12:29:07 +02:00
Aryeh Gregor
7b4489e019 Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints.  This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases).  As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User.  If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args().  Some of the changes are definitely safe, like
functions and test classes.

In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:

* Forwarding all arguments to another function. It's useful to keep
  func_get_args() here where we want to keep the list of expected
  arguments and their meanings in the function signature line for
  documentation purposes, but don't want to copy-paste a long line of
  argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
  arguments individually but want to use them as an array as well for
  some reason.

Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2019-04-12 20:17:01 +00:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Derick Alangi
3d662e93a2 installer: Replace the use of global $wgParser with services
global $wgParser was deprecated in 1.32 and services are used
instead to get the parser object via MediaWikiServices. Making
this replacement as we're avoiding globals.

Change-Id: I967a52c481bfcc83552053a03e88acb038810828
2019-03-03 15:05:16 +01:00
C. Scott Ananian
873c89fcc4 Only expand {{...}} in messages once (part 2)
If we're going to call `OutputPage::addWikiTextAs*` or
`OutputPage::parseAs*` to parse the message, we don't need to
pre-expand `{{...}}` markup before passing it to the parser.

Follow up to I2f68f73365df876e6f9d017e4e3ddea39c4a1284.

Bug: T206574
Change-Id: I0ee493207ea80c1caba7e60a31714805dc54c64e
2018-10-26 17:09:42 +00:00
Fomafix
43244db9a2 Use PHP 7 '??' operator instead of if-then-else
Change-Id: If9d4be5d88c8927f63cbb84dfc8181baf62ea3eb
2018-10-21 21:46:46 +02:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
Brian Wolff
89b21847e1 Start working on phan-taint-check warnings. Fix minor escaping issues.
This fixes 26 of the phan-taint-check warnings on MW core. Some
are outright fixed, others are false positives that were suppressed.

This really only covers some of the easy ones. There are still
314 warnings to go.

Change-Id: I30463bc3a09fd4324d190de8533f51784764dd3a
2018-07-12 03:26:59 +00:00
jenkins-bot
285134ac56 Merge "Web installer: Correctly escape U+00A0 NO-BREAK SPACE" 2018-07-09 04:26:42 +00:00
Kevin Israel
7a4df753fd Web installer: Correctly escape U+00A0 NO-BREAK SPACE
Unicode escape sequences cannot be used in single quoted strings,
in which they are treated as literal text.

Follows-up 125cbd8c01.

Change-Id: Ife53a613a801b8bb96542b42fd3d2bb3dccaf629
2018-07-08 23:16:22 -04:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Fomafix
125cbd8c01 Use \u{00A0} instead of &#160; or &nbsp;
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities &#160; or &#xa0; or &nbsp;.

With the UTF-8 character the generated HTML is shorter and better to read.

Also change the special value for the label in HTMLForm from &#160; to
U+00A0 but also support &#160; for backward compability.

Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
2018-06-24 01:20:13 +00:00