Commit graph

937 commits

Author SHA1 Message Date
jenkins-bot
eebc96e10c Merge "BacklinkCache: cleanup, use fullResultCache with limit" 2024-07-19 10:36:27 +00:00
Umherirrender
4cced1fcff cache: Deprecate UserCache class
The ActorStore could be used to lookup user names.
UserCache is not cross-wiki aware.

Change-Id: Ie5456a09bbf8ab0f236157182309cea8bedd9359
2024-07-15 17:21:31 +00:00
Derick Alangi
8e51012ce7
cache: Deprecate calling UserCache::singleton()
The last callers themselves were already soft deprecated and the
singleton on UserCache itself was almost unused. The last usage has
been replaced and the method now emits deprecation warnings.

Change-Id: Ic9f5e4f427c0402b6c0e7232bcf1d5f9eec6e73e
2024-07-13 22:25:12 +02: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
Tim Starling
d5ac0b40d0 BacklinkCache: cleanup, use fullResultCache with limit
* In queryLinks(), use the full result cache even if a limit is
  specified. Truncate the result in the caller if necessary.
* Remove the confusing boolean parameter from partitionResult(). Make it
  always false and fix up the results afterwards. So the batches are
  always the inclusive start and end IDs, false is never returned.
* Inject a logger instead of using wfDebug()
* Use private not protected. Defaulting to protected was just a coding
  style quirk I had at the time.
* In queryLinks(), use early return.
* In hooks BacklinkCacheGetConditionsHook and BacklinkCacheGetPrefixHook
  adjust the parameter type hint to avoid the need for a Phan override.

Change-Id: Ia53f494633affe48316f0a8b63d03596239ad53c
2024-06-28 15:04:16 +10:00
Tim Starling
0837da9484 Fix use of stale backlink partition cache
If a template is created, and then used on a page, and then the template
is updated, all within an hour, then the page_touched of the page is
never updated and the user will always see the old template contents.
This is because htmlCacheUpdate jobs are fully suppressed for one hour
following template creation, due to the WAN backlink partition cache.

So:

* Revert 4f3efbf406, so that htmlCacheUpdate jobs always do
  something regardless of the state of the partition cache.
* Factor out the job queueing parts of WikiPage::onArticleCreate,
  ::onArticleDelete and ::onArticleEdit. Instead of queueing a job
  unconditionally, check for the existence of backlinks in a post-send
  deferred update. If there are none, don't queue the job.
* It's convenient to use BacklinkCache::hasLinks(), however, it suffered
  from the same stale cache problem as BacklinkCache::partition(). It's
  a short and fast query, and code review shows that none of the callers
  are particularly performance sensitive. So, do not use the WAN cache
  in BacklinkCache::hasLinks().
* Since hasLinks() and getNumLinks() no longer share a significant
  amount of code, separate them. Remove the $max parameter from
  getNumLinks(), which only existed to support hasLinks() and has no
  other usages in codesearch.
* Log a debug message when entering the post-send request stage, so that
  it's easier to confirm that no additional pre-send queries are done.
* Add a regression test, confirmed to previously fail.

Bug: T368006
Change-Id: Id5c7af6d4fcdbeb6724a9036133742c5f76624df
2024-06-28 13:16:26 +10:00
Umherirrender
9879723ef3 Use namespaced classes (1)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
2024-06-16 20:18:23 +02:00
Wandji69
1665ea876f User objectCacheFactory methods not deprecated ObjectCache methods
Bug: T363770
Change-Id: I2335b315bec6a540409492df4891c518640966d5
2024-06-06 09:59:24 +01:00
Umherirrender
57d623f530 Change some type hints from IDatabase to IReadableDatabase
Use narrow interface if no writes are done

Change-Id: I55148c8b6fda8830a29a235c63fc118f636ab3e6
2024-05-24 16:11:12 +00:00
Amir Sarabadani
0269adbe83 Remove last uses of DBAccessObjectUtils::getDBOptions()
With this and soon T360517 be done, we can hard-deprecate this method.

Bug: T354194
Change-Id: Idad6ae65527fdb15ddd46cc41060726e3132620f
2024-04-30 17:44:26 +02:00
Amir Sarabadani
8e183495e1 Stop using LoadBalancer::getConnectionRef() so it can be hard-deprecated
Bug: T326274
Change-Id: I90493d7cd4c21fdc022bcc19765fc04d986a9c8f
2024-04-30 13:31:08 +01:00
Taavi Väänänen
ed7e787f32
Ignore/fix MediaWiki.Commenting.PropertyDocumentation.WrongStyle
Fix the real issues found by this sniff, and convert the remaining
false positive ignores to per-line ignores so that any more real issues
won't be added.

Change-Id: I18e75d59df327e2d93a3a487c115e92b9f268722
2024-04-22 18:26:14 +03:00
James D. Forrester
8e940c4f21 Standardise all our class alias deprecation comments for ease of grepping
Change-Id: I7f85d931d3b79da23e87b4e5692b2e14be8fcaa0
2024-03-19 20:11:29 +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
4bae64d1c7 Namespace includes/context
Bug: T353458
Change-Id: I4dbef138fd0110c14c70214282519189d70c94fb
2024-02-08 11:07:01 -05:00
Tim Starling
9c02258a04 Use thousands separators in selected integer literals
For readability. Allowed since PHP 7.4.

I searched for integer literals of 6 or more digits, and also changed
some nearby smaller numbers for consistency.

Bug: T353205
Change-Id: I8518e04889ba8fd52e0f9476a74f8e3e1454b678
2023-12-12 09:22:45 +11:00
Martin Urbanec
29af4dd074 Move user options related classes into its own namespace
There are a couple of user options related classes already,
and the T321527 work on dynamic defaults is going to add
even more. Let's move them into a separate namespace
to make core a bit more organized.

Old name is kept as an alias for compatibility purposes.

Bug: T321527
Bug: T352284
Change-Id: I9822eb1553870b876d0b8a927e4e86c27d83bd52
2023-11-29 13:27:13 +01:00
James D. Forrester
67217d08df Namespace remaining files under includes/deferred
Bug: T166010
Change-Id: Ibd40734b96fd2900e3ce12239d09becfb4150059
2023-11-22 10:08:53 -05:00
Bartosz Dziewoński
978d739bc6 Replace single-value $db->buildComparison() with $db->expr()
Find:
->buildComparison\( ('..?'), \[(\s*)([^\],]+) => ([^\],]+)(\s*)\] \)

Replace with:
->expr($2$3, $1, $4$5)

Change-Id: I2cfc3070c2a08fc3888ad48a995f7d79198cc336
2023-10-22 01:05:47 +02:00
Derick Alangi
cb22f7b13b
cache: Dependency inject more args into BacklinkCache
Injecting LinksMigration and ServiceOptions into BacklinkCache.

Change-Id: I2068cccc472e00bc025de771760d289aaaec2831
2023-10-02 19:10:11 +01:00
Timo Tijhof
d9f1618e40 GenderCache: Improve docs and fix outdated comments
* Follows-up I00813228e177a7a7, which removed the "valid username" check,
  but getGenderOf() still referred to this check. The fallback in
  getGenderOf seems fine and cleaner to keep but no longer needs to
  mention this outdated implementation detail.

* Simplify newSelectQueryBuilder call by moving the caller() value
  and turn it into a single chain.

* Document why missLimit isn't a constant.

Change-Id: I5791bfdf5b234f266812a478904bf3e7b1dc2313
2023-09-29 19:38:45 +00:00
jenkins-bot
4d1e278105 Merge "Migrate another major batch to SelectQueryBuilder" 2023-09-20 13:39:17 +00:00
Amir Sarabadani
44a6dd21b3 Migrate another major batch to SelectQueryBuilder
I fixed some edge cases in the script that migrates to SQB and it
managed to fix these now.

Bug: T344971
Change-Id: I00cc9a6660d9bd4c64c976121b2121ccd7aae1f0
2023-09-20 13:32:09 +02:00
Amir Sarabadani
ba3b5a98c1 cache: Add support for pagelinks read new in BacklinkCache
That also simplified the code and deduplicated logic a bit.

Bug: T346457
Change-Id: I31cc253469f13c6b1a3ef50be74f1a7e6466db79
2023-09-19 17:30:45 +02: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
James D. Forrester
a8a6cfd966 Namespace NamespaceInfo under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: Ibe103cd362535d3cb94cb8931e95fc74099d1497
2023-09-19 05:17:04 +00:00
James D. Forrester
94ece673b2 Namespace TitleValue under \MediaWiki\Title
One of the big ones, so doing this alone.

Bug: T166010
Change-Id: I4c901d5c32696d8334ec30cede7d9b6f3d8d645e
2023-09-18 18:24:39 +01:00
Amir Sarabadani
8cd2646ba9 Migrate several services to use ICP instead of LB
Bug: T330641
Depends-On: I4b8a8ecd2efd0e872dbf6b24762401f95a7654c7
Change-Id: Ic4359b05f7f4fdc2a25a2f11aae33c63a2836bc9
2023-09-16 10:04:13 +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
Amir Sarabadani
1a66e0095f Migrate several more Database::select calls to SQB
These are not too complicated to require their own query builder or
playing with hooks but too complicated for the automated script to do it
cleanly.

Bug: T311866
Change-Id: Ib3ca9cc2a046b03748db0f2eb8bfbb31de641c07
2023-08-24 14:19:14 +02:00
James D. Forrester
d148989faf LinkCache: Drop addGoodLinkObj(), deprecated in 1.37
Change-Id: I9c426689f0db9658bacc93da1f591e452c51910b
2023-08-23 23:53:51 +00:00
Amir Sarabadani
64a3552a40 ResourceLoader: Completely remove FileCache
When I was testing for caching in RL, I realized file cache is
completely broken and mostly useless, specially for not taking into
account new query parameters and thinking basically all RL modules are
uncachable.

Let's just remove this.

Bug: T330576
Change-Id: I5b17bfc4c5543bd0e96e1099c87341ddf8fd6572
2023-08-11 13:50:41 +02:00
Derick Alangi
693b8c5987
cache: Remove deprecated methods from BacklinkCache
BacklinkCache::get(), ::getLinks(), ::getCascadeProtectedLinks()
have been removed from core. No longer used.

Change-Id: I84d743719e08c755dc98777ecf6d6d1e92eb2d2b
2023-08-10 14:21:23 +01:00
jenkins-bot
3ee2ce6301 Merge "Simplify WHERE conditions with field IS NULL" 2023-07-24 18:34:30 +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
Timo Tijhof
d6adb2a6e1 HTMLFileCache: Remove @throws for unchecked exception
While at it, move the array to a constant.

Bug: T321683
Change-Id: I46db0f4b01711ff7304918708efb7776300bbcc8
2023-07-24 05:08:58 +01:00
jenkins-bot
b36f1ba1b5 Merge "Remove duplicate array_keys() from GenderCache::doLinkBatch" 2023-07-07 21:30:24 +00:00
Amir Sarabadani
3e157496ff Migrate several wfGetDB() to use ICP
And doing proper dependency injection.

Bug: T330641
Change-Id: I4978c158e513f88f5547343c4fbbe4b39078dc09
2023-07-05 11:00:59 +02:00
thiemowmde
e18d363203 Remove duplicate array_keys() from GenderCache::doLinkBatch
What this piece of code does: Collect the page names (without a
namespace) from all namespaces that support a gender discinction.
These are usually the User: and User_talk: namespaces.

In other words: No matter if the input contains "User:Foo" or
"User_talk:Foo" or both, we want the output to contain the user name
"Foo" a single time.

We can just combine the incoming per-namespace arrays with + or
array_merge (doesn't make a difference here, but + is actually a lot
faster).

Change-Id: Ia616d3c3db509c4a02ef6806321ef8ae39ede640
2023-07-03 17:31:51 +00:00
jenkins-bot
158adf4dde Merge "Collapse sequences of if into short return if possible" 2023-06-20 11:48:55 +00:00
jenkins-bot
dbf8f8d12c Merge "Merge sequences of if that end doing the same thing anyway" 2023-06-17 23:34:51 +00:00
thiemowmde
9b03cde58e Merge sequences of if that end doing the same thing anyway
Motivation:
* Avoid code duplication.
* Hopefully make it easier to read.
* Also order stuff from cheap to expensive, if possible.

Change-Id: I575e3f2027ce60a0d0885be5b9bd3e07bc035eee
2023-06-16 16:09:42 +02:00
Timo Tijhof
8207004738 LinkBatch: Re-apply makeWhereFrom2d/constructSet exception
Follows-up Ifdf3ea54 (678326e6fb) and its
partial revert I665c3a6e8 (d48115b2bf).

Bug: T336964
Bug: T336980
Change-Id: Ia5d8f652d6d1522543ebb8338e68f5ccd8742dac
2023-06-15 21:30:07 +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
jenkins-bot
60443f2dd8 Merge "Replace some more usages of deprecated MWException" 2023-06-09 13:19:48 +00:00
Taavi Väänänen
c5063e9c18
Database: support passing an IReadableDatabase to getCacheSetOptions
Change-Id: Ia93e52838c0ca68732969268f36a4ff5f193ff16
2023-06-09 10:46:03 +03:00
Daimona Eaytoy
8adf1bfb93 Replace some more usages of deprecated MWException
Bug: T328220
Change-Id: I3c36835fbd90acc301731e2b33ae4815cd4b0cc5
2023-06-09 02:07:08 +02:00
Umherirrender
d48115b2bf cache: Do not throw on empty set in LinkBatch::constructSet
IDatabase::makeWhereFrom2d no longer returns false (it throws),
so do the check in the calling code and return false

Bug: T336964
Follow-Up: Ifdf3ea54271ea856f2f555a5e087b8f521e348b3
Change-Id: I665c3a6e8d8623ace6a5df4e110527db2f546b30
2023-05-18 21:32:05 +02:00
Umherirrender
e04d3a28f6 Replace internal Hooks::runner
The Hooks class contains deprecated functions and the whole class is
going to get removed, so remove the convenience function and inline the
code.

Bug: T335536
Change-Id: I8ef3468a64a0199996f26ef293543fcacdf2797f
2023-05-11 06:17:38 +00:00
Amir Sarabadani
d44c45c76a watcheditem: Switch out of LB for picking db connection
A bit of a clean up. Switching out of lbFactory to ICP is not possible
at the moment because there is $this->lbFactory->getLocalDomainID()
for cache prefix. Fixable later.

Bug: T330641
Change-Id: I2d4537f75f5877552c6d9fd2b76c5be1959ea400
2023-05-05 15:42:10 +02:00