Commit graph

1835 commits

Author SHA1 Message Date
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
Abijeet
8ddc4ee2ef Add TranslationAliasesDirs to specify special page aliases in JSON
The TranslationAliasesDirs configuration allows defining translatable
aliases in JSON files. The value should be a name or names of folders
that contains files that have localized aliases. Each language should
have a separate file.

Currently, it supports defining special page aliases but in the
future can be extended to support magic words and namespace aliases.

The patch adds a script: ConvertExtensionsMessagesToTranslationAlias
that can be used to convert existing ExtensionMessagesFiles to the new
format.

Bug: T89947
Change-Id: Ief16a48a8dc8742854f67301791aa2a0b0531116
2024-03-06 18:13:28 +05:30
Gergő Tisza
038ec7be40 Revert "Output: Add IframeSandbox class"
This reverts commit cb09a27cc2.

The class is not very useful as it is now, due to performance issues
(T169027#9342985). The Graph extension is not going to use iframes
(T334940#9537862) and that was the only concrete feature for this, so
making the class usable in practice is unlikely to get prioritized.
No point in leaving the code in its current halfway state.

Bug: T222807
Bug: T169027
Change-Id: Id1b5193975435b58aebc225528e30f04456d0c41
2024-03-04 12:32:23 -05:00
jenkins-bot
abaa158dd2 Merge "Refactor PublishStashedFileJob to make the code reusable" 2024-03-02 21:33:27 +00:00
jenkins-bot
000232282d Merge "filebackend: add FileStatePredicates helper class for file operations" 2024-03-02 08:10:44 +00:00
Giuseppe Lavagetto
61ed857f9e Refactor PublishStashedFileJob to make the code reusable
To this end, we create a trait to coalesce together all upload methods
common to all upload mechanisms.

Change-Id: I28d0be0239f3b25efc6ea8bc3d400b9d0f5bc7bf
2024-02-28 16:15:15 +01:00
jenkins-bot
845e69cb2e Merge "Namespace includes/cache" 2024-02-28 15:10:38 +00:00
jenkins-bot
8301b5ae7c Merge "specials: Use a pager on Special:UploadStash" 2024-02-25 16:20:19 +00:00
Timo Tijhof
be2dbcc219 ResourceLoader: Follow-up creation of ResourceLoaderEntryPoint
Follows-up Iadea44b7867f48a2be6ccbf00c0e56911a5af74e.

ResourceLoaderEntryPoint:
* Rename from Resource to ResourceLoader, as it is the entry point
  for ResourceLoader.
* Fix accidental use of ingroup on the file docblock
  instead of the class.
  https://phabricator.wikimedia.org/F42046908
* Fix broken "see" reference to "/load.php" on the ResourceEntryPoint
  class on doc.wikimedia.org. Files are indexed in Doxygen by full
  name without leading slash.
* Remove load.php from docgroup, akin to index.php.

tests:
* Remove unrelated Rest namespace from test suite.
* Remove redundant default values in newResourceLoader(),
  especially null values were confusing by showing an
  apparent intent to set a value without actually
  isplacing the default, given that isset/?? treat
  set null as not set.
* Simplify test by using the built-in startup module instead.

EntryPoint:
* Remove comment in test about doPostOutputShutdown.
  It sounded like it was explaining that we use getCapturedOutput()
  instead of run() because the latter calls doPostOutputShutdown
  which we want to avoid. Except, we don't avoid it,
  since run() is called and does call doPostOutputShutdown.
  Unclear what it was explaining.
* Improve docs around getCapturedOutput() in the base class,
  and make explicit that this seemingly unused complexity
  exists for the purpose of testing.

Bug: T354216
Change-Id: I5139fda90a3d5ac7ea1ed917c8045d1a09961d78
2024-02-22 22:30:39 +00:00
Aaron Schulz
7913713d88 filebackend: add FileStatePredicates helper class for file operations
This replaces the old pass-by-reference $predicates array and makes the
intent clearer. It also supports lazy-loading of predicated properties,
which useful for avoiding expensive computations like SHA-1 hashes when
they end up not being needed.

Pass FileOp::doPrecheck() a mutable "batch level" FileStatePredicates
instance along with an immutable "operation level" FileStatePredicates
instance. The later can be used in callbacks that need to recall the
predicated file states just before the start of the operation.

Make FileOp::precheckDestExistence() support lazy size/sha1 closures.

Bug: T348294
Change-Id: I709c1920d2bee4b76f69e38c1643a44a73d63265
2024-02-21 14:00:27 -08:00
jenkins-bot
02990a13e0 Merge "SpecialRandomPage: Remove deprecated stuff" 2024-02-20 17:54:35 +00:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
Reedy
24260fe527 SpecialPrefixIndex: Allow extensible filters
Add SpecialPrefixIndexGetFormFiltersHook hook that allow extensions
to add custom filters on Special:PrefixIndex and another hook
SpecialPrefixIndexQuery that allows you to modify the query builder
to add more conditions based on the filters selected.

Bug: T299308
Change-Id: Iabc672086547d0b19f01cc95892633c2668821ef
2024-02-18 16:43:43 +05:30
Fomafix
83e57d0444 SpecialRandomPage: Remove deprecated stuff
* Constructor without injected services.
* Class name alias RandomPage.

The class name SpecialRandomPage can removed in 1.43.

Accoding to
https://codesearch.wmcloud.org/search/?q=RandomPage
there is no usage with the old class names or without injected
services.

Bug: T265308
Depends-On: I889266c7b1435c6849a63fa5d99f272c9650e96a
Change-Id: I9ae2655084128ff5e9531f4d4431cab966c72341
2024-02-17 20:52:42 +00:00
Subramanya Sastry
e55cc517da Move Parser to Mediawiki\Parser namespace
Bug: T166010
Co-Authored-By: Daimona Eaytoy <daimona.wiki@gmail.com>
Co-Authored-By: James Forrester <jforrester@wikimedia.org>
Co-Authored-By: Subramanya Sastry <ssastry@wikimedia.org>
Change-Id: I79b4e732c45095eedbaa80afa5eb7479b387ed8a
2024-02-16 09:18:38 -05:00
C. Scott Ananian
b01eb624c4 [OutputTransform] Add section edit links to Parsoid output
Bug: T269630
Change-Id: I9d5fb6348609642ad94743cc5dae81ce608be99d
2024-02-15 13:09:02 -05:00
Umherirrender
1175c77fca specials: Use a pager on Special:UploadStash
- A pager allows to limit the result shown on the page
- A pager allows pagination if the list is very long
- Add timestamp, thumb and dimensions to provide more information

Bug: T335629
Change-Id: I30b6cbe11f116baad4f61a08876f18f5d042ac02
2024-02-14 21:13:56 +01:00
James D. Forrester
eeb5a740b3 Namespace Message, move to appropriate directory
Bug: T353458
Change-Id: I088cbc53fbcdb974e5b05b45a62e91709dacc024
2024-02-14 15:10:36 -05:00
James D. Forrester
59c0aa2134 Namespace HTMLForm and friends
Bug: T353458
Change-Id: I09e66c3223018ec47e0549ee7f6a590b676f4eef
2024-02-14 08:18:33 -05:00
C. Scott Ananian
4c302bd47c Move hooks used by OutputPage into includes/Output/Hook
Bug: T166010
Change-Id: Ifdb9e6b59f126b47e4143c875c34a207643b7034
2024-02-09 11:08:43 -05:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Amir Sarabadani
686ab5623a LinkedData: Namespace PageDataRequestHandler
Bug: T353458
Change-Id: I873c323bc94e6ff6c07bbbe6157fc4cdf0e85e0d
2024-02-08 11:07:01 -05:00
C. Scott Ananian
52320c0902 Move ParsoidRenderID to MediaWiki\Edit
This class belongs with the rest of the Parsoid output stash code.

This class has been marked @unstable since 1.39 and thus the move
does not need release notes.

Change-Id: I16061c0c28b1549fbe90ea082cc717fee4a09a6e
2024-02-07 21:22:06 -05:00
Isabelle Hurbain-Palatin
ec9dc3d4c4 Rename PostCacheTransformHookRunner
Follow-up to I53551ec6d6471569709c71c1155729e550f64de8.

Bug: T348253
Change-Id: Ia08624a6770070313bf8bbaa11df29e4ed30b73b
2024-02-07 13:01:20 -05:00
jenkins-bot
77e88d6821 Merge "ResourceLoader: Factor out ResourceEntryPoint from load.php" 2024-02-02 22:31:37 +00:00