Commit graph

49 commits

Author SHA1 Message Date
Tim Starling
820f46964f A service for read-only mode
Introduce a service to represent wfReadOnly() and friends.

It's necessary to have two service instances, one for wfReadOnly() and
one for wfConfiguredReadOnlyReason(), to avoid a circular dependency,
since LoadBalancer needs the configured reason during construction, but
wfReadOnly() needs to query the currently active load balancer.

Not having a cache of the configuration makes it possible to dynamically
change the configuration. Ideally things would not change the
configuration, and I removed such instances in core, but to support
extensions, I added a test ensuring that the configuration can be changed.

Change-Id: I9bbee946c10742526d3423208efd68cb3cc5a7ee
2017-04-19 12:27:06 -07:00
Aaron Schulz
dd359741cc Move DB errors to Rdbms namespace
Change-Id: I463bd86123501abc68fdb78b4cda6110f7af2549
2017-04-15 10:47:41 -07:00
Aaron Schulz
488a647831 Move IDatabase/IMaintainableDatabase to Rdbms namespace
Change-Id: If7e8a8ff574661fd827de8bcec11d2c39a687300
2017-03-28 15:32:38 -07:00
aude
8443339411 Add missing @group Database tags in tests
Change-Id: Id92aab0b1f8cde6657d6558d0d82605109daa588
2017-03-18 19:13:18 -04:00
Aaron Schulz
64df456b39 Move remaining LoadBalancer classes to Rdbms
The old names are left as aliases.

Change-Id: I52a327f2463a2ba7437324047b5b00d28cd1d758
2017-02-23 20:38:31 -08:00
WMDE-Fisch
ae3419f532 Replace some of the deprecated wfGetLBFactory() calls
Change-Id: I87aa0ebe273706438f1634167de8c60f51432878
2017-02-07 14:41:09 +01:00
Brad Jorsch
05ca28bba0 WatchedItemStore::setNotificationTimestampsForUser(): Allow clearing timestamp
ApiSetNotificationTimestamp expects to be able to clear the timestamp by
passing null. Allow that to work as expected.

Bug: T153482
Change-Id: Ibf4ba56f0abd3b72283f7a33e4665d5999a70b82
2016-12-16 14:31:24 -05:00
Timo Tijhof
5783751e71 WatchedItemStore: Update process cache when adding items
This way, when submitting POST to action=watch, the response will
not show "Unwatched" in the navigation 'content action' tabs.

This was previously the case on any wiki installation that has
more than 1 database as the skin would call User::isWatched(),
which would query stale data from a slave.

This doesn't yet account for the reverse use case (removing from
watchlist). That's to be addressed in a later commit.

Bug: T28292
Change-Id: Ie4b69c985815a77b70692db0c4dbf52e1a6a018d
2016-11-02 00:13:35 +00:00
addshore
82b29abd71 use Wikimedia\ScopedCallback in WatchedItemStore
Change-Id: I4292c6098cc54536e3dbb2bcf19fca1288042535
2016-10-06 03:02:11 +00:00
addshore
1629eace1f Use getConnectionRef in WatchedItemStore
Change-Id: Ica6fce8aeec08ace34cd23d3bb0390a859175e71
2016-09-28 03:11:47 +00:00
Aaron Schulz
5bbac35ed1 Replace DatabaseBase:: with Database:: and update type hints
Change-Id: I3919b04eb2de4fa0bf8a02239fb5bbf17d347511
2016-09-27 04:20:03 +00:00
Aaron Schulz
57e19b610d Renamed some variables from "slave" to "replica"
Change-Id: I455278294cd7ea344d14a76ac5957ece2e07fbf3
2016-09-05 23:03:01 -07:00
Aaron Schulz
950cf6016c Rename DB_SLAVE constant to DB_REPLICA
This is more consistent with LoadBalancer, modern, and inclusive
of master/master mysql, NDB cluster, and MariaDB galera cluster.

The old constant is an alias now.

Change-Id: I0b37299ecb439cc446ffbe8c341365d1eef45849
2016-09-05 22:55:53 -07:00
Aaron Schulz
21ddcf1592 Add convenience commitAndWaitForReplication() method
This also does sanity checks to avoid breaking transactions

Change-Id: I7453c245eee25a26243e606970ef5f79b21a8141
2016-08-16 22:09:17 +00:00
jenkins-bot
2686727565 Merge "Database transaction flushing cleanups" 2016-08-16 22:03:43 +00:00
Aaron Schulz
4bcfe7d0ad Database transaction flushing cleanups
* Do not commit() inside masterPosWait(). This could happen
  inside JobRunner::commitMasterChanges, resulting in
  one DB committing while the others may or may not later commit.
* Migrate some commit() callers to commitMasterChanges().
* Removed unsafe upload class commit() which could break
  outer transactions.
* Also cleaned up the "flush" flag to make it harder to misuse.

Change-Id: I75193baaed979100c5338abe0c0899abba3444cb
2016-08-16 20:34:54 +00:00
Aaron Schulz
32a8eb1822 Make various MWCallableUpdate usages rollback-safe
Support for this added to MWCallableUpdate and its helper method
in DeferredUpdates.

Bug: T141988
Change-Id: Ief150ea655036e2708557dd8ae847379edf21933
2016-08-15 00:47:42 -07:00
Aaron Schulz
140da10741 Move updateNotificationTimestamp callback to DeferredUpdates
* This puts the complex logic here after the commit step for
  all DBs, making the main multi-DB transaction more likely
  to be atomic.
* Also fixed the reuseConnection() call by getting a new
  handle in the callback.

Change-Id: I449a521423ff13bfbf49bdaa6e7e6df2145c8751
2016-07-19 15:27:29 -07:00
Kunal Mehta
ce251d15b7 WatchedItemStore: Use callable type hint instead of Assert library
And remove an unused use statement.

Change-Id: Idb74a564088744d73f71f5ef17e8f84f6e484c69
2016-05-27 19:30:14 -07:00
umherirrender
14b888c515 Batch updateNotificationTimestamp() UPDATE queries (without wl_id)
The new primary key is not usable in production (T130067), so batch the
query using the old where condition.

Some code ideas from I3dbe1de4cf39499728a2077a71157d4bcc203e44

Bug: T134613
Change-Id: Ic12926a5166f7578a1136c7944d883c2fe1f3b3a
2016-05-23 21:16:38 +02:00
addshore
eacec0a223 add setNotificationTimestampsForUser to WatchedItemStore
Bug: T134387
Change-Id: Ia6abe7687b51aabe67e8461375075692db28c9a2
2016-05-18 08:50:46 +00:00
addshore
818984e5cb Remove WatchedItemStore::getDefaultInstance
Change-Id: I0c7d706fabee8d1f6fcfbc4c568f375953de8058
2016-05-06 08:47:37 +00:00
addshore
8a71ee8ec3 Make WatchedItemStore use MediaWikiServices
(This is a re-submi8t of I5c8c1a65 after it got reverted by Iae7f7b7)

Change-Id: I193de7ef1566336040463b71735b09db941d8ce1
2016-05-06 08:47:29 +00:00
jenkins-bot
f5fc9f21ea Merge "Remove un-needed cast for array key in WatchedItemStore" 2016-04-26 18:36:47 +00:00
Kunal Mehta
c9d885f3b4 Namespace LinkTarget under MediaWiki\Linker
And add a GPL file header while we're at it.

Change-Id: I15a6f240124c879b21fb655ade1baaebf4f34ffd
2016-04-21 17:19:10 -07:00
Kunal Mehta
aa21cf32fa Specially handle Title objects in Title::newFromLinkTarget()
Every single caller of Title::newFromLinkTarget() already special cases
when the LinkTarget object is already a Title, so move that logic into
one function.

Change-Id: Iba5432ae01c87850e5b34893092427c5b1629188
2016-04-19 22:21:09 -07:00
Catrope
deb22bced7 Revert "Make WatchedItemStore use MediaWikiServices"
In order to cleanly revert "Allow reset of global services"
which breaks login.

This reverts commit 99e8d45b50.

Change-Id: Iae7f7b7b7083345dd50c313ee68e2e814f130f1a
2016-04-11 20:25:47 +00:00
addshore
99e8d45b50 Make WatchedItemStore use MediaWikiServices
Change-Id: I5c8c1a652a35e055d8d65753a60c0d1684e1c37d
2016-04-11 15:50:15 +01:00
addshore
d047a9c604 Introduce StatsdAwareInterface
Change-Id: Iac343e4b448d9af852b4c479c35a9ff60359b6d5
2016-04-02 13:29:51 +00:00
addshore
6ae77e6984 Introduce NullStatsdDataFactory
I have left the phpdocs in NullStatsdDataFactory
to clearly show the return types of the interface
implemented.

Change-Id: I96cb64b4af16fc087028269a53d539f8c132f81c
2016-04-02 13:02:37 +00:00
addshore
9d18093909 Track the use of the WatchedItemStore Cache
Change-Id: Idc33dd6a52471e895b312fa2c6562a90bf3d7861
2016-04-01 15:06:09 +03:00
addshore
12e2e9edbc Switch Signature of WatchedItemStore::addWatchBatch
Adding batches of watched items per users
makes much more sense.
Only the deprecated static WatchedItem method
needed the old silly way of passing in objects.

Change-Id: I90f9583b66bd3b5afcf07faefedb38a8a0149f6e
2016-03-24 18:28:08 +00:00
addshore
4e42311f92 Use WIS::getWatchedItemsForUser in SpecialEditWatchlist
This also adds a order option to:
WacthedItemStore::getWatchedItemsForUser

Tests are also updated

Change-Id: Ia683b92846ad79bde3f37068a8e168c5a8bdc201
2016-03-24 12:33:38 +00:00
addshore
231c684d36 Remove un-needed cast for array key in WatchedItemStore
'1' for example will always result in a php array
key of int 1.
Same for all strings that look like / can correctly
be cast to ints

Change-Id: Id52e4273c6b2f342a148181ce63300aac37582d9
2016-03-24 10:38:41 +00:00
jenkins-bot
98c62a6542 Merge "Add WatchedItemStore::getWatchedItemsForUser" 2016-03-23 15:45:45 +00:00
addshore
659fd5ec9c Add WatchedItemStore::getWatchedItemsForUser
This method is also no used in SpecialEditWatchlist

Unit and Integration tests have also been added.

Bug: T129481
Change-Id: Ica136b6fee63be8de4c2fe502288dd2318d99114
2016-03-23 14:01:31 +00:00
Leszek Manicki
b92ae1501e Use WatchedItemStore in ApiQueryInfo::getWatchedInfo
Adds a method for getting watchlist's notification timestamps
for a batch of LinkTargets.

Bug: T129482
Change-Id: I1f84212e7879a84b34bb3b53859069fcea282bba
2016-03-21 10:25:54 +01:00
Leszek Manicki
7d4e225cb9 Add WatchedItemStore::countVisitingWatchersMultiple
This is for batch counting of visiting watchers, following the change
made in I2868c31fc09121de381d822e8f49194e3022bb42.
Query/logic has been extracted from ApiQueryInfo.

Bug: T129482
Change-Id: Ia9a534f5edb7af3cb7bf86be358dddb5d8c259cf
2016-03-17 16:17:38 +00:00
addshore
bfa8662b73 Add WatchedItemStore::countWatchedItems
This method counts the number of individual items
that a user is watching.
A subject and corresponding talk page would mean a
count of 2

Unit and integration tests are also added here

Bug: T129481
Change-Id: I4b55318dc1d1c5abab1c5da16cebf1a43ddf9248
2016-03-15 15:58:51 +00:00
addshore
eb9d245a11 WatchedItemStore add db connection helper methods
As suggested in:
https://gerrit.wikimedia.org/r/#/c/277276/2/includes/WatchedItemStore.php

Change-Id: Id82d987eee025e21efc381bd441cd07fbc50aea0
2016-03-15 15:57:09 +00:00
addshore
3ab9a9656c Reset WatchedItemStore default instance after tests
Prior to this change in tests the overridden store
would remain in the instance static and thus could
be used in other places.

This patch introduces the used of ScopedCallbacks
in the override methods in WatchedItemStore.
This means that any instance of WatchedItemStore
should return to a regular state after each test.

This is better than requiring the tests to reset
the value back to the origional as this would likely
be forgotten and result in long hunts for failing
tests.

This was found while writing more tests...

Change-Id: I9aa71425642174ae9ea2c6d4f85dcd07d724af11
2016-03-15 15:36:38 +00:00
addshore
846d373c28 Add countUnreadNotifications to WatchedItemStore
This query / logic has been extracted from
ApiQueryUserInfo.

Unit & Integration tests have also been added.

Relating to the task linked this is the last change
needed in this ApiQueryUserInfo!

Bug: T129482
Change-Id: I91aa109416c16cd1f257c9de46669e35d6fd34d7
2016-03-14 16:00:47 +00:00
addshore
0b852c5717 Move countVisitingWatchers to WatchedItemStore
Also adds tests

Bug: T129479
Change-Id: I2868c31fc09121de381d822e8f49194e3022bb42
2016-03-14 15:56:43 +00:00
addshore
6e2d6a0b44 Move counting of watchers to WatchedItemStore
Also adds tests

Bug: T129479
Bug: T129482
Change-Id: I5a465773599cce9f8c9e94847cede6d12282c827
2016-03-14 15:56:16 +00:00
addshore
59e7587ed2 Improve cache assertions in WatchedItemStoreUnitTest
Change-Id: If4b2086cc29fcfc73dee2e9f96591a9e4aa50da9
2016-03-14 15:55:55 +00:00
addshore
8d984cebb2 Uncache things in WatchedItemStore::updateNotificationTimestamp
When the notification timestamp for a LinkTarget is
updated all items relating to that LinkTarget should
be uncached!..

This also switches this class from a BagOStuff to
a HashBagOStuff as this cache index is only maintained
per process..

Change-Id: I5dc58e018a6a4a15903abc1e0b326b4220abc75e
2016-03-14 15:13:19 +00:00
addshore
a683b11b23 Move EmailNotification::updateWatchlistTimestamp to WatchedItemStore
Flow is the only thing remaining that uses this deprecated method.

Change-Id: Iaa4e1e34cb3f2a91c163565fb0107c500e3852d7
2016-03-08 18:44:05 +00:00
addshore
fee0afdc8a Move WatchedItem logic to WatchedItemStore
This also removes assumptions that when a page
in one Namespace should be watched / removed
that the page in the talk / subject ns for the
page should have the same action applied

This should maintain all backward compatability
for the WatchedItem class

This also includes tests written by:
 - WMDE-leszek
 - Addshore

Bug: T127956
Change-Id: Iad9abafe4417bb479151a3bfbee6e1c78a3afe3c
2016-03-08 15:41:22 +00:00
addshore
54d4315be6 Move WatchedItem::duplicateEntries to WatchedItemStore
This removes static logic from WatchedItem into a
class that we can slowly fill with watchlist database
and storage things.

This also removes the dual namespace handling in
the new implementation.

Change-Id: Ia67ab1d200ac393c65013b2091e61acefcb3defb
2016-02-17 15:22:32 +00:00