Commit graph

1999 commits

Author SHA1 Message Date
James D. Forrester
9e5c1e8ac7 Add namespace to IDBAccessObject and DBAccessObjectUtils
Bug: T353458
Change-Id: I23cf7991f8792d4d000d1780463d8ce76dc0aee0
2024-09-27 16:19:10 -04:00
Bartosz Dziewoński
943d089008 Replace raw HTML copyright footer message with wikitext one
Replaces 'copyright' with 'copyright-footer' and 'history_copyright'
with 'copyright-footer-history' (the original still takes precedence
if set). Adds SkinCopyrightFooterMessage hook which works the same
way as SkinCopyrightFooter for the new messages. Allows disabling
the old messages by setting $wgAllowRawHtmlCopyrightMessages = false.

Co-Authored-By: Gergő Tisza <tgr.huwiki@gmail.com>
Bug: T45646
Change-Id: I5fd5607f8d43b6e934c8d4d35097cec430c56043
2024-09-26 16:18:52 +02:00
James D. Forrester
984076f98e Add namespace to includes/api classes
Bug: T353458
Change-Id: I3ea6b08c5018ba03ba45c5766e1f46e12f6b8597
2024-09-25 19:31:14 +00:00
Dreamy Jazz
6547b639d8 Add SpreadAnyEditBlock hook
Why:
* A hook is needed which is called when User::spreadAnyEditBlock
  is called, so that extensions which provide alternative blocking
  mechanisims (such as the GlobalBlocking extension) can spread
  their blocks when local blocks are spread.

What:
* Add SpreadAnyEditBlockHook which is called from User
  ::spreadAnyEditBlock when it is called except when the user is
  not registered.
** The hook is called even if the user is not locally blocked
* The return value of User::spreadAnyEditBlock is modified to
  return true if either a local block or alternative blocking
  mechanism spread blocks.
* Update UserTest to test this new behaviour.

Bug: T374857
Change-Id: Id302a6362d6177c89da9cdf4e677b3822ecb85f1
2024-09-24 12:04:20 +01:00
daniel
84fe1b9ccd REST: Introduce discovery endpoint
The discovery endpoint provides basic information about accessing the
wiki's APIs, as well as a directory of available modules.

Bug: T365753
Change-Id: I161aa68566da91867b650e13c8aadc87cd0c428c
2024-09-20 17:02:59 +00:00
Bartosz Dziewoński
7772b58bb9 auth: Add base class for TemporaryPasswordPrimaryAuthenticationProvider
Bug: T149003
Change-Id: I38c0de0ed52f4e35db443bc22d4ed110eafac97b
2024-09-16 23:09:01 +02:00
Dreamy Jazz
44cad41d03 Fix old autoblock unblock log entries with namespace in log_title
Why:
* The logging table on en.wikipedia.org contains an entry from
  2005 which is an unblock of an autoblock. However, the log_title
  contains the namespace, which makes the code that looks for
  logs which target an autoblock fail (because it checks for the
  first character being '#').
* Fixing the log_title to remove the 'User:' prefix from rows which
  are autoblocks (i.e. searching for log_titles which start with
  'User:#') should address the exceptions seen on Special:Log for
  these rows.
** The search can be limited to rows which have the 'unblock'
   log_action, as this has only been seen for this type of log.

What:
* Create fixAutoblockLogTitles.php which searches for the entries
  and then updates the log_title value to no longer include the
  'User:' prefix
** The queries to search are split, such that the expensive LIKE
   query is performed on batches of row IDs. If the LIKE query is
   applied directly to all rows in the table, the query takes 30s
   to run on WMF production.
* Add this maintenance script to update.php. It will be run once
  as the class extends LoggedUpdateMaintenance.
* Test the newly added maintenance script to ensure it works.

Bug: T373929
Change-Id: Ia62db56eda456bb764303b5f4b5a29be8f2d8fff
2024-09-13 12:18:32 +00:00
Timo Tijhof
8268b5e72c
objectcache: Improve overall BagOStuff class docs
Fix file doc blocks while at it.

> Remove duplicate description from file block in favour of class doc.
> This reduces needless duplication and is often incorrect or outdated,
> and helps make file headers more consistently (visually) ignorable.
>
> Add missing `ingroup` to class doc (and remove any from file doc)
> as otherwise the file is indexed twice (e.g. in Doxygen) which makes
> navigation on doc.wikimedia.org rather messy.
>
> Ref https://gerrit.wikimedia.org/r/q/message:ingroup+is:merged+owner:Krinkle+branch:master

Bug: T364652
Change-Id: Icc36566da1c7190b0f4269719f34d3d6a83026c1
2024-09-11 11:55:10 +01:00
jenkins-bot
dbb984360a Merge "objectcache: Remove WinCache support" 2024-09-06 01:19:59 +00:00
Máté Szabó
f89aa38f69 objectcache: Remove WinCache support
WinCache is an APCu equivalent for use with Microsoft IIS, but in recent
years has been unmaintained and lacks support for PHP 8 and newer.[1]
So, remove support for it as MediaWiki will be raising the minimum
supported PHP version to 8.1.

[1] https://www.php.net/manual/en/install.windows.recommended.php

Bug: T365691
Change-Id: I4d2dc01a9119bb1f858132f0146b894750c1e86d
2024-09-05 17:59:26 +00:00
Fomafix
b43860cc09 Add new hook OutputPageRenderCategoryLink
This allows to change the category link rendering by extension
CategoryTree without missing update of mCategoryData and mCategories
which leads to wgCategories = [] (T372155).

The new hook will be used in extension CategoryTree by
Ic86f210474cbc0e2dcebf664cf2309a4a4408f60.

Bug: T372155
Change-Id: Id82a77a57d1f12233d974ea4c1b093f50c5ab74f
2024-09-05 15:53:43 +00:00
jenkins-bot
7ffa04d155 Merge "Remove UIDGenerator, deprecated since 1.35" 2024-09-05 11:01:25 +00:00
Ebrahim Byagowi
c0d1f7694c objectcache: Remove ReplicatedBagOStuff, deprecated since 1.42
Bug: T352481
Change-Id: I4e1ee5680b7ba0207dfe30a1208db35eca07e218
2024-09-04 20:21:29 +00:00
Ebrahim Byagowi
f903bae012 Remove UIDGenerator, deprecated since 1.35
Change-Id: I5e47ecd560218df7e48af68e6aee351bc2a57823
2024-09-04 14:38:30 +03:30
jenkins-bot
d7a2a2bf56 Merge "recentchanges: Move rcfeed/ to includes/recentchanges/RCFeed/" 2024-08-30 09:03:43 +00:00
Aaron Schulz
3833d2d3d3 rdbms: remove deprecated MaintainableDBConnRef class
Bug: T373655
Change-Id: I1d1ccb862d4356af146ee39f0fd4081acd82a9ce
2024-08-30 01:19:51 +00:00
Timo Tijhof
8fb118cb8b recentchanges: Move rcfeed/ to includes/recentchanges/RCFeed/
It is part of the component at
https://phabricator.wikimedia.org/tag/mediawiki-recent-changes/
and
https://www.mediawiki.org/wiki/Developers/Maintainers
and
since Ifac20da51f7e809f under the same "Recent changes" doc group.

The Maintainers list oddly enough lists only rcfeed and completely
forgets the majority of it under /includes/changes (or now,
/includes/recentchanges).

Bug: T364652
Change-Id: I94e6705672c1e2821bdc726aa7a383d9e7c1f7b5
2024-08-29 03:51:40 +01:00
jenkins-bot
3abfedbcbb Merge "auth: Add AuthManagerVerifyAuthentication hook" 2024-08-27 01:16:31 +00:00
jenkins-bot
8cf23d37ef Merge "auth: Add AuthManagerFilterProviders hook" 2024-08-27 01:16:14 +00:00
Gergő Tisza
e3cea8e11f auth: Add AuthManagerVerifyAuthentication hook
Add a new hook that can be used to prevent authentication just
before AuthManager takes the main action (writing the session
for login, creating the local user account for account creation).

The driving use case is a wiki which supports both a local and
a central (wiki-farm-level) login or signup flow - various
security options (such as 2FA) are needed during local login
but unnecessary during central login (which will have those
security features centrally), so we need to skip much of the
security when the user is taking the central route, and a bug
in how that's done could result in circumvention of security
features during local login. The hook makes it easy to inspect
and potentially interrupt login near the end, when we know for
sure what route it took. (Specifically, we know which primary
provider was used. The hook doesn't expose other details,
such as the list of preauth or secondary provders that were
invoked, because they were not needed for the immediate use
case, but they are easy to add in the future.)

The hook is called after the secondary providers for login
and before them for account creation, since secondaries can
interrupt login but cannot interrupt account creation.

A shortcoming is that since the hook is called after a primary
provider succeeded, it cannot prevent the primary provider from
doing work, ie. it cannot prevent creation of the remote account
during account creation (although it will prevent the creation
of the local account). This is not great but acceptable, since
creating a new account isn't very security-sensitive.
This also means the hook would not be useful during account
linking, as AuthManager does not do anything there, all the work
happens in the primary provider. This is even less great but
few authentication extensions implement account linking.

The hook is not called for authentication happening via
CreatedAccountAuthenticationRequest, which is a weird internal
hack hook handlers should not have to know about.

Also rename a confusingly named variable.

Change-Id: I835b2fe2f43e6e81f23348165cbb9c93832e6583
2024-08-26 23:57:31 +00:00
Gergő Tisza
cde00b5585 auth: Add AuthManagerFilterProviders hook
Allow disabling authentication providers. This allows for
extensions to replace core providers with their own.

This is using the $wgAuthManagerAutoConfig keys instead of
AuthenticationProvider::getUniqueId() as the keys to filter.
This makes it more useful for site administrators, and also
it's probably the better known of the two identifiers so
more intuitive.

No effort is made to prevent the hook from filtering
differently in different steps of the same authentication
process.

Bug: T369180
Change-Id: If5435b54a4fc08f685c04fc10eb44c6d72cd78fa
2024-08-26 23:56:49 +00:00
Dreamy Jazz
feba425a10 Remove fixDefaultJsonContentPages.php
Why:
* The fixDefaultJsonContentPages.php maintenance script was added
  in 2986d47c90 which was MW 1.27
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove fixDefaultJsonContentPages.php

Bug: T373335
Change-Id: Ie20f55c6a8723573aa7e9acd67766af9dfb67269
2024-08-26 13:17:04 +00:00
Dreamy Jazz
21fae91b4a Remove populatePPSortKey.php
Why:
* The populatePPSortKey.php maintenance script was added in
  993ce4d411 which was in at
  least MW 1.34.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populatePPSortKey.php

Bug: T373334
Change-Id: Iaa86bb193bf8feae9f5e2fe33255182e864d2e4f
2024-08-26 13:16:48 +00:00
Dreamy Jazz
30668e638f Remove populateBacklinkNamespace.php
Why:
* The populateBacklinkNamespace.php maintenance script was
  added to update.php in MW 1.24 in
  b8c038f678
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateBacklinkNamespace.php

Bug: T373333
Change-Id: Ia70fdd5c5ae087d7f5bdf4499185701bbb106c1f
2024-08-26 13:16:04 +00:00
Dreamy Jazz
de1f704035 Remove addRFCandPMIDInterwiki.php
Why:
* The addRFCandPMIDInterwiki.php maintenance script last had
  it's update key modified in MW 1.23 in commit
  bd38435848.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove addRFCandPMIDInterwiki.php

Bug: T373331
Change-Id: Ie6791c0cc2cfab5e09aa0b1c7ddcea1099cd1f79
2024-08-26 13:15:41 +00:00
Dreamy Jazz
b103940c24 Remove populateRevisionLength.php
Why:
* The populateRevisionLength.php maintenance script last had it's
  update key modified in 0f79beec8b
  which was MW 1.22.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateRevisionLength.php

Bug: T373313
Change-Id: Ic621e14a6ea7f455a396aac61b9919ed8436d71a
2024-08-26 10:37:48 +01:00
Dreamy Jazz
1e3420bf8c Remove populateFilearchiveSha1.php
Why:
* The populateFilearchiveSha1.php maintenance script has been in
  core since fb2c1c645b which was
  MW 1.19
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateFilearchiveSha1.php

Bug: T373312
Change-Id: Ia68d11ccc5c9f470783acfe7139e48f76a1576c9
2024-08-26 10:31:57 +01:00
Dreamy Jazz
7adcc63bfe Remove populateImageSha1.php
Why:
* The populateImageSha1.php maintenance script has been in core
  since at least MW 1.19, being definitely added to update.php
  in 1.19 through 7cb4d69d9d.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateImageSha1.php

Bug: T373310
Change-Id: Ibc6a31b1eafb7c5727d68bfb2526ffd7532408a6
2024-08-26 10:27:01 +01:00
Dreamy Jazz
1bbff80eaf Remove populateRecentChangesSource.php
Why:
* The populateRecentChangesSource.php maintenance script was
  added in 6bbd4bca6c which was in
  MW 1.22. It was added to the version-specific updater
  list, which means it is no longer run in 1.43 and therefore
  is also never called.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateRecentChangesSource.php

Bug: T373308
Change-Id: Iabe8f0b28966c9d57a19d6965cc2de7ce489e8ed
2024-08-26 10:15:27 +01:00
Dreamy Jazz
4474cca644 Remove populateIpChanges.php
Why:
* The populateIpChanges.php maintenance script was added in MW 1.30
  in commit d09554b6ef.
* Per the version policy, wikis wishing to upgrade to MW 1.43
  should upgrade via 1.35 or 1.39 before moving to 1.43.
* As such, this script will have been already run for any wiki
  upgrading to 1.43 and therefore this script is unused.
* Removing the script is useful to reduce the amount of untested
  code in the maintenance directory and reducing unnecessary
  maintenance on now unused code.

What:
* Remove populateIpChanges.php

Bug: T373306
Change-Id: Ie6b5405ceac4aa5465325dc5b5d3b82e3235390f
2024-08-26 09:11:14 +00:00
Dreamy Jazz
5f4d19f680 Remove populateRevisionSha1.php
Why:
* The populateRevisionSha1.php maintenance script last had it's
  update log key changed in MW 1.19 in c326cab5, and it has been
  added to update.php since that version.
* This means that, since the script has been run via update.php
  since before MW 1.35, it should be possible to remove the
  script as all wikis will have run this script and therefore
  it will be skipped for all wikis (as it's in the update log).
* Removing now unused maintenance scripts is important to reduce
  the amount of untested code in the maintenance directory and
  also prevents the need to update the code for migrations
  (e.g. using the query builders).

What:
* Remove the populateRevisionSha1.php maintenance script.

Bug: T373238
Change-Id: Id3d46d6e0d4b8bd4aaf6d3ed01d7b759813c981a
2024-08-26 09:10:40 +00:00
jenkins-bot
b1d5d73704 Merge "Create a maintenance script to purge expired rows in recentchanges" 2024-08-22 10:38:07 +00:00
DannyS712
16706f2b14 Add Special:NamespaceInfo
Bug: T263513
Change-Id: I2e863433608d13bcb6740b12d3336353c99f3ea3
2024-08-22 02:39:42 +00:00
Dreamy Jazz
fc5798668d Create a maintenance script to purge expired rows in recentchanges
Why:
* In the CheckUser extension, a maintenance script named
  'purgeOldData.php' purges data from the recentchanges table.
* This script is run on WMF production daily to ensure private
  data is purged.
* This should instead be in core, so that the functionality can
  be used when CheckUser is not installed and also not duplicate
  existing code used for the job that purges the table.

What:
* Create purgeRecentChanges.php which purges expired rows in the
  recentchanges table by running the code in the
  RecentChangesUpdateJob directly (without using the job queue,
  as there is no need to do that because we are in a maintenance
  script context).
* Add a test for this maintenance script
* Test the purging features of the existing job to ensure that
  this code is reliable.

Bug: T373032
Change-Id: Id32780c00b053d7fec94a00812f8d40a6bf2e40c
2024-08-21 17:18:11 +01:00
James D. Forrester
285682ab41 Consolidate Maintenance 'includes' code in one place
Change-Id: Ifd20f164e5cafe52efdf4fa65e39289214d68696
2024-08-11 18:09:08 +02:00
James D. Forrester
bc662aec9b Move Language and friends into Language namespace
Bug: T353458
Change-Id: Id3202c0c4f4a2043bf97b7caee081acab684155c
2024-08-10 13:36:30 +02:00
jenkins-bot
22163e47a7 Merge "Add MediaWiki\Registration namespace to registration classes" 2024-08-10 11:33:27 +00:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
James D. Forrester
f7ce0a0976 Move remaining four classes in includes/content into Content namespace
Bug: T353458
Change-Id: Ia0f3e22078550be410c4b87faf6aa4eabe6e270d
2024-08-10 10:40:53 +02:00
James D. Forrester
6df7a51484 Drop MessageContent, deprecated since 1.38
Change-Id: Ib53d4a04e6faa82b0ea553221e6c0c827f36017a
2024-08-10 09:28:37 +02:00
jenkins-bot
01d18ced29 Merge "Throw exception from Maintenance::fatalError when in PHPUnit tests" 2024-08-09 12:09:43 +00:00
jenkins-bot
cfc9cb4a9f Merge "ForeignResourceManager: Ignore network errors during tests" 2024-08-08 12:12:17 +00:00
Gergő Tisza
3b276808ed ForeignResourceManager: Ignore network errors during tests
Bug: T362425
Change-Id: Ie7e9e9bbd99c32d5b3153f1fd4a4042b437ce189
2024-08-08 12:51:37 +02:00
Ebrahim Byagowi
c586a7207c Add namespace to ContentModelChange
It adds MediaWiki\Content namespace to ContentModelChange

Bug: T353458
Change-Id: Ia9fbff3b7d25a83be58fffbfc01274c9fcc7a482
2024-08-08 11:14:45 +02:00
Ebrahim Byagowi
35867f0e21 Add namespace to FileContentHandler
It adds MediaWiki\Content namespace to FileContentHandler

Change-Id: I2db36de12a60c78524ea6ee2d8866ff901a48cac
2024-08-07 09:34:01 +03:30
Ebrahim Byagowi
4c270a72ac Add namespace to WikitextContent
It adds MediaWiki\Content namespace to WikitextContent
and two classes related.

Change-Id: Ib74e4c5b3edac6aa0e35d3b2093ce1d0b794cb6d
2024-08-06 17:42:51 +03:30
Ebrahim Byagowi
cfe2c7c2cf Add namespace to CodeContentHandler
It adds MediaWiki\Content namespace to CodeContentHandler

Change-Id: Ie02c727a66af7d0dae568eab67b242d5ffdf6431
2024-08-06 13:06:10 +03:30
Dreamy Jazz
65d62ae39e Throw exception from Maintenance::fatalError when in PHPUnit tests
Why:
* The Maintenance::fatalError method calls the exit method, which
  when called causes the PHPUnit test suites to exit early.
* This means that code that calls ::fatalError cannot be tested
  unless the method is mocked for each test.
* To avoid this problem the ::fatalError method should not call
  exit() when running PHPUnit tests, as described in T272241.
  Instead, it should throw an exception which can be caught when
  the call is expected.

What:
* Create MaintenanceFatalError which extends Exception, which is
  thrown by Maintenance::fatalError instead of calling exit() if
  the 'MW_PHPUNIT_TEST' constant is defined.
** This new exception takes the error code passed to the
   ::fatalError method and uses it as the exception error code.
* Create MaintenanceBaseTestCase::expectCallToFatalError which
  makes it easier for tests to assert that a call to
  Maintenance::fatalError occurs. This can optionally assert
  that the $code passed is as expected.
** Code which wishes to assert against the provided $msg can use
   ::expectOutputString or ::expectOutputRegex.

Bug: T272241
Change-Id: I554a963c63eb4f22ebb3273053a7b83a33dcb4d1
2024-08-03 22:54:38 +00:00
jenkins-bot
9c80f489cf Merge "resourceloader: Add ResourceLoaderModifyStartupSourceUrls hook" 2024-08-01 03:25:14 +00:00
Gergő Tisza
31f614f732 resourceloader: Add ResourceLoaderModifyStartupSourceUrls hook
Add a hook to StartUpModule that can modify the source URLs
that get embedded into the startup module JS in the form of
mw.loader.addSource() parameters.

The intended use case is preserving relevant URL information,
especially in the case of the 'local' source which is a
relative URL, when the URL pattern of the load.php URL
that generates the startup module code is different from the
URL pattern of the page that loads that load.php URL.

(E.g. $wgLoadScript is set to a different domain than the
current page, to canonicalize load.php URLs for a site
that's reachable via multiple domains, but then by default
the local source is a relative URL which would be
interpreted relative to the URL of the page that executes
the startup module code, so it would result in calls to
non-canonical load.php URLs).

Bug: T365162
Bug: T371530
Change-Id: I199ab779abd0596b836ae43dcc5f2f2a489c9274
2024-07-31 17:02:35 +00:00