Commit graph

1736 commits

Author SHA1 Message Date
Roman Stolar
6ebaa5caf6 Remove the fallback for create rights (covered in PM edit rights check).
Remove key to i18n message, no longer being used.

Bug: T272079
Change-Id: Id6566e5241b06ba377c2eca083221ee02556365f
2021-06-30 17:30:30 +03:00
DannyS712
30c10a2e8d Remove unneeded title casts
Parser::parse() accepts PageReference, and
WikiPage::factory() accepts PageIdentity

Change-Id: If8d15863045d7690fd6d965341ec8564d50db2d7
2021-06-07 13:36:03 +00:00
Mark A. Hershberger
e4a95b9b82
Stop logging and md5'ing if the file does not exist
Also bring this more in line with CSSMin::remapOne()

Bug: T283387
Change-Id: Iea5e68f48be96fae5b5640fe26c2095ca5196e88
2021-05-21 14:31:17 -04:00
daniel
fd2a9bf4a4 resourceloader: Remove Title from public interfaces
Bug: T278459
Depends-On: I9bc371fd299e7a5401ebc1b8d7456d9a4ecde90d
Change-Id: Ib3a0591766f873492ec5a24721e7840f4e1a6407
2021-05-13 10:06:30 +02:00
mainframe98
c87462097c Don't use classes error, success and warning outside parser
Bug: T280766
Change-Id: I83f2828bcde160c98a1d97e783a869e64fb4c6ea
2021-04-27 17:11:14 +02:00
daniel
c1eb74603a Remove Title from public interface of OutputPage
Bug: T278459
Change-Id: If455682540faf8d42fd8a14e0ef09bac24f72db4
2021-04-16 10:01:56 -07:00
mainframe98
20fc80577b Rename $wgSlaveLagWarning and $wgSlaveLagCritical to match DB_REPLICA
These are now named $wgDatabaseReplicaLagWarning and
$wgDatabaseReplicaLagCritical, respectively.

Bug: T277987
Change-Id: I62d8c2028fdfee00904f1058f8387499f2b2e977
2021-03-21 17:58:15 +00:00
jenkins-bot
7cc9b84af9 Merge "Convert second batch of special pages to authority" 2021-03-08 22:33:53 +00:00
Ammar Abdulhamid
242b9b2f6a Enforce concealment of hidden RelevantUser at Skin level
Skin is what takes a user or extract it from a title to set relevant
user and so this is the right place to handle permission check too
because if the user is hidden, it should be made known for all
callers, instead of hoping each caller will do similar check
which is duplication and not guranteed.

Skin:setRelevantUser always takes user and this is now typehinted to
avoid errors. Callers need to give what's required.

Bug: T120883
Change-Id: I177cd83a9c4f87c27a63d8f530c40895d0f3f5dd
2021-03-08 15:38:07 +01:00
Petr Pchelko
bfa145fae7 Convert second batch of special pages to authority
Depends-On: Ifc82d29a00d3fd136c44e0699e6bbfa11b8cf2a6
Change-Id: Iaf559a72cc47ec5d2481d7f740ad0eb303c94002
2021-03-04 15:37:59 -07:00
Petr Pchelko
244bbc8edc OutputPage: move to authority where relevant
Change-Id: Iae42cc747f80cb0215f862d633e9af32fc7c8571
2021-03-04 08:55:20 -07:00
Timo Tijhof
26c9849330 docs: Fix 'dependant' typos
The intended word in all these cases was the adjective "dependent".

Whilst the "dependant" does exist, it is a noun and generally
refers to a person. The word is rare used in general, but
especially so in a technology context.

Change-Id: Ic7e2d2ea6a566f4139ff1fdb77f38b0e962ccd9c
2021-02-18 16:59:20 +00:00
jenkins-bot
5ea464b234 Merge "Use static closures where safe to use" 2021-02-14 23:05:48 +00:00
Ammar Abdulhamid
e78de41070 OutputPage: Make $wgDebugRedirects work again
This was broken by I2dd2b71.

In that patch MediaWiki::outputResponsePayload() was introduced and it
added another output buffer layer on top of Outputpage::output( true )
which directly outputs and return empty string if $wgDebugRedirects is
true (and the location is redirect).

Because Outputpage::output( true ) returns empty string in that case,
the output buffer started by MediaWiki::outputResponsePayload() will
always end up with empty string, and the print() in Outputpage cannot
send the output because it's now nested inside another buffer layer
with call to ob_end_flush(), which discards contents of inner buffers.

Previously it worked because the return value of Outputpage::output()
was not wrapped in another output buffer then, so the direct print of
the html was enough to make it work.

This patch modified Outputpage::output() to return the html string if
$wgDebugRedirects is on, and return value is requested --instead of
outputting it-- that way the debug html will now be captured in the
topmost buffer layer inside MediaWiki::outputResponsePayload()

Bug: T236639
Change-Id: Ibe4e771b0530b7c6bb7132c88c8455b0ef4fde0e
2021-02-12 03:35:53 +00:00
Umherirrender
8de3b7d324 Use static closures where safe to use
This is micro-optimization of closure code to avoid binding the closure
to $this where it is not needed.

Created by I25a17fb22b6b669e817317a0f45051ae9c608208

Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
2021-02-11 00:13:52 +00:00
Umherirrender
9cb5f24bb8 Replace deprecated function in OutputPage
Now mocking LanguageConverter

Change-Id: I25f2f90d8dcf2cb09429e01873f1982dca199976
2021-02-05 02:17:36 +00:00
Umherirrender
47cc4da6d7 Remove unneeded @return documentation
Change-Id: If79d2126cc1b6a6e9876a972c9560d045de42ff6
2021-01-25 19:44:27 +01:00
Ppchelko
bdb5f394d3 Revert "Enhance GroupPermissionsLookup and use it."
This reverts commit 900c6663b0.

Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice.

Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
2021-01-12 04:48:49 +00:00
Petr Pchelko
900c6663b0 Enhance GroupPermissionsLookup and use it.
Added new methods:
- ::getGroupsWithAnyPermissions
- ::getGroupsWithAllPermissions
- ::groupHasAnyPermission
- ::groupHasAllPermission

Replaced relevant calls to PermissionManager with
calls to GroupPermissionsLookup.

Bug: T254537
Change-Id: I0b9c3352c5bebc94e1649239fe0527144e7c2eb2
2021-01-11 11:05:54 -06:00
James D. Forrester
abdc94a3da Swap out uses of User->isLoggedIn() with ->isRegistered()
Bug: T270450
Change-Id: I90ff94a553ebae9a4ef97c25c333f067f19c327d
2020-12-22 03:13:37 +00:00
DannyS712
f4e21014ce Deprecate a bunch of global functions
* wfAcceptToPrefs
* wfClearOutputBuffers
* wfConfiguredReadOnlyReason
* wfDebugMem
* wfGetPrecompiledData
* wfNegotiateType

Bug: T264976
Bug: T264979
Bug: T264981
Bug: T264983
Bug: T264984
Bug: T264985
Change-Id: Ia05bc84e4d1be7c8a02472f32e2c009e4bb32032
2020-12-18 21:34:50 +00:00
DannyS712
b5e7f210cd SECURITY: Act like users don't exist if hidden from viewer
When viewing Special:Contributions for a hidden user and
a missing user, or the user page of a hidden user and a
missing user, if the viewer cannot see hidden users
the output should be the same for hidden users and
missing users.

To that end
* In OutputPage.php, only set the `wgRelevantUserName` javascript
  variable if the user is not hidden, or the viewer can see hidden
  users
* In Article.php, show the `userpage-userdoesnotexist-view` on user
  pages of hidden users if the viewer cannot see hidden users
* In Skin.php, do not add user-specific sidebar links (contributions,
  logs, mute, etc.) if the user is hidden and the viewer cannot see
  hidden users
* In SpecialContributions.php, stop calling Skin::setRelevantUser
  for non-existing users, so that callers of Skin::getRelevantUser
  can ignore users that are hidden from the viewer without creating
  divergent behavior
* In SpecialContributions.php, for users that do exist but are
  hidden from the viewer, don't show `sp-contributions-footer`,
  but do show `contributions-userdoesnotexist`

Bug: T120883
Change-Id: I83b723402f315447bc4b50992e28620e3daace8f
2020-12-18 00:35:54 +00:00
C. Scott Ananian
c64e71615e Replace $wgDisable{Lang,Title}Conversion with LanguageConverterFactory methods
Replace direct access to $wgDisableLangConversion with
LanguageConverterFactory::isConversionDisabled(), and replace direct
access to $wgDisableTitleConversion with
LanguageConverterFactory::isTitleConversionDisabled().  However, most
places that check ::isTitleConversionDisabled() actually want
::isLinkConversionDisabled(), so add that too (and deprecate
isTitleConversionDisabled()).

Code search:
https://codesearch.wmcloud.org/search/?q=Disable%28Lang|Title%29Conversion&i=nope&files=&repos=

This change removes a number of spurious dependencies on the global
configuration and reduces code duplication (for example, if the logic
for disabling language conversion were ever to change).

Depends-On: I6fa8230ae97b0e34c381003548e61f9b7387d363
Change-Id: Icc4687638ff1815003dd903854efdbd904854f1e
2020-11-25 12:47:26 -05:00
jdlrobson
d11cb401d6 Deprecate the use of Skin::setupSkinUserCss to alter the internal array of styles
Check the internal array of styles to determine whether
the method was inappropriately used to alter the array of styles and
if it was, call wfDeprecatedMsg().

Change-Id: I591b03c2e19d4b8cadfe220b498ae244d332f9fb
2020-11-24 10:49:09 +11:00
Tim Starling
e9608cc17d Revert "Deprecate Skin::setupSkinUserCss"
The commit did not really hard-deprecate overriding of setupSkinUserCss() as stated in the commit message, rather it removed core calls to setupSkinUserCss(), instantly breaking the many skins that still override it. It did not actually create a deprecation period for graceful migration.

As discussed in T267080, there is presently no way to hard-deprecate the override of a method.

This reverts commit 334cfeffd6.

Bug: T257990
Change-Id: I8f669ba30affc437800890c3a875994a9f2eb3c8
2020-11-24 10:03:11 +11:00
jenkins-bot
1976283835 Merge "Update a lot of unspecific "array" types in PHPDocs" 2020-11-13 21:48:24 +00:00
jenkins-bot
32fed9c635 Merge "resourceloader: Remove wfExpandUrl() coupling from CSSMin" 2020-11-13 07:07:49 +00:00
jenkins-bot
b8f3822d52 Merge "Reduce some references to $wgUser" 2020-11-09 14:53:37 +00:00
Brad Jorsch
cd54c03e86 resourceloader: Remove wfExpandUrl() coupling from CSSMin
There are three cases in CSSMin::remap where performs path
resolution.

1. Absolute local path URLs to full URL.
   Example: url(/static/foo.png), url(/w/index.php?…), etc.

   These previously used wfExpandUrl(), which got the server
   name and protocol directly from $wgServer.

   We will now use the $remote parameter to get this information
   instead, which is generally set to something like
   https://wiki/w/resources/foo, and thus naturally contains
   the server name and protocol.

   The resolution is powered by the Net_URL2 library, allowing
   this to work outside Mediawiki as well.

   Some tests needed to change because they were calling CSSMin::remap
   with an incomplete $remote dummy values like "/" or "/w, because
   the test author (past me) was trying to be clever by not supplying
   it, knowing MW would ignore it. Now that it is consistently used,
   like normal calls from ResourceLoader would, the expected values
   will always be based on http://localhost/w, instead of sometimes
   the competing $wgServer value of `https://expand.example`.

2. Relative local path to full URL
   Example: url(foo.png), url(../foo.png), url(bar/foo.png)

   These were already using $remote. The only change is that
   they now use Net_URL2 library instead of blind string
   concatenation. One of the benefits of this is that we will
   no longer need to call wfRemoveDotSegments() to get rid
   of things like double slashes or redundant "../" sequences.
   Previously, thing like "foo//bar" or "foo/../bar" were cleaned
   up only due to wfRemoveDotSegments(). This is now naturally
   handled by Net_URL2.

3. Remote URLs
   Example: url(http://example.org/bar.png), url(//example.org/bar.png)

   This is generally not used in source code, but gadgets may use this,
   e.g. for upload.wikimedia.org or cross-wiki imports.

Other changes:

* One test case used spaces within the URL string in CSS, which the
  net_url2 library represents with percent-encoding instead.
  Same thing either way.

Bug: T88914
Change-Id: Ibef70cc934c0ee8260a244c51bca9fb88c1c0d88
2020-11-05 19:59:02 +00:00
Tim Starling
5ada7df93e Log the reason for private caching
In OutputPage::sendCacheControl(), break up the multi-line conditional
and include in the debug log message the reason for private cache
headers being sent. I think this improves the readability of the code.

Change-Id: I0229e04c44771245b7ac8cd45d2c83062a4d78f2
2020-11-05 13:12:42 +11:00
jenkins-bot
929381a81f Merge "Use LinkBatchFactory" 2020-11-01 20:48:02 +00:00
Umherirrender
c85a43561e Improve class property documentation
Reformat existing documentation to match the format

Change-Id: I190b54b5e962f17bab6502dd1b3c02f11dc926d2
2020-10-30 10:38:58 +01:00
Thiemo Kreuz
b0130ca649 Update a lot of unspecific "array" types in PHPDocs
This includes fixing some mistakes, as well as removing
redundant text that doesn't add new information, either because
it literally repeats what the code already says, or is actually
duplicated.

Change-Id: I3a8dd8ce57192deda8916cc444c87d7ab1a36515
2020-10-28 11:01:33 +01:00
Thiemo Kreuz
1fc8d79ac6 Remove documentation that literally repeats the code
For example, documenting the method getUser() with "get the User
object" does not add any information that's not already there.
But I have to read the text first to understand that it doesn't
document anything that's not already obvious from the code.

Some of this is from a time when we had a PHPCS sniff that was
complaining when a line like `@param User $user` doesn't end
with some descriptive text. Some users started adding text like
`@param User $user The User` back then. Let's please remove
this.

Change-Id: I0ea8d051bc732466c73940de9259f87ffb86ce7a
2020-10-27 19:20:26 +00:00
Umherirrender
973c562927 Use LinkBatchFactory
Change-Id: Ib82f91048faad8cf8be961d038f30c9261072af5
2020-10-25 23:21:42 +01:00
ArtBaltai
e7dbd69de0 Hard deprecation of Language::convertTitle(),
::findVariantLink(), ::updateConversionTable()

Co-authored-by: C. Scott Ananian <cananian@wikimedia.org>
Bug: T226832
Change-Id: I41a3b67490fc6b9d4c484f566d346a0d10c670e9
2020-10-20 16:49:17 -04:00
DannyS712
cf5fd868cd Reduce some references to $wgUser
Should be a no-op

Bug: T243708
Change-Id: I7b204cdc629c6c33e6a84b5c7a4e0e7ac321f19d
2020-10-13 15:07:27 +00:00
Umherirrender
7c539e9c72 Avoid null query in Skin::lastModified
For action=history there is a query:
SELECT rev_timestamp FROM `revision` WHERE rev_id IS NULL LIMIT 1
to generate the footer links

Change-Id: I8b0f30f874eb73544693dff9d12d45585bd9a110
2020-08-18 13:41:53 +02:00
Timo Tijhof
274c4232b9 mediawiki.page.startup: Merge with mediawiki.page.ready module
The distinction between the two was lost several years years ago
when the "position top" queue ceased to be a thing. Since then,
the two have been loaded and executed together in the same batch,
and are doing similar things.

mediawiki.page.ready is publicly used in several places
as dependendency, but mediawiki.page.startup is entirely internal
to core, which makes it the easier one of the two to dissolve.

Keep an alias for two weeks for cache compat to avoid console
warnings about unknown modules. Although even some cache still
refers to it, this is harmless since the errors are recoverable
and the correct module was also loaded by the cached pages
already.

Bug: T260210
Change-Id: Ic418c23a7400abba22fd07b17f173d3c5f1d1d10
2020-08-14 01:35:15 +00:00
Ammar Abdulhamid
334cfeffd6 Deprecate Skin::setupSkinUserCss
Bug: T257990
Depends-On: I132513a897e40162acd973b9817b3103f4a33333
Depends-On: I363f8c9e39298ab9f74274d288681f2ef88a1894
Change-Id: I13bedd8c14de419ff1a88d5087f5669652cd3123
2020-08-09 02:09:08 +01:00
mainframe98
204ddf0522 Skin: Add a skin option for responsiveness
Skins can now specify responsive in the skin option, which will add
a meta tag with the value width=device-width, initial-scale=1.0,
user-scalable=yes, minimum-scale=0.25, maximum-scale=5.0.
If responsiveness is not constant, but based on, for example, a
user preference, then skins can override isResponsive to indicate
when the skin is responsive.

When enabled, it will also add the skin--responsive class to <body>.

Bug: T258290
Change-Id: I6e69b482cdbc49c09adc6f7cee54f5e17b7c92c4
2020-08-04 10:31:09 +00:00
Ed Sanders
7683f7d839 Use strict (in)equality with namespaces constants when LHS is definitely an integer
Change-Id: I8fede00dfe1270d93c5d78d3c36e788cddfc8a99
2020-07-31 18:03:28 +01:00
Amir Sarabadani
5fb5dab231 Drop html5shiv
According to T248061 the basic support for IE8 is gone now meaning we
don't need to serve the snippet for html5shiv anymore.

Also dropping the html5shiv code.

Bug: T248061
Change-Id: I1a8dbd72ae68f518f52a76a80a3b54239720d20c
2020-07-21 11:11:08 +00:00
Timo Tijhof
1e82b201c1 OutputPage: Use @unstable instead of @internal for addHtmlClasses()
Follows-up 9d3254d18e.

Methods using @internal are designed for use internal to the component
that defines the method, and are generally considered safe to remove
anytime if they are unused.

This method however is not for internal use, it is designed for public
use (nothing in core needs it), but we're not yet ready to commit
to it being a stable API that would receive no breaking changes or
be removed without deprecation.

The appropiate tag for such experimental feature that allows early
adoption (with caution, knowing it might get renamed, moved or dropped
in the next major release) – is @unstable.
<https://www.mediawiki.org/wiki/Stable_interface_policy>

Bug: T247862
Change-Id: Iceaaf520979afa1c3ee806262083f94d67660174
2020-07-02 02:04:02 +01:00
jenkins-bot
cd91918405 Merge "Revert "OutputPage: Temporary hack to avoid taint-check crash"" 2020-06-26 16:25:56 +00:00
Daimona Eaytoy
a77226d105 Revert "OutputPage: Temporary hack to avoid taint-check crash"
This reverts commit dad17c82da.

Reason for revert: now working with newer taint-check.

Change-Id: I394c04b5583f718d5d809fdd15ae723b1564d551
2020-06-26 09:33:33 +00:00
jenkins-bot
a7dae830b3 Merge "Introduce wfDeprecatedMsg()" 2020-06-22 22:30:49 +00:00
jenkins-bot
a0559c63c6 Merge "Deprecate using Skin method to add body attributes." 2020-06-22 21:23:10 +00:00
Tim Starling
d459add63d Introduce wfDeprecatedMsg()
Deprecating something means to say something nasty about it, or to draw
its character into question. For example, "this function is lazy and good
for nothing". Deprecatory remarks by a developer are generally taken as a
warning that violence will soon be done against the function in question.
Other developers are thus warned to avoid associating with the deprecated
function.

However, since wfDeprecated() was introduced, it has become obvious that
the targets of deprecation are not limited to functions. Developers can
deprecate literally anything: a parameter, a return value, a file
format, Mondays, the concept of being, etc. wfDeprecated() requires
every deprecatory statement to begin with "use of", leading to some
awkward sentences. For example, one might say: "Use of your mouth to
cough without it being covered by your arm is deprecated since 2020."

So, introduce wfDeprecatedMsg(), which allows deprecation messages to be
specified in plain text, with the caller description being optionally
appended. Migrate incorrect or gramatically awkward uses of wfDeprecated()
to wfDeprecatedMsg().

Change-Id: Ib3dd2fe37677d98425d0f3692db5c9e988943ae8
2020-06-22 14:34:39 +10:00
Ammar Abdulhamid
18263d95b8 Deprecate using Skin method to add body attributes.
- Remove the parent method. There's no skin that's relying on this method
directly and since it's no-op declaration, removing it is also no-op.
- Raise deprecation warning if the body attributes are modified with the
method (as implemented by the relevant skin that made call to the OutputPage)
- The recommended way to add body attributes now is to use the
OutputPageBodyAttributes hook

Bug: T255698
Depends-On: Idab13c37002ac5663f292e4f4b4ff51eb7573fda
Change-Id: Ibc56bf40c1ea70b2d7f7860ed85fbeb7b5d2bbf5
2020-06-21 08:19:35 +01:00