Commit graph

612 commits

Author SHA1 Message Date
James D. Forrester
3ed6668745 Formally deprecate code marked with @deprecated
Some of these have been marked in-code as deprecated for a long while,
but haven't ever been announced in the RELEASE-NOTES (and later,
HISTORY) file, so let's mark them up now so we can get the ball rolling
at least.

Per Gergo, the AuthManager one was 'born deprecated' and should only
have been used by humans also reading the deprecation notice given in
the code, and indeed no uses are known to code search, so also emit
deprecation warnings there immediately; others will have to wait until
uses have been migrated.

Change-Id: I0c1c71d8f4293623039302da35d58d2a24367e97
2024-05-03 18:25:03 +03:00
Jon Robson
b6adccbed6 Special:NewPages should generate markup consistent with other pager pages
This will allow us to style NewPages consistent with other Minerva
special pages.

Update getStartBody and getEndBody to be consistent with ContribsPager,
now that the output of the UL is output by mGroupByDate

Bug: T360843
Change-Id: I3424d8f4f7a40ff60827065e83532315ba35dfd3
2024-04-17 16:30:40 -07:00
jenkins-bot
b48017285d Merge "RecentChange: Avoid duplicate patrol log entry after patrol conflict" 2024-03-02 18:03:23 +00:00
xiplus
f7552491c4 RecentChange: Avoid duplicate patrol log entry after patrol conflict
Check the affected rows count to detect a patrol conflict, which is
when the database query succeeds, but it was a no-op because another
request (possibly from the same user, or someone else) marked it as
patrolled already.

We detect it using the `rc_patrolled` condition because without it,
affectedRows() would always return 1, as the previous update condition
could match either the patrolled or patrolled version of the row.

Bug: T196182
Change-Id: I2aa4f2f752a40657883e0a6714dbb175c9d2fdcb
2024-03-02 17:41:16 +00:00
James D. Forrester
35b2542895 Namespace includes/cache
Bug: T353458
Change-Id: Ic3f3168ef17113f5fb3ec11e0a47f52d65eefba9
2024-02-20 10:28:03 -05:00
James D. Forrester
060a1b1668 Replace last remaining wfGetDB() calls in core, except ResourceLoader
Bug: T330641
Change-Id: I6d30af6ff9f667e367d39befb80c2bb0bf5fb29e
2024-02-14 11:02:01 -05:00
Amir Sarabadani
ea268ddcfd Move away from wfGetDB() calls
If we are serious about getting rid of wfGetDB(), we should start
replcing callers with proper replacement.

These classes don't have any injection so it doesn't make sense to
introduce it for this specific usecase.

Bug: T330641
Change-Id: I645f67324d441288c63787c7e42390b59106c585
2024-02-12 21:23:38 +01:00
James D. Forrester
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
James D. Forrester
0398171625 ChangesList: Switch from mixed Xml and Html classes to pure Html ones
Bug: T356544
Change-Id: Ic7c32515357610bd89d0e3965107d89a3d01f3f4
2024-02-05 21:54:21 +00:00
Arlo Breault
fc2a7030a8 Avoid misnesting div in span in OldChangesList
When OldChangesList is used, the mw-changeslist-line-inner that the
mw-changeslist-links is nested in is a span.

mw-changeslist-links is formatted as inline-block in skinStyles.less as
it is.

Bug: T275230
Change-Id: If97aa95472a73fce1f73c65dfcad961d24cf7e37
2024-01-25 17:37:25 -05:00
Daimona Eaytoy
7acfa6a0a5 Replace more instances of unchecked MWException
Most (all?) of the remaining usages are caught somewhere and will be
migrated later.

Bug: T328220
Change-Id: I5c36693a5361dd75b4f1e7a0bab5ad48626ed75c
2024-01-23 16:20:53 +00:00
Amir Sarabadani
014bc61006 Remove more indirect calls to IDBAccessObject::READ_* constants
Found via (?<!IDBAccessObject)::READ_

We are planning to deprecate and remove implementing IDBAccessObject
interface just to use the constants.

Bug: T354194
Change-Id: I89d442fa493b8e5332ce118e5bf13f13b8dd3477
2024-01-23 15:42:38 +01:00
Bartosz Dziewoński
e4c7272976 Change uses of getDBLoadBalancerFactory() to getConnectionProvider()
Update cases where one of the IConnectionProvider methods is called
immediately.

This doesn't really change anything, but I hope it helps promote
getConnectionProvider() as the common way to do this.

Follow-up to 8604c384f6.

Change-Id: Id0e7d02bab0c570343c2b1f03c70b44ee39db112
2024-01-22 22:27:45 +01:00
Dogu
f73d342b29 Replace deprecated MWException with InvalidArgumentException
Change-Id: I14391c156f66e9686f82b93d55e0bbcd951f8057
2024-01-07 06:18:13 +00:00
Dogu
43fcf91171 Consolidate duplicate branch in 'switch' statement
Merged duplicate branches in the switch statement related to the
RecentChange::SRC_NEW case, combining them with existing cases
for RecentChange::SRC_EDIT and RecentChange::SRC_CATEGORIZE.

Change-Id: If09288dcfdf40b4cf095a568eacac3621956e063
2024-01-04 00:48:16 +00:00
Amir Sarabadani
a778d3fea7 Inline once-called short private methods to its caller, part 1
This makes the code easier to read to avoid jumps and improves
encapsulation by not allowing the rest of the class having access to the
logic. Of course, if needed then some code can be refactored out again
but for now let's not do YAGNI.

Change-Id: Ic37524e386fc04fd67e33768417ff8425f85b0ca
2023-12-18 23:43:32 +00:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Amir Sarabadani
2e1cd74ad2 Migrate off wfGetDB() in more places to ICP
This function is uber-deprecated, meaning even its replacement is
deprecated, We have already migrated in static functions and more.

In this batch, all calls have been migrated that there is already a call
to MediaWikiServices::getInstance() making the migration easier. Of
course in most cases, they should eventually turn into proper service
injection but this at least makes it clear what services should be
injected.

Also removing "category" group since we are removing all groups except a
handful from mw (see T263127 for more information).

Bug: T330641
Change-Id: I90cd35ee45a37eb6e6bf7a531cc8f75effbd0328
2023-11-20 14:40:28 +01:00
Amir Sarabadani
136fa38a4a Migrate to IConnectionProvider methods in more places
Getting rid of uber-deprecated wfGetDb() and recently deprecated
LB::getConnection.

Bug: T330641
Change-Id: Ifd4b4e01f2a120ad6db517cc8fd2eb6b11b72bc9
2023-10-05 19:51:20 +02:00
James D. Forrester
98f50660cb Drop RecentChange::getPerformer(), deprecated since 1.36
Change-Id: I10cd61f6088da3069d7e29e5fe4355747e83236e
2023-09-27 22:41:21 +00:00
Amir Sarabadani
f5abfb8d58 Bump codesniffer to 42.0.0
Most noisily, this enables MediaWiki.Arrays.OneSpaceInlineArray.

Change-Id: I8ab11399c67ce7e3ab1b6249b591452774393428
2023-09-27 15:06:32 -04:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
James D. Forrester
468e69bccc Namespace Sanitizer under \MediaWiki\Parser
Bug: T166010
Change-Id: Id13dcbf7a0372017495958dbc4f601f40c122508
2023-09-21 05:39:23 +00:00
James D. Forrester
3851805f64 Namespace remaining User-related classes under \MediaWiki\User
Bug: T166010
Change-Id: Ibda1e8be0f23c6262a32b607f8260cad36f188fc
2023-09-20 09:12:08 +01:00
James D. Forrester
1d0b7ae1e2 Namespace User under \MediaWiki\User
Bug: T166010
Change-Id: I7257302b485588af31384d4f7fc8e30551f161f1
2023-09-19 19:18:16 +00:00
James D. Forrester
459cbb0494 Namespace remaining 'specialpage' files under \MediaWiki\SpecialPage
SpecialPageFactory is already here, but none of the others were yet.

Bug: T166010
Change-Id: I9689bf0a1ab329625e23669b99f019b96295fffd
2023-09-18 18:23:13 +01:00
James D. Forrester
5088626212 Namespace 'special' Pagers under \MediaWiki\Pager
They're under 'specials' because that's where they're mostly used,
but they're just another kind of Pager (shown by their use outwith
the MediaWiki\Specials hierarchy, which is a bad code smell for us
to review later).

Bug: T166010
Change-Id: Iad3f91582b723c1e6679525aa852ffdfd8c6d5ba
2023-09-18 18:23:13 +01:00
Daimona Eaytoy
f78fd3710d Add $wgRequest to phan's globals_type_map
The base phan config uses a file_exists check to determine whether to
use the namespaced class name, but it doesn't work when running against
core because MW_INSTALL_PATH isn't set. So specify the type in the local
config, and remove @phan-var annotations added in I6bbdbbe6.

Also use `::class` instead of string literals for classes.

Change-Id: I994a0ed32ea948253ed07ee3cc8868a0eaa6d8b9
2023-09-11 23:22:12 +02:00
Amir Sarabadani
5bd33d46ef Reorg: Move WebRequest to includes\Request
This has been approved as part of RFC T166010

Bug: T321882
Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
2023-09-11 21:44:34 +01:00
Daimona Eaytoy
3f35734ac0 Remove redundant empty() constructs
empty() only makes sense when the expression it checks is possibly
undefined, otherwise it's equivalent to a truthiness check with the
additional downside of suppressing errors when it's not wanted.

Replace it with simple truthiness checks, using strict comparison when
that seems to help with polymorphic variables.

These were caught by a bespoke phan plugin.

Change-Id: I52999e5286a0d9ad70b0da40b41b9f998ecb990e
2023-09-08 23:18:11 +02:00
Tim Starling
95bd40b25c In query builders, use insertInto() and deleteFrom() instead of insert() and delete()
The design principle for SelectQueryBuilder was to make the chained
builder calls look as much like SQL as possible, so that developers
could leverage their knowledge of SQL to understand what the query
builder is doing.

That's why SelectQueryBuilder::select() takes a list of fields, and by
the same principle, it makes sense for UpdateQueryBuilder::update() to
take a table. However with "insert" and "delete", the SQL designers
chose to add prepositions "into" and "from", and I think it makes sense
to follow that here.

In terms of natural language, we update a table, but we don't delete a
table, or insert a table. We delete rows from a table, or insert rows
into a table. The table is not the object of the verb.

So, add insertInto() as an alias for insert(), and add deleteFrom() as
an alias for delete(). Use the new methods in MW core callers where
PHPStorm knows the type.

Change-Id: Idb327a54a57a0fb2288ea067472c1e9727016000
2023-09-08 10:16:08 +10:00
Amir Sarabadani
e1b3323312 Migrate calls to wfGetDB() in static methods
wfGetDB() has been deprecated since 1.39 (or more?) and it's better to
inject LBF and call ::getReplicaDatabase() or ::getPrimaryDatabase()
which is not straightforward in classes but for static functions, there
is no way to inject the method so we can simply call
MediaWikiServices::getInstance()->getDBLoadBalancerFactory()

While I was here, I migrated one call to SelectQueryBuilder.

Bug: T330641
Change-Id: Idd2278cef647035dce05a2d461a620e145fe1167
2023-09-05 10:48:31 +02:00
jenkins-bot
a4ec56b1f2 Merge "ChangesList: Cache user links" 2023-08-24 04:17:46 +00:00
jenkins-bot
b9bc8572b0 Merge "mark various anonymous functions as static" 2023-08-23 22:59:21 +00:00
James D. Forrester
e7ff62ea22 RecentChange: Drop getEngine(), deprecated since 1.29
Change-Id: Iad19dc62c4a06ccdb553ed11b3390679c761e17e
2023-08-23 17:31:01 -04:00
Reedy
a1144dc7c5 mark various anonymous functions as static
Change-Id: Iefe896769359f0d32e52bf20aa03e1c3715d5074
2023-08-22 19:38:38 +00:00
Matěj Suchánek
02389446a5 ChangesList: Cache user links
Follow up to a468534. The caching added to RCCacheEntryFactory
would be utilized only by EnhancedChangesList. This should
improve performance for OldChangesList, too.

Bug: T341319
Change-Id: Ibb1907732c71d0783d1a627063debb2a484cafe7
2023-08-20 16:55:58 +02:00
jenkins-bot
dc412f3bb5 Merge "Cache some more repeated messages in changes lists" 2023-08-19 19:31:29 +00:00
Matěj Suchánek
cfad5d8d71 Cache some more repeated messages in changes lists
Change-Id: I635eaf947280fd1071e308b19715d581e1c1cb15
2023-08-19 14:32:58 +02:00
Amir Sarabadani
15a278189f Reorg: Move MWTimestamp to MediaWiki\Utils
Bug: T321882
Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
2023-08-19 05:53:40 +02:00
Matěj Suchánek
f3b25b3891 ChangesList: Call MapCacheLRU::makeKey
Also split the cache by context, like it's done
in ::insertTags. Follows-up 17deb8353b (I0b5e48ef5).

Change-Id: I5b539a63c3210a8cd1debb2ba625b0f2dedacc39
2023-08-16 03:31:00 +00:00
jenkins-bot
a8d3383444 Merge "Mass migrate Database::insert calls to InsertQueryBuilder" 2023-08-08 11:01:32 +00:00
Amir Sarabadani
98d6503f65 Mass migrate Database::insert calls to InsertQueryBuilder
Done automatically based on a php parser written on top of ANTLR4

Bug: T335377
Change-Id: Ie8fabc594edab18e55cb1d5bbf573762106e3d71
2023-08-07 19:44:27 +02:00
Timo Tijhof
17deb8353b objectcache: Add MapCacheLRU::makeKey() and adopt in ChangesList
This came up during code review of change I91588aebae7e49e3d3c.

Change-Id: I0b5e48ef52513f012bfbb460ab5a649178ebf255
2023-08-03 17:19:33 +00:00
thiemowmde
ef84619cd3 Consistently use LogicException for test-only methods
"BadMethodCallException" sounds like it would fit, but it does
have a very different meaning, described as "exception thrown if
a callback refers to an undefined method or if some arguments are
missing". This is not what's going on here. These are methods that
should only be called from unit tests.

This appears to be a common mistake, often copy-pasted.

Change-Id: Ib39e28f596a883481d5f526460a5c871c75f5313
2023-07-22 16:21:42 +00:00
jenkins-bot
0fadd34392 Merge "RecentChanges: Add process caching to RecentChanges UserLinks and Tags parsing" 2023-07-20 01:32:58 +00:00
ttomalak
a468534689 RecentChanges: Add process caching to RecentChanges UserLinks and Tags parsing
Rendering UserLinks or Tags requires parsing, which when run on thousands of records, adds up to a significant amount of processing time. More often than not, this can be optimized by storing already visited tags or user links as those "renders" will not change for the single request run and are repeated constantly on the list.

Bug: T341319
Change-Id: I91588aebae7e49e3d3cb77702cf28677b4a14c8d
2023-07-18 12:05:33 +02:00
Fomafix
9bf98ab9db EnhancedChangesList: Use HTML/CSS for collapsing
The collapsing on the enhanced changes list now works without
JavaScript.

Keyboard navigation is still supported but only the space and not the
return toggles the collapsing toggle button.

The <input type="checkbox"> element needs an unique identifier in the
`id` attribute and the same value must be in the `for` attribute of the
<label> element. A simple counter in the class EnhancedChangesList
starts twice from the beginning if the recent changes get included as:

 {{Special:RecentChanges|enhanced=1}}
 {{Special:RecentChanges|enhanced=1}}

Therefore a random value is used as checkbox identifier.

The module 'jquery.makeCollapsible' and its classes `mw-collapsible`,
`mw-collapsed` and `mw-collapsible-toggle-collapsed` are not needed
anymore.

The icons from module 'mediawiki.icon' are directly included because the
module has fixed selectors which do not fit here.

Bug: T172618
Change-Id: Iafd27e5d760b78ae386d833946005f86cee8dd64
2023-07-13 23:12:45 +00:00
Umherirrender
1086958611 Replace array_keys in foreach to use $_ as value instead
When the value of the associated array is not used, there is no need to
use array_keys and create internal a copy of the array, just omit the
value with $_ to tell static analyzer that the var is unused.

Change-Id: I5c6d667e98c0167c0573c683f0d617bc1d4ca619
2023-07-10 02:53:52 +00:00
thiemowmde
990ef704ce Collapse sequences of if into short return if possible
The main goal is to make this code faster and easier to read, and to
avoid duplication.

Change-Id: I925d742d560e9d90e3ecc9ff19fe7e87b60bf9a4
2023-06-15 15:14:40 +02:00