Commit graph

1381 commits

Author SHA1 Message Date
jenkins-bot
c434d89688 Merge "Replace gettype() with get_debug_type() in exception messages" 2024-08-04 21:18:48 +00:00
Bartosz Dziewoński
c045fa0291 Replace gettype() with get_debug_type() in exception messages
get_debug_type() does the same thing but better (spelling type names
in the same way as in type declarations, and including names of
object classes and resource types). It was added in PHP 8, but the
symfony/polyfill-php80 package provides it while we still support 7.4.

Also remove uses of get_class() and get_resource_type() where the new
method already provides the same information.

For reference:
https://www.php.net/manual/en/function.get-debug-type.php
https://www.php.net/manual/en/function.gettype.php

To keep this safe and simple to review, I'm only changing cases where
the type is immediately used in an exception message.

Change-Id: I325efcddcb58be63b1592b9c20ac0845393c15e2
2024-07-31 19:24:39 +02:00
Reedy
b52a8addf5 Drop writeapi userright
Bug: T294397
Depends-On: Ib34228a18917e404517d45e539bd786419d9c401
Change-Id: Ifad2edc782b36d21c8c67fecde7f011dce02c11b
2024-07-31 11:10:50 +00:00
STran
311774c033 Filter temporary accounts as anonymous in ApiQueryRecentChanges
Edits from temporary accounts are considered anonymous edits.
ApiQueryRecentChanges doesn't correctly reflect this and needs to be
updated to correctly return temporary account edits as anonymous (and
similarly, not to return them when requesting !anon)

- Update the anon|!anon query to accomodate temporary accounts

Bug: T370803
Change-Id: Ica5225422ea53d2aa3a84b86d9c2f14832a34ed4
2024-07-29 11:00:22 +01: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
Umherirrender
2e6b634176 api: Hard-deprecate ApiPageSet::get*Titles
The following functions are now hard-deprected:
- ApiPageSet::getTitles
- ApiPageSet::getGoodTitles
- ApiPageSet::getMissingTitles
- ApiPageSet::getGoodAndMissingTitles
- ApiPageSet::getRedirectTitles
- ApiPageSet::getSpecialTitles

Bug: T339384
Depends-On: Ie117ac8417e7f62ef3f199312a7f57df205900b2
Change-Id: I9533f89bbd370bcec43ca37200b2fedd0610183f
2024-07-20 00:11:55 +02:00
Umherirrender
856947391f api: Add a ratelimit test for action=purge
Follow-Up: Ifb19cc195a51f5521f8365ab26b3cdb56429e0fb
Change-Id: Ie1179a046d7d4dd68aca938593e83aadc578d23b
2024-07-12 22:32:22 +02:00
jenkins-bot
71285104f5 Merge "Add namespace to the root classes of ObjectCache" 2024-07-10 11:58:53 +00:00
jenkins-bot
3fc5ec3616 Merge "RecentChange: Replace use of legacy error arrays" 2024-07-10 11:40:11 +00:00
Bartosz Dziewoński
252bacff34 RecentChange: Replace use of legacy error arrays
Replace uses of soon-to-be-deprecated methods:
* ApiBase::errorArrayToStatus
* PermissionStatus::toLegacyErrorArray

Deprecate and replace uses of:
* RecentChange::doMarkPatrolled

Change-Id: I2311d1fa3772ba6be378ad6f497ed4c0df9b7aa8
2024-07-09 21:48:34 +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
Bartosz Dziewoński
b5fb2b724a ApiFormatTestBase: Fix test failures with extensions
Many tests were failing for me locally with CentralAuth installed.

Change-Id: I3e4e28c49e7b7906e81ca9b78ddc20b6de2ca7d3
2024-07-08 00:14:20 +02:00
Kosta Harlan
37306f5efb
ApiEditPageTest#testCreateImageRedirectAnon: Disable temp user feature
Why:

- The test checks for anon edit functionality specifically

What:

- Disable temp user feature for this test

Bug: T365669
Change-Id: I856ff3cb5ed64fd2d46a7cffc5084415f66ee536
2024-06-27 13:42:52 +02:00
jenkins-bot
78f6e3a602 Merge "ApiParseTest: Set a user in method call that generates log entry" 2024-06-26 12:54:45 +00:00
Kosta Harlan
0332b96e51 ApiParseTest: Set a user in method call that generates log entry
Why:

- Anon authority will generate manual log entries with an anonymous
  actor, which won't work with temp accounts enabled

What:

- Set the context user to a regular account before calling
  ::setVisibility on a list from RevisionDeleter

Bug: T365669
Change-Id: I3a813c69abcc715eec5048acc316d1fb43242b01
2024-06-26 11:37:48 +00:00
Kosta Harlan
638117c424
ApiQueryWatchlistIntegrationTest: Disable temp account in anon edit
Why:

- The test class does anonymous edits, but did not first disable temp
  user creation

What:

- Disable temp user creation before attempting an anonymous edit
- Enable temp account feature when calling doTempPageEdit
  - Remove call to enableAutoCreateTempUser in testShowAnonParamsTemp, as
    it's no longer needed

Bug: T365669
Change-Id: I2ce83d5703ecc75fe680d7ddb44aa406c26c4df5
2024-06-26 13:13:54 +02:00
Kosta Harlan
059d155dd3 ApiQueryRecentChangesIntegrationTest: Fixes for temp accounts
Why:

- This test does not pass when temp accounts are enabled

What:

- Set disableAutoCreateTempUser when doing an anon page edit
- Set a valid pattern for the temp user name

This patch does not fix testUserPropParameter but does solve the other
failures for this class.

Bug: T365669
Change-Id: I24b3ff10c6275a9c13c3f07d97ea14581f975067
2024-06-26 10:55:32 +00:00
Kosta Harlan
c7c1404d27 ApiQueryUserContribsTest: Disable temp account feature
Why:

- This test exercises code that checks for IP edits

What:

- Disable temp user feature for this test class

Bug: T365669
Change-Id: If385b71b76c16f9276c3973a02ca0c888b47d3a3
2024-06-26 10:55:32 +00:00
Kosta Harlan
a64e3d6c3a ApiRevisionDeleteTest: Use registered authority for tests
Why:

- Anon authority will generate manual log entries with an anonymous
  actor, which won't work with temp accounts enabled

What:

- Switch test cases to use registered authority mock

Bug: T365669
Change-Id: I4d3a79506d2f1fc744fc32b75e560f084738bdd7
2024-06-26 10:55:32 +00:00
Kosta Harlan
534ecdd49c ApiTestCase: Set request context user to session user
Why:

- In some situations (e.g. tests in ApiRevisionDeleteTest),
  the context user ID / name was being unset by code in Session

What:

- Set the session user to the request context user

Bug: T365669
Change-Id: Ife2cc31133bafb6a2c0adfeebcb2e1a139f25f48
2024-06-26 10:55:32 +00:00
jenkins-bot
291aab76dd Merge "ApiEditPageTest: Set a user in method call that generates log entry" 2024-06-26 10:54:41 +00:00
Kosta Harlan
6a938585b3 ApiEditPageTest: Set a user in method call that generates log entry
Why:

- When temp accounts are enabled, creation of new log entries needs to
  be associated with a named user account or temp account

What:

- Set the context user to a regular account before calling
  ::setVisibility on a list from RevisionDeleter

Bug: T365669
Change-Id: I1be6924a92309ea5da75df37910949440e23c937
2024-06-26 10:27:51 +00:00
Bartosz Dziewoński
0c2fb030e2 Message: Rename 'interface' prop because of syntax highlighting
Some syntax highlighters, in particular Gerrit's, incorrectly handle
code that uses a property named 'interface' (which is a PHP keyword).
https://phabricator.wikimedia.org/F55884039

Rename it to avoid problems.

Message isn't '@stable to extend', so this is not a breaking change.
I couldn't find any extensions that refer to it anyway.

Change-Id: I6676421222921b7bb1aeeefef79dd06072c1c2ac
2024-06-26 02:04:59 +00:00
jenkins-bot
a1d3e66790 Merge "ApiChangeContentModelTest: Disable temp accounts for anon test" 2024-06-25 21:53:55 +00:00
jenkins-bot
1436e324e7 Merge "ApiComparePagesTest: Disable temp accounts for anon tests" 2024-06-25 21:42:55 +00:00
Kosta Harlan
5042215d85
ApiComparePagesTest: Disable temp accounts for anon tests
Bug: T365669
Change-Id: I3b641fe8e93e3a302092c5097e87b4c3de2e7225
2024-06-25 22:05:28 +02:00
Kosta Harlan
60310c37d0
ApiChangeContentModelTest: Disable temp accounts for anon test
Bug: T365669
Change-Id: Ib6e789f0b2363118890c8ccc04316d9cd08fcf5b
2024-06-25 22:01:56 +02:00
Wandji69
c257e2276c Replace db with getDb for Tests
Bug: T316841
Change-Id: I29e535e8ee9b5641a4546d53b98cd5060d39681d
2024-06-23 23:47:56 +01:00
jenkins-bot
52e66c8aa8 Merge "api: Rewrite adrto/from/prefix handling to use expression builder" 2024-06-18 14:16:23 +00:00
Umherirrender
883b3f08fb api: Rewrite adrto/from/prefix handling to use expression builder
For a deduplication the raw sql is used as string key in an array.
Now only the search term is part of the key, build the sql a bit later,
as objects not usable in array keys.

The deduplication is needed when namespaces have different first letter
configs as happen with $wgCapitalLinks = false for all namespaces except
the hard coded like user and mediawiki with talk.
Searching for lower case titles splits the query

Bug: T361023
Change-Id: Ia4e29d1d4d816f354318ef443ae19c954fd52274
2024-06-17 22:36:10 +02:00
jenkins-bot
5f49cafa64 Merge "ApiQuerySiteinfo: Use TempUserConfig class" 2024-06-14 14:25:24 +00:00
jenkins-bot
a0fd50682e Merge "TempUserTestTrait: Use an array for config overrides when disabling" 2024-06-14 14:03:49 +00:00
Kosta Harlan
2ed2467a7a
ApiQuerySiteinfo: Use TempUserConfig class
Why:

- Using TempUserConfig is more flexible as it doesn't require us to know
  about the internal details of the AutoCreateTempUser config object

What:

- Use TempUserConfig service instead of loading the AutoCreateTempUser
  object
- Remove properties from ApiQuerySiteInfo that don't already have
  getters. If someone has a need for more this information to be exposed
  in ApiQuerySiteInfo, they can be added in a separate patch
  - This seems compatible with the goals of T335532 which was about
    making it possible to discover via the API if an action would result
    in a temp account
- Implement __toString for Pattern, so that it can be used in
  ApiQuerySiteInfo

Bug: T335532
Change-Id: Ica84b3e9b9865b8b83a9e9e513c99cd2e47661c9
2024-06-13 22:11:27 +02:00
Kosta Harlan
cef704c72a
TempUserTestTrait: Use an array for config overrides when disabling
Why:

- Consistency with the enableAutoCreateTempUser method
- Allows for overriding config properties (e.g. 'known')

What:

- Use an array as the parameter for `disableAutoCreateTempUser` instead
  of a string

Change-Id: I1a495cc83effcf92364fa489f779c5f4bf2d29b9
2024-06-13 21:42:35 +02:00
frankie
17b2250683 Migrate MediaWiki.editstash to statslib
Modifies incrStatsByContent in order to migrate cache_misses, cache_hits to Prometheus backend

Bug: T359465
Change-Id: I78afac7437bc2849b64f43c23477d702b94e907b
2024-06-13 17:11:33 +00:00
Tim Starling
b4591f1960 user: Add "global" parameter to ApiOptions
Add a "global" parameter to ApiOptions which allows it to update or
override global preferences.

Bug: T323076
Depends-On: I686c0091768ed330683fff89201fae4f93b8a1c4
Change-Id: Ieb2d0c0d0da5c51b2a47ed8a967a47b4e7ad4577
2024-06-13 15:22:47 +00:00
Bartosz Dziewoński
da1c476b8f Add "implements/extends Stringable" to more classes and interfaces
Follow-up to ccd423225f,
which missed some classes and all interfaces.

Change-Id: Ida0477d548c767f116eb8f465090a19f7986f7ca
2024-06-13 16:06:14 +02:00
Bartosz Dziewoński
ccd423225f Add "implements Stringable" to every class with "function __toString()"
In PHP 8, but not in PHP 7.4, every class with a __toString() function
implicitly implements the Stringable interface. Therefore, the
behavior of checks like "instanceof Stringable" differs between these
PHP versions when such classes are involved. Make every such class
implement the interface so that the behavior will be consistent.

The PHP 7.4 fallback for the Stringable interface is provided by
symfony/polyfill-php80.

Change-Id: I3f0330c2555c7d3bf99b654ed3c0b0303e257ea1
2024-06-13 00:23:39 +00:00
Tim Starling
94151fcde9 user: Move "reset kinds" concept to PreferencesFactory
Fix the dependency loop between PreferencesFactory and
UserOptionsManager by moving the concept of "reset kinds" or "option
kinds" to PreferencesFactory.

Note that this is a half-baked feature from 2013 (I5f9ba5b0dfe7c2ea)
that is not really used for anything. Apparently only the "all" and
"unused" kinds are used.

The strong dependencies on PreferencesFactory internal details show that
this feature belongs in PreferencesFactory. But UserOptionsManager can
reset "all" preferences without help from PreferencesFactory, so add a
helper for that.

The rationale for putting it in UserOptionsManager was that eventually
all preference definition information should move to UserOptionsManager
(T250822). I don't agree with that. UserOptionsManager is the key/value
store which backs PreferencesFactory. I need to refactor it further for
T323076 and it will help to have these concepts be separate.

Hard-deprecate UserOptionsManager methods resetOptions, listOptionKinds
and getOptionKinds. Add convenience methods to replace calls to
resetOptions().

I couldn't understand the logic in resetOptions(). Why was it copying
old values instead of just omitting them? Why was it assigning null but
only for "all"? setOption() had a documented method for resetting an
option to the default, so I just used that.

Bug: T323076
Depends-On: I1ed0a1a9f6492fb50254104fa4bc9f2130218323
Change-Id: I900fd4a48c96d91491eae54824e7bf02a004843d
2024-06-11 23:50:21 +00:00
jenkins-bot
9f0144af08 Merge "Use StatusValue::getMessages() instead of deprecated methods" 2024-05-29 02:12:05 +00:00
Bartosz Dziewoński
cfcfe299e2 Use StatusValue::getMessages() instead of deprecated methods
This commit replaces some of the uses of getErrorsArray(),
getWarningsArray(), getErrorsByType(), and getErrors().
In many cases the code becomes shorter and clearer.
Follow-up to Ibc4ce11594cf36ce7b2495d2636ee080d3443b04.

Change-Id: Id0ebeac26ae62231edb48458dbd2e13ddcbd0a9e
2024-05-18 14:45:54 +00:00
jenkins-bot
440edd14fd Merge "Add namespace and deprecation alias to CssContent" 2024-05-18 00:05:32 +00:00
Ebrahim Byagowi
1e4f59b724 Add namespace and deprecation alias to WatchedItemQueryService
This patch introduces a namespace declaration for the
MediaWiki\Watchlist to WatchedItemQueryService and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Ib1b5c19c89087940987730939e84c8cd35cd3760
2024-05-18 01:50:29 +03:30
Ebrahim Byagowi
6316a253aa Add namespace and deprecation alias to CssContent
This patch introduces a namespace declaration for the
MediaWiki\Content to CssContent and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I6ab25787893cb2195f8cd2ba125ed8dd5a60de43
2024-05-18 01:48:53 +03:30
Ebrahim Byagowi
ccde5085de Add namespace and deprecation alias to JavaScriptContent
This patch introduces a namespace declaration for the
MediaWiki\Content to JavaScriptContent and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I87c17327911e28a461feaf2ff46242454cff257a
2024-05-17 13:51:18 +03:30
Ebrahim Byagowi
a717db8e60 Add namespace and deprecation alias to FormatJson
This patch introduces a namespace declaration for the
MediaWiki\Json to FormatJson and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: I5e1311e4eb7a878a7db319b725ae262f40671c32
2024-05-16 16:28:01 +03:30
jenkins-bot
37d2a081ba Merge "block: Deprecate and stop using $wgBlockTargetMigrationStage" 2024-05-11 00:47:21 +00: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
DannyS712
ee75e1c6f9 Tests: remove a bunch of DummyServicesTrait-related comments
Not sure why I added these, it should be clear from the method names

Change-Id: Ie49881e6f31fad52bb65b0d2ac3e9379dbb7bfc5
2024-05-10 04:07:59 +00:00
Bartosz Dziewoński
f0c7fa9234 Move section edit links outside headings (new heading HTML)
Legacy parser can now output headings using a more accessible markup,
which is also identical to the markup used by the Parsoid parser.

Changes to client-side JS and CSS necessary to support the new markup
have already been merged in earlier commits.

includes/skins/Skin.php
includes/ServiceWiring.php
* Define a new skin option, 'supportsMwHeading', which can be used
  to toggle the new markup per-skin.
* Update the built-in fallback skin to enable it. This affects the
  output in parser tests.

docs/config-schema.yaml
includes/config-schema.php
includes/config-vars.php
includes/MainConfigNames.php
includes/MainConfigSchema.php
* Add a new configuration setting, 'ParserEnableLegacyHeadingDOM',
  which can be used to toggle the new markup per-site.

includes/OutputTransform/Stages/HandleSectionLinks.php
* Output new heading HTML for skins that enabled the option.

tests/*
* Duplicate parser tests that cover heading generation to cover both
  new and old markup. Update other parser tests to use new markup.
* Add some unit and integration tests for the behavior of the skin
  option and some parser tests for edge cases of the new markup.

Bug: T13555
Change-Id: I1180169a8e83af834c2984ba16089e6277f2a8dd
2024-05-06 12:25:33 -04:00