aboutsummaryrefslogtreecommitdiffstats
path: root/includes/watcheditem
Commit message (Collapse)AuthorAgeFilesLines
* Use static closures where safe to useUmherirrender2021-02-112-3/+3
| | | | | | | | | This is micro-optimization of closure code to avoid binding the closure to $this where it is not needed. Created by I25a17fb22b6b669e817317a0f45051ae9c608208 Change-Id: I0ffc6200f6c6693d78a3151cb8cea7dce7c21653
* Make UserIdentity objects aware of which wiki they belong to.Cindy Cicalese2021-02-021-1/+1
| | | | | Bug: T260933 Change-Id: Ic986640cc34e6ec6be239e410a8334f0e299c682
* WatchedItemStore: Use REPLACE when inserting expiries after page moveMusikAnimal2021-01-141-1/+2
| | | | | | | | | | | | | Sometimes when moving pages, a row for the target page may already exist in the watchlist_expiry table. The exact scenario that's causing the prod errors could not be repo'd in tests or locally, but using REPLACE should be a safe solution. Tests updated to actually verify the expiry of the new title, if present, is overriden with the old one following the page move. Bug: T271971 Change-Id: Id4d46fcdea4816e5714d266985ba86fdc6450cfb
* WatchedItemStore: use UserFactoryDannyS7122021-01-101-2/+9
| | | | | | Will allow for converting to true Unit tests Change-Id: I0ef2ada0d5ee9a80a104cb9b07a50e3887d02dd3
* ApiQueryInfo: Return watchlist expiry when applicable for inprop=watchedMusikAnimal2021-01-063-15/+61
| | | | | | | | | The expiry is returned as a separate key, 'watchlistexpiry', to match other APIs, and because some clients might expect 'watched' to be a boolean (or blank string depending on the formatversion). Bug: T268834 Change-Id: I227d6ed42e70ba1ddec0139e8198f536dfba0b46
* WatchedItemQueryService: Add expiry to itemsDannyS7122020-12-011-2/+4
| | | | | | | | So that ApiQueryWatchlist can include it Bug: T263796 Follow-up: 9fefe2eac0419c154e35fa3b5bbc0e8308526798 Change-Id: I18bfc19e992a00549cdcd14db436cd65f8654cb6
* Merge "Use LinkBatchFactory in WatchedItemStore"jenkins-bot2020-11-061-4/+13
|\
| * Use LinkBatchFactory in WatchedItemStoreUmherirrender2020-11-021-4/+13
| | | | | | | | Change-Id: I870b6b9780f0131fb8caa6d48999f3ab8800dd81
* | Inject UserFactory into WatchedItemQueryServiceDannyS7122020-10-121-2/+14
| | | | | | | | | | Bug: T265311 Change-Id: I2bf6782b4f83f7ce0f0809dcb09d83c82fc13b6c
* | Normalize WatchedItem expiry fieldhmonroy2020-10-062-29/+27
| | | | | | | | | | | | | | | | | | | | Normalize watchlist expiry field so that it is set to ConvertibleTimestamp and the expiry value validation is handled by the WatchedItem class. Bug: T260868 Bug: T260009 Change-Id: I3ef31900cfbe7bce23c5ebe1db777a5137ea6167
* | Document hook names in hook interfaces.daniel2020-09-272-0/+6
| | | | | | | | | | Bug: T258665 Change-Id: Ifddbf57f8aa2e3eb0d5845601376cbafa08ed407
* | Correct success messages for action=watchSam Wilson2020-09-031-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix up display of success messages after action=watch is submitted. This adds two new messages for when the remaining watch period is less than a day, and fixes the display of the other six messages. The factors for which message is used are: * watchlist expiry feature flag; * article vs talk page; * temporarily vs permanently watched; and * hours or whole days remainig in watch period. Bug: T259055 Change-Id: Ice3a30028d0bec5c5f4e4b9ce9e95b6553bdabdf
* | Merge "WatchedItemStore: Cache single WatchedItems with preexisting expiry"jenkins-bot2020-08-211-19/+34
|\ \
| * | WatchedItemStore: Cache single WatchedItems with preexisting expiryMusikAnimal2020-08-211-19/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit makes three changes: 1) Re-fetches the expiry before caching WatchedItems in addWatch(). Sometimes (as with action=rollback) addWatch() is called without an expiry, even though one currently exists. So we must query for the preexisting expiry to ensure it persists in the process cache, otherwise the star in Vector will be full when it should be a half-star. 2) Removes caching of WatchedItems within addWatchBatchForUser(). We do not want to fix #1 above within addWatchBatchForUser() as this would mean we'd need to fetch expiries en masse, when seemingly only a single WatchedItem needs the process cache (the page you're viewing). Bulk caching was added in Ie4b69c985815a77b70692db0c4dbf52e1a6a018d solely for the benefit of a single page (T28292), so it seems safe to move the caching to addWatch(). 3) Changes User::addWatch() to use WatchedItemStore::addWatch() instead of addWatchBatchForUser(). This is to ensure the WatchedItem is stored in the process cache for the aforementioned reasons. Accordingly the docblock for addWatchBatchForUser() now encourages use of addWatch() for a single page/talk page. Bug: T259379 Change-Id: I3a071f4fbc28fcc96ca7768e31c6810ff7b8e605
* | | Mark CONSTRUCTOR_OPTIONS as internalAryeh Gregor2020-08-211-1/+1
|/ / | | | | | | | | | | | | | | These were never meant to be part of the public interface and should not ever have been marked with @since. They're only useful for constructing the respective objects, which no outside users should be doing. Change-Id: I86e01272d46fc72af32172d8a12b9180971d4613
* / Update language in watchlist expiryhmonroy2020-08-141-0/+30
|/ | | | | | | | | | | | | | | Update watchlist expiry language indicators (dropdowns, tooltips, watch via star, watch via edit): * Change "Permanently" to "Permanent" * Change "XX days left" and "Expires in X days" to "XX days left in watchlist" * Update the "Click.." sentence by star to "Click to remove it." * Change watch period for a page that is less than "1 day left" to "A few hours left" Bug: T253135 Bug: T255632 Change-Id: I114c6f77e86ad81b1810fedcd49f52c88700ca16
* Merge "Default to using watchlist expiry of old page when moving pages"jenkins-bot2020-08-061-22/+106
|\
| * Default to using watchlist expiry of old page when moving pagesMusikAnimal2020-08-051-22/+106
| | | | | | | | | | | | | | | | | | | | | | | | Expiries are copied post-send so as to not slow anything down. Note the expiry feature has been disabled in some unit tests that mock database queries, simply because these tests are so hard to maintain and are very fragile. The logic introduced with this patch is covered by the integration tests. Bug: T257259 Change-Id: I4223eaa6782a319fb684acf656f54b88a92e5288
* | Add UI support in Special:EditWatchlist for watchlist expiryhmonroy2020-07-302-8/+21
| | | | | | | | | | | | | | | | | | Add text to indicate remaining days for temporarily watched items in the Special:EditWatchlist page. Add ascending sorting by expiration date. Display the items that will expire soonest at the top. Bug: T250214 Change-Id: I9aba8cccc2ef75c59b78008723d0ae76d853c5f2
* | Merge "Watchlist: Return null instead of 0 days remaining"jenkins-bot2020-07-291-4/+4
|\ \ | |/ |/|
| * Watchlist: Return null instead of 0 days remainingDayllan Maza2020-07-271-4/+4
| | | | | | | | | | | | | | If no expiration is present, `null` will be returned as to indicate that there is no expiry on the WatchedItem. Change-Id: If940e6c94ccfa4ab2546ba9ba1a02c164ed0400a
* | Watchlist: Fix action=watch caching the wrong expiryDayllan Maza2020-07-281-8/+8
|/ | | | | | | | | | | | | | | | | | | WatchedItem was being cached with an invalid expiry always resulting in isExpired()* returning true and a query to the replica db being executed also returning the wrong expiry due to replication lag in the same request since the record is being updated a little bit earlier in the call-stack. This was not a problem when `$wgWatchlistExpiry` was disabled because isExpired()* is never true and the cache object was always returned avoiding the query to the replica. * See ::getWatchedItem() which gets called indirectly from SkinTemplate after the update to the db has been made on addWatchBatchForUser Bug: T253937 Change-Id: Ic4d186433c4fc105a3268d6cf98b8ef8ce023cd4
* Watchlist: Return early if expiry is nullDayllan Maza2020-07-251-2/+5
| | | | | | | | * Return early if expiry is null when calculating a watchlist item expiration time in days * Replace "yoda conditional" to conform to our coding conventions Change-Id: Ife8e9d3a2f9b107548414fa0fc25c4adafbcf7d0
* Fix broken PHPDoc comments that don't start with /**Thiemo Kreuz2020-07-231-2/+2
| | | | Change-Id: I8db56ff0f73873864dde260e51adcd729aa74e94
* Replace "@stable for implementation" with "@stable to implement"daniel2020-07-132-2/+2
| | | | | | | | | | | For compliance with the new version of the table interface policy (T255803). This patch was created by an automated search & replace operation on the includes/ directory. Bug: T257789 Change-Id: I17e5e92e24c708ffc846945a136347670a3a20c7
* Merge "Filter out expired watched items when sending email notifications"jenkins-bot2020-06-291-8/+21
|\
| * Filter out expired watched items when sending email notificationsMusikAnimal2020-06-241-8/+21
| | | | | | | | | | Bug: T253035 Change-Id: I9ebfee4042b6ac40726162fa8c887f757d7528b8
* | Add clock icon to expiring items in Special:WatchlistSam Wilson2020-06-191-0/+15
|/ | | | | | | | | If a changeslist item has an expiry date, add a grey clock icon after the page title, with a tooltip indicating when the item expires. Bug: T250212 Change-Id: I38f8c85321cf257eeea8de5a3bd73bbc0b5ea393
* Add getExpiryInDays function in WatchedItemsuecarmol2020-06-161-0/+29
| | | | | | | | | | Add a function that calculated the number of days remaining before a watched item expires. This function will be used in several places, like the watchstar tooltip and the clock icon that will appear on Special:Watchlist on pages that are being temporarily watched. Bug: T253936 Change-Id: I5b50a6707fb6a8e5ad868b5c30917027266ab82a
* Pass function name to database functionsUmherirrender2020-06-071-4/+6
| | | | | | Useful for logging Change-Id: Ia2160fb6be5fc93f28ab51f7ae23d7f078247481
* Hooks::run() call site migrationTim Starling2020-05-302-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Migrate all callers of Hooks::run() to use the new HookContainer/HookRunner system. General principles: * Use DI if it is already used. We're not changing the way state is managed in this patch. * HookContainer is always injected, not HookRunner. HookContainer is a service, it's a more generic interface, it is the only thing that provides isRegistered() which is needed in some cases, and a HookRunner can be efficiently constructed from it (confirmed by benchmark). Because HookContainer is needed for object construction, it is also needed by all factories. * "Ask your friendly local base class". Big hierarchies like SpecialPage and ApiBase have getHookContainer() and getHookRunner() methods in the base class, and classes that extend that base class are not expected to know or care where the base class gets its HookContainer from. * ProtectedHookAccessorTrait provides protected getHookContainer() and getHookRunner() methods, getting them from the global service container. The point of this is to ease migration to DI by ensuring that call sites ask their local friendly base class rather than getting a HookRunner from the service container directly. * Private $this->hookRunner. In some smaller classes where accessor methods did not seem warranted, there is a private HookRunner property which is accessed directly. Very rarely (two cases), there is a protected property, for consistency with code that conventionally assumes protected=private, but in cases where the class might actually be overridden, a protected accessor is preferred over a protected property. * The last resort: Hooks::runner(). Mostly for static, file-scope and global code. In a few cases it was used for objects with broken construction schemes, out of horror or laziness. Constructors with new required arguments: * AuthManager * BadFileLookup * BlockManager * ClassicInterwikiLookup * ContentHandlerFactory * ContentSecurityPolicy * DefaultOptionsManager * DerivedPageDataUpdater * FullSearchResultWidget * HtmlCacheUpdater * LanguageFactory * LanguageNameUtils * LinkRenderer * LinkRendererFactory * LocalisationCache * MagicWordFactory * MessageCache * NamespaceInfo * PageEditStash * PageHandlerFactory * PageUpdater * ParserFactory * PermissionManager * RevisionStore * RevisionStoreFactory * SearchEngineConfig * SearchEngineFactory * SearchFormWidget * SearchNearMatcher * SessionBackend * SpecialPageFactory * UserNameUtils * UserOptionsManager * WatchedItemQueryService * WatchedItemStore Constructors with new optional arguments: * DefaultPreferencesFactory * Language * LinkHolderArray * MovePage * Parser * ParserCache * PasswordReset * Router setHookContainer() now required after construction: * AuthenticationProvider * ResourceLoaderModule * SearchEngine Change-Id: Id442b0dbe43aba84bd5cf801d86dedc768b082c7
* Merge "WatchedItemStore: Enforce a maximum watchlist expiry duration"jenkins-bot2020-05-271-8/+28
|\
| * WatchedItemStore: Enforce a maximum watchlist expiry durationMusikAnimal2020-05-221-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduces $wgWatchlistExpiryMaxDuration which is used instead of given expiry if the given exceeds it. This is done in the storage layer. The reasoning is to control the size of the watchlist_expiry table. Hence, the max duration does not apply to indefinite expiries (since that would mean now row in watchlist_expiry). The frontend is responsible for disallowing expiries greater than the max, if it choses to do so. APIs should now pass in $wgWatchlistExpiryMaxDuration as the PARAM_MAX setting for the 'expiry' type. They should also set PARAM_USE_MAX so that the maximum value is used if it is exceeded. Other APIs that watch pages will be updated in separate patches (see T248512 and T248514). Bug: T249672 Change-Id: I811c444c36c1da1470f2d6e185404b6121a263eb
* | Filter out expired items from watcher countshmonroy2020-05-191-21/+68
|/ | | | | | | | | | | | Filter out the expired items from: * Watcher counts in an article info page (Number of page watchers, Number of page watchers who visited recent edits). * Mediawiki API when getting the properties `watchers` and `visitingwatchers` for an article. Bug: T251327 Change-Id: I48489b685f8aec2c265b316c68e626ad5126b123
* Fix more PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-152-3/+3
| | | | Change-Id: I0ccda3d1de29b1044f74ef0972949eb8fbcb707d
* Add methods to check if a page is temporarily watchedMusikAnimal2020-05-133-0/+29
| | | | | | | Add 'mw-watchlink-temp' class to watch link when temporarily watched. Bug: T248495 Change-Id: I61b24fddf6aaf5233f426602bfa1cc4fafce942b
* Filter out expired items from Special:Watchlist pagehmonroy2020-04-271-5/+15
| | | | | | | | Add functionality to exclude all expired items from the watchlist results in the Special:Watchlist page. Bug: T245080 Change-Id: I49840a2527e553d99b8a42db34af207870d1e0fb
* docs: Hook interface doc comment reviewapaskulin2020-04-212-9/+14
| | | | | | | | Edited doc comments for hook interfaces to improve consistency and add type hints. Bug: T246855 Change-Id: I38fa802463cd6f39bf5946dbbeb1b3ebaea604b2
* Automatically generated hook interfacesTim Starling2020-04-202-0/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add hook interfaces which were generated by a script which parses hooks.txt and identifies caller namespaces and directories. Hook interfaces are mostly placed in a Hook/ subdirectory relative to the caller location. When there are callers in multiple directories, a "primary" caller was manually selected. The exceptions to this are: * The source root, maintenance and tests, which use includes/Hook. Test hooks need to be autoloadable in a non-test request so that implementing test interfaces in a generic handler will not fail. * resources uses includes/resourceloader/Hook * The following third-level subdirectories had their hooks placed in the parent ../Hook: * includes/filerepo/file * includes/search/searchwidgets * includes/specials/forms * includes/specials/helpers * includes/specials/pagers Parameters marked as legacy references in hooks.txt are passed by value in the interfaces. Bug: T240307 Change-Id: I6efe2e7dd1f0c6a3d0f4d100a4c34e41f8428720
* Merge "Add expiry type to ParamValidator"jenkins-bot2020-04-092-27/+2
|\
| * Add expiry type to ParamValidatorMusikAnimal2020-04-082-27/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit also changes ApiWatch to make use of the new parameter type. Other APIs will be updated to use it in a separate patch (T248196). In doing this, we are for the first using logic within a TypeDef outside the API. This seems acceptable given TypeDefs chiefly appear to serve as a validation method, with otherwise no particular logic tied to the concept of APIs. wfIsInfinity() now uses ExpiryDef::INFINITY_VALS Bug: T248508 Change-Id: If8f0df059eafb73ec9f39cc076b3a9ce2412d60a
* | Remove expired items in WatchedItemStore::clearUserWatchedItemshmonroy2020-04-081-5/+31
|/ | | | | | | | Add functionality to ClearUserWatchedItems function in WatchedItemStore to delete watchlist expired items from watchlist_expiry table. Bug: T249283 Change-Id: Ifb475c7b8e824419f45dea489940a15d9edb28c5
* Add check to api that filters out expired watchlist itemshmonroy2020-04-031-1/+19
| | | | | | | | Add logic to API module that outputs the watchlist (api.php?action=query&list=watchlist) to filter out expired watched items when $wgWatchlistExpiry feature flag is turned on. Bug: T247029 Change-Id: I49e7959b5166e74c95106a20d965dec6a0590a87
* Merge "Purge expired watchlist items"jenkins-bot2020-03-263-0/+121
|\
| * Purge expired watchlist itemsSam Wilson2020-03-263-0/+121
| | | | | | | | | | | | | | | | | | Add two methods to remove expired watchlist items: 1. A job that's triggered on about 10% of page edits; and 2. A new maintenance script. Bug: T244804 Change-Id: Ica8ab92837c38fa4d484726c94d5181c08387e28
* | ApiWatch: Add support for expiriesMusikAnimal2020-03-242-12/+30
|/ | | | | | | | | With this commit, the action=watch API accepts an 'expiry' parameter, analagous to the expiry accepted by action=userrights, action=block, etc. Bug: T245078 Change-Id: If37a772253082529cb290027da87098c1e6bf98c
* Add support for watchlist expiries to ↵Sam Wilson2020-03-131-3/+22
| | | | | | | | | WatchedItemQueryService::getWatchedItemsForUser() This method is only used by ApiQueryWatchlistRaw. Bug: T247026 Change-Id: I7852bea84c3310e01a9fa2b6fda658e89346980c
* Fixes for batch watchlist deletion and relative expiriesMusikAnimal2020-03-051-2/+2
| | | | | | Change-Id: I3902011b7c56cb0804754cc398a2b93778e73960 Follows-Up: Ifff5e56e0222bb325cf796e0aa3d88825820d1fd Bug: T245213
* Introduce an expiry to WatchedItemMusikAnimal2020-03-044-56/+291
| | | | | | | | | | | Includes the new $wgWatchlistExpiry feature flag. Consumers of WatchedItem and WatchedItemStore have not been changed to make use of expiries, this along with associated UI changes will be done in a separate patch. Bug: T245213 Change-Id: Ifff5e56e0222bb325cf796e0aa3d88825820d1fd
* When clearing don't load the watchlist if we must clear through a jobaddshore2020-01-293-1/+20
| | | | | | | | | | | | | | | It looks like this bug has existed in the special page since before the time of the refactoring into WatchedItemStore although apparently it has only just surfaced now! This adds a new method into WatchedItemStore that decides if the watchlist can be cleared interactively or must use the job queue. This can then be used in the special page instead of the old logic which would load the watchlist and then count the loaded items (inefficient if you know your clearing the list anyway) Bug: T243449 Change-Id: I810d89e3e1142a223430f7fc5f8598a493637a72