Commit graph

39 commits

Author SHA1 Message Date
Amir Sarabadani
2df0c99fe0 Migrate several subqueries to use SQB
Bug: T344971
Change-Id: I278a6efb7efefadd5db7b52490300811669372df
2023-10-31 15:54:55 +01:00
Amir Sarabadani
d5adc3ca65 Mass migrate simple cases to use expression builder
Done via
'([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \)
to:
$3->expr\( '$1', '$2', $4 \)

And
'([A-Za-z_\.]+) IS NULL OR ([A-Za-z_\.]+) ?(=|!=|<|<=|>|>=) ?' . (\$db(?:r|w|))->addQuotes\( (.+?) \)
to:
$4->expr( '$1', '=', null )->or\( '$2', '$3', $5 \)

Bug: T210206
Change-Id: I109bf2a712bdefa9e074f775b1bee41ac5b9d665
2023-10-26 16:59:19 +00:00
James D. Forrester
b16be7a36c Namespace TitleFormatter under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ic2d59eb6764b1a273ed7162ecabf641f638b8f66
2023-09-19 05:17:18 +00:00
Umherirrender
6e0065ad20 Simplify WHERE conditions with field IS NULL
Reduce raw sql fragments on simple compares

Change-Id: I3f2340dfdbf5197cc22546911e6c5653dc5a6269
2023-07-24 19:22:36 +02:00
daniel
5bc235c966 Convert PageRedirectHandlerTrait to PageRedirectHelper
Using a helper object instead of a trait allows for dependency
injection through PageRestHelperFactory. This will make it easier to add
language variant redirects in the next step.

Change-Id: I1d4f26c380797e28e1b97051400bb9b1301b89ab
2023-06-20 21:15:24 +02:00
Amir Sarabadani
775bfb6dc3 Rest: Migrate rest of handlers to IConnectionProvider
Instead of using LoadBalancer

Bug: T330641
Change-Id: I276da1460d9bbc6159fb2d496220b9cd2d2c9261
2023-04-20 14:38:39 +02:00
msantos
63deedc94c add redirects to page/history and link endpoints
* Add normalization redirects for page/history, page/history/counts
and links/language endpoints

Bug: T301372
Change-Id: I731fbfdcfb538c3e8a5dd32349ebaa0e642bf338
2022-12-09 12:17:38 +00:00
Bartosz Dziewoński
f0baa9c418 Use buildComparison() instead of raw SQL in REST API
Bug: T321422
Change-Id: I665451fc6989bec2cdfa7cb45a0cda6aabaffe3f
2022-10-22 21:35:40 +02:00
Umherirrender
e4e2ce4690 Remove references to revision_actor_temp, aliased as temp_rev_user
The alias temp_rev_user was used by RevisionStore::getQuryInfo

Bug: T215466
Follow-Up: I66b2cb8653252e720c897351065978119f040ba7
Change-Id: I4b4c2afbe942ad36fd96f3d9c604c836ffc6d8f7
2022-09-06 20:17:56 +02:00
Umherirrender
6caf78c2c8 phan: Remove PhanPossiblyUndeclaredVariable suppression
Make phan stricter about conditional variable declaration
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T259172
Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
2022-03-30 19:47:15 +00:00
Umherirrender
7aa0884029 phan: Remove PhanTypePossiblyInvalidDimOffset suppression
Make phan stricter about array keys
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T304887
Depends-On: I3105a5fd4826f8667b5232834defc5ec93be32a1
Depends-On: Ie9610a6e83731468311edb3ed17f80fc509de385
Change-Id: I701f12ab94478c3b8e7fd82110ade74a8e6b04ef
2022-03-28 23:26:49 +02:00
Tim Starling
d3d8dc9965 Schema migration for revison_actor_temp table removal
Introduce a new schema migration stage in which rev_actor is used
directly and the revision_actor_temp table is no longer needed. This
becomes the new "new" stage whereas the previous situation is now
termed SCHEMA_COMPAT_TEMP.

Introduce migrateRevisionActorTemp which copies data from
revision_actor_temp to rev_actor. The code is similar to
migrateImageCommentTemp.php except that it doesn't delete from the old
table.

Partial revert of c29909e59f. That change removed direct
references to $wgActorTableSchemaMigrationStage and made queries
involving revision_actor_temp be unconditional. Such changes need to be
reverted to make the use of revision_actor_temp be conditional again.

In ActorMigrationTest, I compacted provideGetJoin() and
provideGetWhere(), removing most of the duplication between expected
values. I gave all the stages a short name, and mostly used the name in
providers.

Bug: T275246
Change-Id: I7498107dd6433ab7de5bf2e7b3fe2aa5e10e345d
2021-07-14 08:29:04 +10:00
DannyS712
f057d2253c Replace deprecated uses of PermissionManager with GroupPermissionsLookup
In a few places where a PermissionManager is used
but only GroupPermissionsLookup is needed

Also update references to the class in PermissionManager
that referred to it as GroupPermissionLookup

Change-Id: I5d7a13900852a38768a106aeee1ce012c3a04ea2
2021-05-26 05:47:21 +00:00
Petr Pchelko
4ca16e8d08 Eliminate use of Title object in REST infrastructure
Change-Id: I585f0f23cac5f6dc2a4879f69f7b83828fda3dd3
2021-05-05 18:54:58 -07:00
Petr Pchelko
3a2e8883b4 Rest: use Authority in all core handlers
Bug: T239753
Change-Id: Idf2229255f49514dd8b68bf63573c5b619b4f2f1
2021-01-21 18:22:33 -06:00
Ppchelko
bdb5f394d3 Revert "Enhance GroupPermissionsLookup and use it."
This reverts commit 900c6663b0.

Reason for revert: breaks Parsoid CI. Instead of fixing the test in presence of the FlaggedRevs hook, I would rather convert DefaultPreferencesFactory to Authority and fix the tests once instead of doing it twice.

Change-Id: Iaa440a9804c9ed97339e737162ef64ccf29ceb51
2021-01-12 04:48:49 +00:00
Petr Pchelko
900c6663b0 Enhance GroupPermissionsLookup and use it.
Added new methods:
- ::getGroupsWithAnyPermissions
- ::getGroupsWithAllPermissions
- ::groupHasAnyPermission
- ::groupHasAllPermission

Replaced relevant calls to PermissionManager with
calls to GroupPermissionsLookup.

Bug: T254537
Change-Id: I0b9c3352c5bebc94e1649239fe0527144e7c2eb2
2021-01-11 11:05:54 -06:00
Gergő Tisza
43651eb161
Make the documentation of change tags easier to access
Add constants for the core change tags, and use the constant's
phpdoc to describe them. Also document ct_params format.

Change-Id: I03e70df3598ad71d80a8d09af8a314e7200a1264
2020-11-10 22:02:21 -08:00
Ostrzyciel
435d5f4d55 Add mw-manual-revert change tag
Based on the patch that introduces manual revert detection, this is
to create a software-defined change tag that will be applied to all
edits that restore a page to an exact previous state. This is also
for consistency with mw-undo and mw-rollback that will make a
"reverted" tag appear on reverted edits in the future.

Note about the REST API tests: in the next patch in this chain
I encountered even more issues with comparing returned changed tags
with expectations, so I decided it'd better if we just checked the
change tags applied manually in these tests. Otherwise we can run into
nasty race conditions, as the reverted tag is processed after sending
the response to client in the deferred update. It also makes the test
hard to maintain.

Bug: T256001
Change-Id: Ic367886f39faedcb823222b7d63bf4d5cb236ae9
2020-07-16 13:29:12 +02:00
daniel
2051b84e5f PageHistoryHandler: fix self-reference route
THis introduces Handler::getRouteUrl() and uses it in
PageHistoryHandler() to generate self-reference links to adjacent
segments of the response.

Bug: T252566
Change-Id: Ie7b2c6cc63c8a499d4714336b917a9e3328294ca
2020-06-08 18:56:26 +02:00
Reedy
b80a9f4f6a Fix even more PSR12.Properties.ConstantVisibility.NotFound
Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
2020-05-16 00:51:14 +01:00
daniel
b872292b77 PageHistoryHandler: use getRouteUrl.
Make use of new utility function.

Change-Id: Ib768622de09435d1dfe31411dc671e53e56286cc
2020-03-26 21:31:41 +01:00
daniel
22561b64a7 REST endpoints: Add etag and last-modified headers
Modified endpoints:
* /v1/page/{title}/history
* /v1/revision/{id}/bare
* /coredev/v0/page/{title}/links/language
* /coredev/v0/page/{title}/links/media
* /coredev/v0/file/{title}

Bug: T238374
Change-Id: I3ddf8fafc17eba3aec724a445d38af98bbc74dc1
2020-03-26 00:18:34 +01:00
Petr Pchelko
e79b72beeb PageHistoryHandler: Undefined index 'query'
Bug: T244184
Change-Id: Ida350938d2a3cbc7be936763108253efb188c42c
2020-02-10 08:21:08 -08:00
Umherirrender
92a0db8165 Pass 1 always as string to IDatabase::select and friends
Column names or other sql fragments are strings, not integer

Change-Id: I7950b6e7ce4fa3b97c8b8ed55c8d7d0119eaac7e
2020-01-11 00:36:13 +00:00
James D. Forrester
4f2d1efdda Coding style: Auto-fix MediaWiki.Classes.UnsortedUseStatements.UnsortedUse
Change-Id: I94a0ae83c65e8ee419bbd1ae1e86ab21ed4d8210
2020-01-10 09:32:25 -08:00
Tim Starling
377e1084e6 REST: Make getValidatedParams() always return an array
To stop phan from flagging every usage as "suspicious nullable".

Bug: T235355
Change-Id: Ibdcd9f4e9761858e68fae1262187a3e99affa6f9
2019-11-15 04:43:20 +00:00
Petr Pchelko
5b77ce93ad REST: Deduplicate and normalize REST error message names
Bug: T237568
Change-Id: I6f35757f948b34a6a641808db8e5f98983054b7b
2019-11-08 09:37:26 -08:00
Petr Pchelko
84b9efa892 REST: Introduce 'minor' flag in revision response
Bug: T237562
Change-Id: I8460e7affe2579d06ed3523d49692cb89b459e5f
2019-11-07 10:37:07 -08:00
Max Semenik
f1c9cf8879 Minor cleanups
* Identifier case
* Returning a void function result
* Unused variable
* Missing documentation

Change-Id: Ibfd2fc5ae1d91c7c9c6a34bcd4523384d3bca576
2019-11-03 17:10:23 -08:00
Bill Pirkle
402eb6a672 Add "minor" to available REST API history filters
Add "minor" as an allowed filter type in PageHistoryHandler.php,
to retrieve only revisions flagged as minor edits

Bug: T235660
Change-Id: Ia2886e979c5cdb1c742149c23ba90474ae5a0ed1
2019-10-28 10:48:05 -05:00
Petr Pchelko
cb3248934d REST: Correctly quote timestamps for page history handler.
Change-Id: I43cb718ee7a4826e99486e4e888143e2d881a0c5
2019-10-24 08:56:08 -07:00
Petr Pchelko
fa7520ed84 REST: add size and delta to revision metadata endpoint response.
Bug: T231588
Change-Id: Ib35a87d5d9c7c088c62423677163e4b243c92477
2019-10-23 14:12:22 -07:00
jenkins-bot
78a2b8f485 Merge "Fix new phan errors, part 5" 2019-10-20 01:39:44 +00:00
Daimona Eaytoy
d3252fc870 Fix new phan errors, part 5
Some of the errors are suppressed because they're phan false positives.
The idea behind this is that they'll be fixed in a future version of
phan, and we'll just have to remove the suppressions.

Note: I'm disabling UnusedPluginSuppression so that we can start suppressing
issues even if they're still disabled. The sniff should be re-enabled
as soon as we upgrade phan.

Bug: T231636
Change-Id: I0f7fa06a9e03fbb86c7a5eb6e50a850bb258a7f7
2019-10-18 20:45:53 +00:00
Petr Pchelko
a5bf77dc44 REST History and compare endpoints followups.
- Improve access checks for history,compare,revision handlers.
- Ensure that null is not returned in place of empty string

Bug: T235146
Bug: T231588
Bug: T235560
Change-Id: I2a15c7577fe67055367147c4f6b982c9fcdf8535
2019-10-16 15:51:33 -07:00
Petr Pchelko
bea61a1d2e Set unknown/restricted properies to null.
Bug: T235146
Change-Id: I58a0a892461bb7ec799d2a5bd503751bd18152b4
2019-10-10 19:10:40 -07:00
Bill Pirkle
33f42bddb8 Improvements to Core REST API GET page history handler
Fix/improve several issues with the page history handler:
- recognize the logged in user's permissions
- fixes to the "bot" filter query
- fixes to error message construction
- remove extaneous space in response data construction

Bug: T235146
Change-Id: I5364a8a7d7492ab48e1dc84db0880475177dabd3
2019-10-10 14:41:48 -05:00
Bill Pirkle
967988bd3e Core REST API handler for GET page history
Handler to return page history via the Core REST API.
Includes two parameters for pagination:
  older_than
  newer_than
Also includes a "filter" parameter with possible values:
  bot
  anonymous
  reverted

Bug: T231558
Bug: T231597
Change-Id: Ie35d8be6c96b468794f8acf80a5fb50e4cd17c3c
2019-10-09 09:23:54 -05:00