Commit graph

1859 commits

Author SHA1 Message Date
jenkins-bot
2354ec3184 Merge "Revert "Revert "Add ContributionsPager, an abstract parent for ContribsPager""" 2024-05-15 13:28:37 +00:00
jenkins-bot
29cb634a5c Merge "Revert "Revert "Make ContributionsSpecialPage parent for SpecialContributions""" 2024-05-15 13:21:27 +00:00
jenkins-bot
060157bafd Merge "Remove DummyLinker" 2024-05-13 18:56:44 +00:00
Bartosz Dziewoński
2b58278477 Remove DummyLinker
DummyLinker existed for backwards-compatibility with a few hooks that
have since been removed, e.g. 'LinkBegin'. The last hook using it is
'ImageBeforeProduceHTML', and it looks like it can be harmlessly
replaced there with `null` (none of the extensions implementing the
hook use this parameter).

Change-Id: I69689b2037269af3320b6203fc44755f93713489
2024-05-13 20:18:28 +02:00
jenkins-bot
cf6d252ead Merge "watchlist: Move un-namespaced watcheditem classes to /includes/watchlist/" 2024-05-13 16:07:36 +00:00
jenkins-bot
17e9c09d0c Merge "Move various job classes to relevant component directories" 2024-05-13 16:07:27 +00:00
Thalia
5362096f27 Revert "Revert "Add ContributionsPager, an abstract parent for ContribsPager""
This reverts commit e6fb3df2a6.

This re-instates I08a5d39036047484e3b44fcd83989072006b88e2.

Bug: T363358
Change-Id: I847c60a493d9973554ceb1232f3799c42321ee2b
2024-05-13 15:38:34 +01:00
Thalia
c2041e87f5 Revert "Revert "Make ContributionsSpecialPage parent for SpecialContributions""
This reverts commit 1f4bb6651a.

This re-instates Ic00fa3297fb08eacf570d3ec3fcf64925fcf69c5.

Bug: T363358
Change-Id: Ibf4f382f5aaf4447cfe9404d5dd8b6b59b314cdc
2024-05-13 15:35:59 +01:00
Lucas Werkmeister
3074f3f773 Add Special:TalkPage for redirecting to talk pages
This is useful to link to the talk page of a page that is only known by
its title without needing to parse it or make any API requests.

I originally had the class extend RedirectSpecialPage, but couldn’t make
the form work properly that way, so eventually I opted to extend
FormSpecialPage instead and implement the redirect behavior directly.

Cache behavior is moderately aggressive, pinned to the parser cache
expiry, as these redirects should only need to change when the
namespace settings are updated.

Bug: T242346
Change-Id: I531b0b061d1ff1fef9ceffd6c82dc34940ba653d
2024-05-13 11:54:39 +02:00
Timo Tijhof
c68eb007ea watchlist: Move un-namespaced watcheditem classes to /includes/watchlist/
Bug: T364652
Change-Id: I264024784e8147fa421c8a13e8ae4541d8735f78
2024-05-10 21:07:20 +01:00
Timo Tijhof
b432fd2f20 Move various job classes to relevant component directories
Motivation:

* Remove need to hardcode out-of-component files in various places.
  Especially for Gerrit queries, this not only reduces effort but
  also makes these files more likely to show up in the first place.
* Clarify component boundaries and ownership, e.g. when filing tasks
  with a stack trace.
* Now rather than later, to avoid need for multiple class renames and
  aliases when PSR-4 namespaces are applied later (T166010).

Background:

Similar to how jobs in extensions belong to that extension, the same
is true within core. There is a distinction between the JobQueue system,
and individual jobs belonging to a specific feature or component,
likewise for deferred updates, and special pages.

To make a begin with this, I propose moving the job classes to their
respective components for cases where component boundaries are already
clear. E.g. due to exclusively being queued by that same component,
being named/introduced by the same commit, being already documented
as such in component descriptions on mediawiki.org.

Bug: T364652
Change-Id: I73d6b97c6ca9f5abd29f4277d0f845426aa23bd0
2024-05-10 20:14:00 +01:00
Tim Starling
a5372218b7 block: Deprecate and stop using $wgBlockTargetMigrationStage
* Deprecate and stop using $wgBlockTargetMigrationStage. Remove
  block_target migration code.
* Make the $schema parameters to DatabaseBlockStore methods default to
  SCHEMA_BLOCK. Avoid passing these parameters where possible.
* Remove cleanupBlocks.php
* Deprecate DatabaseBlock static methods which try to present the old
  schema for b/c.

Bug: T362133
Change-Id: I845bad8cc09a4528fef46a6f9d490ebdec881d99
2024-05-10 15:54:17 +10:00
jenkins-bot
9f5a0be099 Merge "Revert "Make ContributionsSpecialPage parent for SpecialContributions"" 2024-05-09 19:40:05 +00:00
jenkins-bot
04787125e8 Merge "Revert "Add ContributionsPager, an abstract parent for ContribsPager"" 2024-05-09 19:39:16 +00:00
DannyS712
1f4bb6651a Revert "Make ContributionsSpecialPage parent for SpecialContributions"
This reverts commit 4e5917441d.

Reason for revert: breaking change, caused T364569

Bug: T364569
Bug: T363358
Change-Id: Ie5b899c31844a1ff1c3fba279638980d3e0ef176
2024-05-09 17:29:45 +00:00
DannyS712
e6fb3df2a6 Revert "Add ContributionsPager, an abstract parent for ContribsPager"
This reverts commit e1ffed0af6.

Reason for revert: breaking change, caused T364569

Bug: T364569
Bug: T363358
Change-Id: I08a5d39036047484e3b44fcd83989072006b88e2
2024-05-09 17:28:32 +00:00
jenkins-bot
47987acdfd Merge "Add ContributionsPager, an abstract parent for ContribsPager" 2024-05-09 13:13:38 +00:00
jenkins-bot
5b9bde475a Merge "Make ContributionsSpecialPage parent for SpecialContributions" 2024-05-09 12:51:56 +00:00
Thalia
e1ffed0af6 Add ContributionsPager, an abstract parent for ContribsPager
Why:
* For the temporary accounts project, we will make some changes to
  how user contributions can be viewed, including showing global
  contributions (T337089) and showing contributions from temporary
  accounts using the same IP (T358852).
* We will create new pagers that re-use logic from ContribsPager.
  These will behave similarly to ContribsPager, but will get the
  revisions using a different query.

What:
* Make ContribsPager extend a new abstract parent class,
  ContributionsPager.
* ContributionsPager:
  - handles filtering on edit type (minor, etc), namespace, tag,
    date and user permissions (e.g. hiding suppressed revisions)
  - runs the hooks that ContribsPager used to run, and keeps the
    same names for backwards compatability
  - handles displaying results
  - provides an abstract method getRevisionQuery for a subclass
    to specify where the revision comes from. (Examples are
    the `revision` table or the `cu_changes` table, but in the
    future this could also include archive.)
* ContribsPager:
  - handles an IP range target by using the ip_changes table
  - includes some public static functions that are kept for
    backwards compatability. (Future work could put them somewhere
    more appropriate.)

Scope:
* ContributionsPager is designed to select (existing) revisions.
  It could be abstracted out further to handle deleted revisions
  from the archive table, to help bring feature parity to
  Special:DeletedContributions. This is left out of scope for this
  patch.
* To keep the scope limited and the commit history clean, this
  patch doesn't attempt to fix the various TODOs in ContribsPager,
  or update old styles that are used.

Bug: T363358
Change-Id: I85bb28c9d85426ecc82c533a0cdd3f010c247b02
2024-05-09 05:22:37 -07:00
daniel
91a1741787 Introduce Modules into the REST framework
Modules group together endpoints by a shared prefix. The idea is that each module has its own version and can generated self-contained self-documentation. This allows clients to have clear expectations about the endpoints of each module, no matter what wiki they are accessing. So far, each wiki may be exposing a different set of endpoints, with no way to provide a spec that describes that set of endpoints in a way that would be consistent across wikis and stable over time.

Bug: T362480
Change-Id: Iebcde4645d472d27eee5a30adb6eee12cc7d046b
2024-05-08 16:12:30 +02:00
Thalia
4e5917441d Make ContributionsSpecialPage parent for SpecialContributions
Why:
* For the temporary accounts project, we will make some changes to
  how user contributions can be viewed, including showing global
  contributions (T337089) and showing contributions from temporary
  accounts using the same IP (T358852).
* We will create new special pages that re-use logic from
  SpecialContributions. These will be similar but use different
  pager classes.

What:
* Add ContributionsSpecialPage parent class, which does most of
  the work for SpecialContributions.
* ContributionsSpecialPage is not able to be an abstract class
  since its ancestor classes aren't (all the way up to SpecialPage)
  but it provides a function ::getPager that must be overridden by
  subclasses.
* Hooks that were provided by SpecialContributons are run from
  ContributionsSpecialPage in order to allow extensions to modify
  contributions pages in general, and not have to reimplement the
  modification for every contributions page. For backwards
  compatability, hooks are not renamed. Comments are added instead.
* In order to limit the scope of this patch, keep the history
  clean and not introduce new bugs, this is purely a refactor.
  It does not aim to fix any of the problems already existing in
  SpecialContributions, or to update any of the old styles used.

Bug: T363358
Change-Id: Ic00fa3297fb08eacf570d3ec3fcf64925fcf69c5
2024-05-07 18:59:52 +01:00
Isabelle Hurbain-Palatin
8de2e66ca7 Localization output transform
This is an output transform to resolve the mw:I18n and mw:LocalizedAttrs
to their localized forms.

Bug: T358191
Change-Id: Id32bc05ff72eb2d9fba7f8c2f192c9f7812cbc70
2024-05-06 15:24:38 -04:00
Hakan Özdemir
6c5684d41f Add namespace and deprecation alias to DeprecationHelper
This patch introduces a namespace declaration for the
MediaWiki\Debug to DeprecationHelper and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I808c6aa7836445feaa7b401624d79d01f2c70322
2024-05-05 14:16:35 +02:00
Amir Sarabadani
214674d6b1 namespace MWDebug
Bug: T353458
Change-Id: I99d728bd111ff882220cd175ff09d4da20b81eae
2024-05-03 22:59:47 +02:00
bpirkle
1e4b86b183 Disallow optional or empty path parameters
Do not allow optional path parameters or empty path segments
within the path. Handlers may still consider a path parameter
to be non-required. Normally this is when a handler services
multiple routes, and not all routes supply all parameters.

Bug: T359652
Change-Id: I4f82ee2b6ec5b631249d26496688e5f42696c1d0
2024-04-24 14:27:06 -05:00
daniel
23e0b606bd REST: allow redirects to be defined without specifying a handler
Make the Router class know about redirect definitions, so it is no
necessary to explcitly specify the RedirectHandler.

Bug: T361840
Change-Id: I2f3bce5b426639f1c4ecf55a6c003794019acd14
2024-04-17 18:27:31 +02:00
jenkins-bot
9dd96682fa Merge "handler: Create generic redirect handler for the REST API" 2024-04-17 08:12:13 +00:00
Atieno
72a49a90dc handler: Create generic redirect handler for the REST API
Bug: T361840
Change-Id: Idd4073fbe46b2544ca50d3505d396849155a8004
2024-04-16 15:42:19 +03:00
Thalia
14a2ec687b Remove ContributionsLookup service
This was added in 300fcfd00b
for an experimental REST endpoint that was removed in
c3fe4b037d, and is now unused.

Bug: T305506
Change-Id: I900c00747f77af6b0844105e9681c9d4acfe1ad5
2024-04-15 16:29:47 +00:00
Jon Harald Søby
1df54ce20e Implement language converter for Standard Moroccan Amazigh (zgh)
Requested by the zgh community in the Wikimedia Incubator at [1];
the converter is the same as for Shilha (`shi`); the main difference
between the two languages is that the main script for `zgh` is
Tifinagh, which can't be losslessly converted to the Latin script
(the former is unicameral, the latter is bicameral), so the
converter and configuration added here is essentially one-directional.

[1] https://incubator.wikimedia.org/wiki/Special:PermaLink/6060805

Change-Id: I483a1594f001226439497f0870176e9a1e447458
2024-04-11 16:40:50 +02:00
Sergio Gimeno
50a966a208 ReflectionSchemaSource: add support for JSON schema $refs
Why: supporting JSON schema $refs is desired for the
CommunityConfiguration 2.0 project so configuration
schemas can reuse definitions coming from another
PHP JsonSchema class. The https://json-schema.org/
specification supports relative and absolute URIs
as the content of a $ref. The change aims
to support only the former. Meaning that any
$ref defined in a schema should point to a
class that can be resolved by PHP.

What: update schema traversing in JsonSchemaTrait
to resolve any reference specified as:
[ 'class' => SomeClass:class, 'field' => 'someClassField' ]
into an actual json schema compliant $ref, eg:
$ref: '#/$defs/SomeDefinitionName'. Also annotate
new definitions found in a "$defs" array with the
resolved value of the refed class field.

Bug: T357718
Change-Id: I130326e5762e706be4889e308eeec45a6c7683c5
2024-04-05 13:18:47 +02:00
jenkins-bot
638236e3fe Merge "Introduce entry point classes for media files." 2024-04-03 15:50:32 +00:00
jenkins-bot
22cda00fd1 Merge "REST: Add support for complex parameters." 2024-04-03 02:12:33 +00:00
daniel
34b1ab1948 REST: Add support for complex parameters.
ParamValidator so far only supports primitive types as input, which is
insufficient for validating request bodies.

This adds an "array" parameter type that accepts any array. In the
future, we should add validation for such parameters, based on JSON
schema.

Change-Id: Idfa1c90be40772948a3c53d010441905b44b7b4e
2024-04-02 21:59:30 +02:00
jenkins-bot
0e5a6e2907 Merge "logging: Add LogFormatterFactory" 2024-04-02 19:07:28 +00:00
Amir Sarabadani
27dca7fb2a rdbms: Introduce RawSQLExpression for edge cases
This is useful for cases that we can't use the common expression
builders but we don't have a choice but to pass raw SQL. Common usecases
are comparing fields ("a.user_id > b.user_id") and function calls
("user_editcount > COUNT(rev_id)")

Bug: T210206
Change-Id: Ieb73d449262e22557f6f470105ca65ab0afc50e3
2024-04-02 20:04:58 +02:00
daniel
9638fa314a Introduce entry point classes for media files.
This moves a code out of file scope into classes to make it
testable. The code is left in the same structure as it was before,
global functions have been converted into methods on the new
ThumbnailEntryPoint and Thumbnail404EntryPoint classes.

This test introduces comprehensive phpunit tests covering all functional
code paths in ThumbnailEntryPoint. This is intended to support
refactoring of this code.

Change-Id: I459abc7b11d0ab4ee682a863c9525a945048296f
2024-03-30 21:14:05 +01:00
Gergő Tisza
ce836dae7c logging: Add LogFormatterFactory
Bug: T356468
Change-Id: I8dc2ec7993d8d5268877518c86df8c604380c8a0
2024-03-30 11:37:38 +01:00
Giuseppe Lavagetto
c2373af679 Add job for upload from UploadFromUrl
This is the first step to make upload from url work asynchronously

Bug: T295007
Change-Id: I1fb30352849b543c0fb1f27028a34d49dff17797
2024-03-23 11:23:07 +01:00
jenkins-bot
820c06ae94 Merge "objectcache: Introduce ObjectCacheFactory MW service" 2024-03-21 02:33:18 +00:00
James D. Forrester
85d95dd458 Drop old class_aliases for before MW 1.39 that were missed
The RandomPage alias was dropped in an earlier commit, so
group the release note entry in with these.

Change-Id: I207d7463ced1a1bb8b8ac749eba175fc0037a217
2024-03-20 12:10:42 +00:00
Derick Alangi
d372626b97
objectcache: Introduce ObjectCacheFactory MW service
ObjectCache is already doing a lot of factory pattern logic like
creating instances of the various BagOStuff, this should really be
the responsibility of the factory servicet.

This patch introduces a proper factory (ObjectCacheFactory) to handle
the responsibility of creating various instances of BagOStuff. Since
`newFromParams()` is a static function that gets passed in configuration
of $wgObjectCaches, that can stay that way (to keep supporting how we do
this in prod today).

Technical Breaking Change: `ObjectCache::makeLocalServerCache()` now has
a parameter and requires it but there are no callers of this method outside
MW core hence it is safe to change (and this patch update all callers) to
work correctly. Cache prefix is gotten from global state because sometimes
at this stage, the services container is not available.

Bug: T358346
Change-Id: I3179a387486377c6a575d173f39f82870c49c321
2024-03-19 12:38:39 +03:00
jenkins-bot
9f0d6eea0a Merge "Split web-specific code out of DatabaseInstaller" 2024-03-16 21:13:59 +00:00
Bartosz Dziewoński
9f30073589 Remove unused ConfigDependency class
Follow-up to I70613143b3621033c2447574d889a0866e03255e.

Change-Id: Id0d1643477c2babf0fa5e6ad69df4648827c6eb5
2024-03-15 05:59:27 +01:00
jenkins-bot
bf449f75b7 Merge "Remove experimental contributions endpoints" 2024-03-14 09:12:55 +00:00
Bill Pirkle
c3fe4b037d Remove experimental contributions endpoints
These four endpoints have been experimental for many months:
  /coredev/v0/me/contributions
  /coredev/v0/user/{user}/contributions
  /coredev/v0/me/contributions/count
  /coredev/v0/user/{user}/contributions/count

Analytics data shows they are not receiving any traffic.
Remove to clear out the coreDevelopmentRoutes.json file for
unrelated experiments, and to reduce future code maintenance.

Bug: T305506
Change-Id: I21cf9a398638d34725a3c34d348fbad50df40153
2024-03-13 21:22:47 -05:00
Gergő Tisza
e2bad05089 debug: Add MW class as helper for eval.php and shell.php
This class defines convenient shortcuts for common commands, like
creating a User object. To use on shell.php and similar tools.

Change-Id: I7982d163521e7ae8f2be22613ac6a6fb6af1d7cd
2024-03-13 19:07:27 -07:00
Tim Starling
3f852f7ddc Split web-specific code out of DatabaseInstaller
DatabaseInstaller had some LSP violations, such as calling undeclared
methods of the supplied Installer object, assuming that it was a
WebInstaller. It was also large.

So, split the web form parts of DatabaseInstaller into separate classes.
We have a class hierarchy for the connect forms, and a class hierarchy
for the settings forms, with a base class DatabaseForm mostly as a place
to put protected helper methods.

Also, have DatabaseInstaller::getConnection() return a special subclass
of Status, so that we can remove many Phan type overrides.

Change-Id: Ie84025f8f70b895fa6882848b9a21ba1750d60e2
2024-03-13 13:04:13 +11:00
jenkins-bot
9100c074d2 Merge "REST: Introduce trait for handling Status objects" 2024-03-12 14:25:34 +00:00
daniel
84f314bbf1 REST: Introduce trait for handling Status objects
The new trait provides conveniance methods for logging and throwing
errors based on StatusValue instances.

Change-Id: Id7cbacb744bee79cd8a6f61291a26b36e6243053
2024-03-12 14:48:33 +01:00