Commit graph

1959 commits

Author SHA1 Message Date
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
jenkins-bot
674cd4ea18 Merge "Extract LintErrorChecker out of SignatureValidator" 2024-07-29 19:05:52 +00:00
Kunal Mehta
4d49a4a59e Extract LintErrorChecker out of SignatureValidator
This code was partially copied into MassMessage and will hopefully
enable more places that accept arbitrary wikitext to check lint errors.

It also hides the internal details of checking with the Linter
extension's configuration in one place until it can be refactored into
something more acceptable (T360809).

Bug: T368690
Change-Id: Iaeb3ccbd61a2a8cb0d8b3dc8b06a3a10bc8fa653
2024-07-29 14:35:40 -04:00
Bartosz Dziewoński
c9f73efd5a Namespace MessageSpecifier under Wikimedia\Message\
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.

Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
2024-07-28 14:21:32 +02:00
jenkins-bot
78cd3f33cc Merge "Add phpunit:parallel:extensions composer command" 2024-07-17 11:04:36 +00:00
jenkins-bot
e6127d166c Merge "Add phpunit:prepare-parallel:extensions command" 2024-07-17 10:49:43 +00:00
Arthur Taylor
8610cf554d Add phpunit:parallel:extensions composer command
In T361190 and Quibble 1.9.0, we introduced parallel execution of
PHPUnit tests to speed up the CI jobs. The existing implementation
is purely Python/Quibble, and cannot directly be used by developers
locally. With this patch, we re-implement the parallel test
execution already implemented in CI as a composer task so that the
parallel tests can be run locally.

The `phpunit:parallel:extensions` command expects to be run after
`phpunit:prepare-parallel:extensions`, and expects to find 8 test
suites with the names `split_group_X` (for X in 0 through 7) in the
PHPUnit configuration file. 8 here is currently a hard-coded number
that corresponds to the number of parallel test executions we need
to saturate the CPU of a 4-core developer machine, and experimentally
leads to a good speed-up versus the serial execution.

When this command runs, it forks to launch 8 parallel processes,
each running one of the `split_group_X` suites. The parent process
waits for the children to complete, buffers the output, collects the
exit statuses, then dumps the buffered output and exits with a
non-zero status if any of the child processes failed (i.e. if there
were test failures).

We introduce `phpunit:prepare-parallel:default` as a complement to
`phpunit:prepare-parallel:extensions`, and the two commands
`phpunit:parallel:database` and `phpunit:parallel:databaseless`.
This creates four possible combinations - two different test suites,
and two different test groups. This is a similar setup to that which
we have in CI - the Database and non-Database tests are run in
separate groups, and some jobs use the `extensions` suite while
others just use the default suite.

The `phpunit:parallel:...` commands will fail with a helpful message
if no `split_group_`s are found in the active PHPUnit configuration.

To help test whether the split test runs are really running all the
tests in the suite, we generate and store the PHPUnit results cache
file. Comparing the results cache files from linear versus parallel
runs should tell us if all the tests have been executed.

Bug: T365976
Change-Id: If106802f08edd5d4c841bb7970c69b88ab3bb39b
2024-07-17 12:32:35 +02:00
DannyS712
8ae5a07948 Rename AutoSummaryMissingSummaryConstraint
In preparation for also handling the AS_REVISION_WAS_DELETED failure in the
constraint, rename it in a separate commit so that git can more easily track
the change.

Bug: T157658
Change-Id: Id55b40d8e327429fbaf45a96c0b00caaa9110da1
2024-07-12 21:04:32 +00:00
Arthur Taylor
1e2851d8d1 Add phpunit:prepare-parallel:extensions command
In T361190 and Quibble 1.9.0, we introduced parallel execution of
PHPUnit tests to speed up the CI jobs. The existing implementation
is purely Python/Quibble, and cannot directly be used by developers
locally. With this patch, we re-implement the test splitting logic
already implemented in CI as a composer task so that the parallel
tests can be run locally.

There are a couple of different approaches to running PHPUnit tests
in parallel. The different approaches have been discussed at length
in T50217. Ideally, we would just install the `paratest` extension
and use that to parallelise the execution. Unfortunately we have
complex test suites (specifically Parser tests and the Scribunto
test suite) that dynamically create tests as they run, which makes
it hard for `paratest` to work out which tests will run.

To overcome this limitation, we use the `phpunit --list-tests`
function to create a list of test classes that would be included in
the execution of the test suite, then scan the filesystem for
classes named in the `tests-list.xml` output. The classes we find
are then collected into smaller groups (`split_group_X`) which we
can run in parallel in separate processes.

We split into 7-8 groups here, as that experimentally leads to an
even spread of the tests and consumes 100% of all cores on a 4-core
processor.

Because `ParserIntegrationTest.php` is a single test class that
generates thousands of integration tests, we put that in its own
bucket rather than allocating it round-robin to one of the split
buckets. This again helps to keep the buckets roughly the same size.

The current implementation only supports splitting the `extensions`
test suite. We need to do some more development and testing to
support splitting other suites.

The new composer command `phpunit:prepare-parallel:extensions` will
generate a `phpunit.xml` file with the same contents as
`phpunit.xml.dist`, but with the split-group suites added. The
result of running all of the split groups should be the same as the
result of running the whole test suite.

Bug: T365976
Change-Id: I2d841ab236c5367961603bb526319053551bec2e
2024-07-10 07:59:23 +00:00
Ebrahim Byagowi
fab78547ad Add namespace to the root classes of ObjectCache
And deprecated aliases for the the no namespaced classes.

ReplicatedBagOStuff that already is deprecated isn't moved.

Bug: T353458
Change-Id: Ie01962517e5b53e59b9721e9996d4f1ea95abb51
2024-07-10 00:14:54 +03:30
Derick Alangi
493ffea9e9
Introduce hook to preserve query params after authentication
This hook enables extensions such as CentralAuth to preserve and
use query parameters needed for an authentication flow. Since there
is a provider that handles logins in a different wiki (central login
wiki), and movement to a different URL, this hook preserves query
parameters that can be used between these requests.

Bug: T363483
Bug: T362713
Change-Id: I86e629b07e6e4a0f1d1a4c78a6c77d41b4d68e18
2024-07-08 13:37:54 +02:00
nokibsarkar
6895bc84d5 LanguageConverter: Added support for mni-Beng in mniwiki
This is the Language Converter from Meitei Script to Bengali Script in mniwiki.
I don't know the language. I got help from a native speaker User:Haoreima.
The original prototype was in a Python Library written by myself.
It only converts the words that have Meitei characters (U+ABC0..U+ABFF).
The original prototype is already being used in mniwiki via Gadget and a Bot.

Bug: T357853
Change-Id: I810f18050f29efa38b2a646d96644e298af47c50
2024-07-06 17:05:19 +06:00
jenkins-bot
7df99f2dae Merge "REST: Make module definition files more like OpenAPI specs" 2024-06-24 20:36:14 +00:00
daniel
79c61e80dc REST: Make module definition files more like OpenAPI specs
This splits RouteFileModule into two classes, ExtraRoutesModule and
SpecBasedModule.

ExtraRoutesModule has no module prefix and supports
only "flat" route definition files and additional routes from
extension.json.

SpecBasedModule represents a single module defined in a definition
file similar to an OpenAPI spec. The idea is that a full OpenAPI spec
can be generated by filling in any missing information based on
information provided by the Handler implementation. In particular, the
definition of parameters and request body schemas will be generated.

A JSON schema for the new file format is added under docs/rest/.

Support for the intermediate format introduced in Iebcde4645d4 is
removed. It was not included in a release and was not being used outside
core tests.

Bug: T366837
Change-Id: I4ce306b0997f80b78a3d901e38bbfa8445bed604
2024-06-24 16:42:59 +02:00
jenkins-bot
4d5d9a6dae Merge "Add ApiLogFeatureUsage hook" 2024-06-14 19:13:31 +00:00
jenkins-bot
286f49b678 Merge "Add Special:RestSandbox for exploring REST API" 2024-06-14 01:19:30 +00:00
daniel
c01b7c7b4b Add Special:RestSandbox for exploring REST API
Special:RestSandbox presents a Swagger-UI interface for exploring REST APIs. The available APIs can be configured using RestSandboxSpecs.

For now, the default is to support no APIs, so the feature is disabled in production. In the future, it would make sense to expose the wiki's own REST API per default. The corresponding entry in $wgRestSandboxSpecs in LocalSettings.php would look like this:

	'mw' => [
		'url' => $wgScriptPath . '/rest.php/',
		'name' => 'MediaWiki REST API',
	]

Note that the spec URL may still change.

To also explore the endpoints exposed through RESTbase, we might add:

	'wmf-restbase' => [
		'url' => $wgServer . '/api/rest_v1/',
		'name' => 'Wikimedia RESTbase API',
	]

Similarly, we could expose a spec for endpoints on api.wikimedia.org, which could then be explored using the new special page.

NOTE: This adds a dependency on the swagger-ui npm library. See T325558 for the security review.

Bug: T362006
Change-Id: I1dd5ed82680a28f9c15136b446a2de0398525061
2024-06-13 21:40:36 +02:00
jenkins-bot
914fa87e51 Merge "user: Split a base class out of ApiOptions" 2024-06-13 13:06:34 +00:00
jenkins-bot
ce3767dd85 Merge "user: Introduce UserOptionsStore" 2024-06-13 13:06:27 +00:00
Aaron Schulz
0758620460 Add ApiLogFeatureUsage hook
Bug: T313731
Change-Id: I8bbf806501d542a0f91a67e197913a894bdee127
2024-06-12 13:49:50 -07:00
James D. Forrester
19f4e6945a Rename JsonUnserial… to JsonDeserial…
This is to make it clearer that they're related to converting serialized
content back into JSON, rather than stating that things are not
representable in JSON.

Change-Id: Ic440ac2d05b5ac238a1c0e4821d3f2d858bc3d76
2024-06-12 14:50:58 -04:00
Tim Starling
ca615f369a user: Split a base class out of ApiOptions
This gives us the flexibility to add features to core without
affecting GlobalPreferences.

Split getUserForUpdates() into asserting and non-asserting variants
since most things are using it without checking for a null return.

Bug: T323076
Change-Id: I53e5c409a650397fde03a8578b0182f0b97927a9
2024-06-12 02:08:49 +00:00
Tim Starling
cdc5178150 user: Introduce UserOptionsStore
Refactoring:

* Break out the database access part of UserOptionsManager to a separate
  class hierarchy implementing interface UserOptionsStore. It's
  basically a key/key/string-value store, very simple. The complex
  parts of user options storage remain in UserOptionsManager.
* Bundle the UserOptionsManager caches into a per-user cache object. I
  was adding a couple more and it was getting tedious.

Start integrating GlobalPreferences with UserOptionsManager:

* Have an array of stores. There's always a local store, and extensions
  can add stores via an attribute.
* Add $global parameter to UserOptionsManager::setOption(), allowing
  this method to update or override global options.
* Rename loadOptionsFromDb to loadOptionsFromStore.
* Move the local override feature from GlobalPreferences to core.

Bug: T323076
Change-Id: Ib3623b723557c819bc0ffdf21a4ffcb070eb298b
2024-06-12 01:27:57 +00:00
Aaron Schulz
b823c3dad1 rdbms: remove deprecated IDatabase::nextSequenceValue() method
Change-Id: Ic01a6d5b7951f53898f4cb4c19de1210beb5af85
2024-06-03 12:50:54 -07:00
jenkins-bot
6dfa3b8a3b Merge "rdbms: Create RawSQLValue for SET clauses in update/upsert" 2024-05-29 11:31:31 +00:00
jenkins-bot
5fe2040130 Merge "rdbms: Introduce IDatabaseForOwner" 2024-05-29 00:12:38 +00:00
Bartosz Dziewoński
b18e4b3517 Add library to display the login form in a JavaScript modal dialog
Experimental library that can display the login form in a small
browser popup window, a new browser tab or window, or an iframe in
a modal message dialog. We're still testing which of these methods
work from the technical side, and which are understandable for users.
Some methods or the whole library may be removed in the future.

Usage:
    const authPopup = require( 'mediawiki.authenticationPopup' );
    authPopup.startPopupWindow()
    // or: authPopup.startNewTabOrWindow()
    // or: authPopup.startIframe()
        .then( function ( userinfo ) {
            if ( userinfo ) {
                // Logged in
            } else {
                // Cancelled by the user
            }
        }, function ( error ) {
            // Unexpected error stopped the login process
        } );

Or in future JS:
    const userinfo = await authPopup.startPopupWindow(); // etc.
    if ( userinfo ) {
        // Logged in
    } else {
        // Cancelled by the user
    }

In all three methods, the popup opens the login form with
&display=popup and with &returnto pointing to an unlisted special
page that communicates with the module on the parent page.

Once the library is stable, the AuthPopup component may be separated
from MediaWiki and released as its own package, to be used by tools
to open MediaWiki OAuth workflows in a similar way.

Bug: T364939
Change-Id: I08d9c799b8f79ebab2bcf4fcf330ee8eb995582e
2024-05-28 17:54:22 +00:00
Amir Sarabadani
9557ac076b rdbms: Introduce IDatabaseForOwner
Similar to LBForOwner, moving several internal methods there to fully
hide it from outside of rdbms.

Bug: T363839
Change-Id: I7a46d0e77d8865c6ed81ed351cb7fee0f9eda9cb
2024-05-24 11:37:08 +02:00
jenkins-bot
07ece77e44 Merge "Add MediaWiki\Watchlist namespace to the related classes" 2024-05-23 23:12:10 +00:00
jenkins-bot
7fc3b17a9e Merge "LoginSignupSpecialPage: Support &display=popup" 2024-05-23 16:03:19 +00:00
Bartosz Dziewoński
5623b2e44c LoginSignupSpecialPage: Support &display=popup
Setting this URL parameter will replace the default skin with a
"micro-skin" that omits most of the usual interface elements,
making the page suitable to be displayed in a small popup window.
Its design (such as it is) is mostly based on Vector 2022.

In the future, we might allow normal skins to serve this mode too,
if they advise that they support it by setting a skin option.
For now that is out of scope.

The login/signup process is otherwise completely normal. To make use
of it, launch the login page in a popup, and set &returnto=... to
redirect back to your own success page, which should communicate the
successful login to your app and then close itself.

The display=popup / display=page vocabulary is borrowed from the
OpenID Connect spec.

Bug: T362706
Change-Id: Ic7cbbe98344b25d2e965750e0c4429ce157163ed
2024-05-22 22:06:31 +02:00
Ebrahim Byagowi
12660db261 Add MediaWiki\Watchlist namespace to the related classes
This adds MediaWiki\Watchlist namespace to the classes of watchlist
directory and adds deprecation notice since 1.43 to the just created
unnamespaced aliases of the classes.

Bug: T353458
Change-Id: I4234f8fe62bb3bde6f5271c7ba31a2420b0f4b90
2024-05-22 01:23:10 +03:30
Ebrahim Byagowi
c556eda906 Add MediaWiki\Content namespace to FallbackContent{,Handler}
This adds MediaWiki\Content namespace to FallbackContent
and FallbackContentHandler and declares the unnamespaced version
as deprecated since version 1.43.

Bug: T353458
Change-Id: I3ee80aea379788b71539cc1c7a4ec216b753e042
2024-05-21 17:05:28 -04:00
jenkins-bot
31a72c9b71 Merge "REST: introduce OpenSearchDescriptionHandler" 2024-05-21 19:54:56 +00:00
Bartosz Dziewoński
2a6f12dd7d rdbms: Create RawSQLValue for SET clauses in update/upsert
Bug: T210206
Co-Authored-By: Umherirrender <umherirrender_de.wp@web.de>
Follow-Up: Ieb73d449262e22557f6f470105ca65ab0afc50e3
Change-Id: I18c6973713badd2b035aa7f44048344f3494b7b0
2024-05-21 19:16:16 +00:00
jenkins-bot
f7e88a336e Merge "Add MediaWiki\RevisionList namespace to the related classes" 2024-05-21 16:04:12 +00:00
Ebrahim Byagowi
656c7fac3b Add namespace and deprecation alias to JsonContentHandler
This patch introduces a namespace declaration for the
MediaWiki\Content to JsonContentHandler and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Ia4ba6d3eddcb7b3f3d9f41a5ff80f724dbd01b22
2024-05-21 17:10:20 +03:30
Ebrahim Byagowi
64b7d2a03d Add MediaWiki\RevisionList namespace to the related classes
This patch introduces a namespace, MediaWiki\RevisionList, and adds it
to the related classes and establishes class aliases marked as
deprecated since version 1.43.

Bug: T353458
Change-Id: I1614a00dd8973c5300d95317a725cbe46e14d1af
2024-05-21 15:12:05 +03:30
jenkins-bot
37ae84be8b Merge "Add namespace and deprecation alias to WatchedItemStore" 2024-05-21 10:54:43 +00:00
jenkins-bot
7194dea853 Merge "Add namespace and deprecation alias to JsonContent" 2024-05-21 10:28:15 +00:00
jenkins-bot
8e4d1de473 Merge "Add namespace and deprecation alias to XMLRCFeedFormatter" 2024-05-20 17:36:04 +00:00