Commit graph

24 commits

Author SHA1 Message Date
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
Wandji69
c257e2276c Replace db with getDb for Tests
Bug: T316841
Change-Id: I29e535e8ee9b5641a4546d53b98cd5060d39681d
2024-06-23 23:47:56 +01:00
Umherirrender
b4e0d31644 tests: Use namespaced classes (@covers)
Some fixes done via codesniffer fix (Ibd0f48e14e)

Change-Id: I0404ceca7c5abe8d32ef9a8fce404c7b89ffbaae
2024-06-14 00:15:40 +02:00
Umherirrender
a89a00ffb8 tests: Migrate to IDatabase::newInsertQueryBuilder
Changed some inserts to use multi-row insert for small performance
benefit where possible and not already used.
InsertQueryBuilder does not return a value, deprecated since 1.33

Bug: T353219
Change-Id: I2380ebc8ec8db178dd790247aefbdd798b6d62ff
2024-04-14 21:56:07 +02:00
Reedy
85396a9c99 tests: Fix @covers and @coversDefaultClass to have leading \
Change-Id: I5629f91387f2ac453ee4341bfe4bba310bd52f03
2024-02-16 22:43:56 +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
Derick Alangi
03b4f7e1ee
BacklinkCacheTest: Fix test case to avoid slowness
Calling `count()` in a for loop is terrible as the no. of elements in
the array gets recomputed every time. Instead, just call it once and
use the variable to avoid slowness of tests. We shouldn't put more load
on CI to make it slower :D

Change-Id: I9b94bda646e8d922e1f91c9d83d16370caaf8fbd
2023-08-10 14:22:22 +01: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
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
James D. Forrester
ad06527fb4 Reorg: Namespace the Title class
This is moderately messy.

Process was principally:

* xargs rg --files-with-matches '^use Title;' | grep 'php$' | \
  xargs -P 1 -n 1 sed -i -z 's/use Title;/use MediaWiki\\Title\\Title;/1'
* rg --files-without-match 'MediaWiki\\Title\\Title;' . | grep 'php$' | \
  xargs rg --files-with-matches 'Title\b' | \
  xargs -P 1 -n 1 sed -i -z 's/\nuse /\nuse MediaWiki\\Title\\Title;\nuse /1'
* composer fix

Then manual fix-ups for a few files that don't have any use statements.

Bug: T166010
Follows-Up: Ia5d8cb759dc3bc9e9bbe217d0fb109e2f8c4101a
Change-Id: If8fc9d0d95fc1a114021e282a706fc3e7da3524b
2023-03-02 08:46:53 -05:00
Umherirrender
2515199b2f Hard-deprecate BacklinkCache::get/getLinks/getCascadeProtectedLinks
Depends-On: I39a532bcce35191db6abe4fdcdd6f95df74e5e87
Depends-On: I4c8bcec6bb2396b31a7cc73cb7f6f83742dc001a
Change-Id: I09d0aae2400d3b70d8ad59df4e47ee23d3f5072b
2022-12-15 10:51:44 +00:00
Matěj Suchánek
501a16eb18 Hard-deprecate BacklinkCache::get
It has been deprecated since 1.37 and it is unused.

Change-Id: I8b588073f1d22846a8564e340e019de45e7566a3
2022-11-20 20:32:11 +01:00
Umherirrender
89b2d11a0d tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ie240eb42479d19714e64cc4606e26073fadc2e13
2022-09-23 21:53:11 +02:00
jenkins-bot
aafa2e0b04 Merge "tests: Replace deprecated WikiPage::factory" 2022-09-09 16:25:08 +00:00
Amir Sarabadani
6c4194e23e schema: Drop tl_title and tl_namespace fields from templatelinks
The day has gone. Still keeping the code as the schema changes are not
done in production but the data migration has been finished.

Bug: T299417
Change-Id: I906e069a63d1dae14924c72318b22b16244371d6
2022-09-06 19:53:15 +02:00
Umherirrender
6555923b08 tests: Replace deprecated WikiPage::factory
Bug: T297688
Change-Id: Ic84d491c5603f3590e26cb56a305508b2b0ca109
2022-09-02 19:34:02 +00:00
jenkins-bot
3fc9cf4f51 Merge "Add support for write new for templatelinks migration" 2022-07-12 14:17:52 +00:00
Amir Sarabadani
692dde00df Add support for write new for templatelinks migration
- schema change to allow tl_namespace and tl_title being empty
   This is done by removing them from primary key. They don't need to be
   nullable as they have default value.
 - Make sure with WRITE_NEW, updater avoids writing to the old columns

Bug: T306674
Change-Id: I2b8a29043e952060e7a79b6a7a3d647d48cd16fb
2022-07-12 14:46:54 +02:00
Umherirrender
047c184bfe tests: Use Title::makeTitle instead of Title::newFromText
Avoid parsing known titles in tests to improve performance

Change-Id: Ibfccfe696f0b8bfda0b99abae324e60bbecef7d8
2022-07-06 00:44:00 +02:00
Func
7f74a2e50c Clean up tests that misused the parameters of assertSame/Equals
Expected value is the first parameter to assertSame() or assertEquals().
And turn to use assertCount() for some assertions aginst count of array.

Based on code search `assert(?:Same|Equals)\(.+,.+expected` and I look
through files roughly, so some assertions that don't contains 'expected'
are also fixed. In the meantime, some assertions that I am not clear
about are not touched.

Change-Id: I75798b60d29fd19b33f4fdf34ed3c788db420d01
2022-02-08 07:21:10 +00:00
Derick Alangi
db43511e6a Title: Make use of BacklinkCacheFactory service
Change-Id: I48161585de6f329ec4037156234e0b07b3b837e6
2021-09-09 14:04:02 +01:00
Derick Alangi
96bc83e8eb Add BacklinkCacheFactory Service
Bug: T279433
Change-Id: I2943935e2d8148fce4457f76eca0234be72a5a5a
2021-09-09 09:58:52 +01:00
TChin
e1ef35e713 Test new methods in BacklinkCache
Bug: T288614
Change-Id: Ifdced6549b30e27803a37678915f3571332356fd
2021-08-30 15:41:02 +00:00
TChin
de50954fdb Test BacklinkCache
Bug: T288614
Change-Id: I5a45bb0e7b179a1b545ed422fc2b6e7efd664d10
2021-08-19 17:29:05 +00:00