aboutsummaryrefslogtreecommitdiffstats
path: root/includes/api/ApiStashEdit.php
Commit message (Collapse)AuthorAgeFilesLines
* Inject services into ApiStashEditDannyS7122020-10-271-21/+52
| | | | | Bug: T259960 Change-Id: I8fede2c0df26a101f880b4038fe90557fd1818f3
* API: Handle ContentHandler exception for content model mismatchAmmar Abdulhamid2020-09-041-3/+18
| | | | | | | | | | | | | | Ensure the content we are trying to save and the base content have identical content models before proceeding to save so as to forestall Exception that may be thrown by ContentHandler if it founds they're not. There are two cases where the models are allowed to differ: Edit that undoes content model change or edit that's meant to explicitly change the model. The logic for these is handled separately and may succeed or fail, but exception will not be thrown. Bug: T255700 Change-Id: I8782732bb0fc3059693cd7035b7ebb43fd71d333
* Fix even more PSR12.Properties.ConstantVisibility.NotFoundReedy2020-05-161-7/+0
| | | | Change-Id: I5e04824d6fa6a4c36ce489850bb0ed7b4ac588f9
* Remove use of deprecated Revision from ApiStashEditPetr Pchelko2020-03-131-4/+7
| | | | | Bug: T246284 Change-Id: I734e6572c913f4f32295a14705f0fc19b8000b03
* stashedit: Ensure that $summary is a stringDaimona Eaytoy2020-02-221-1/+2
| | | | | | | It's only documented as string. Bug: T245928 Change-Id: I8fa287f335e90a59ac18365e7401a5cf703130a3
* Introduce ContentHandlerFactoryArtBaltai2020-02-071-5/+12
| | | | | | | | | | | | | | | | | Added: - ContentHandlerFactory Tests: - PHPUnit Changed - Calls of changed and deprecated - DI for some service/api Deprecated: - ContentHandler::* then similar to ContentHandlerFactory - ContentHandler::getForTitle - ContentHandler::$handlers Bug: T235165 Change-Id: I59246938c7ad7b3e70e46c9e698708ef9bc672c6
* Remove redundant ignore_user_abort() call in ApiStashEditAaron Schulz2019-08-291-3/+0
| | | | | | | | This API module has mustBePosted() return true and such POST request are already covered by both WebStart.php and ApiBase::useTransactionalTimeLimit(). Change-Id: Ie6f6af1459dde82572be8784049a307a3a769a1c
* Keep ERROR_* constants in ApiStashEdit for backwards compatibilityAaron Schulz2019-04-231-0/+7
| | | | | | | Follow-up to 285930668495b Bug: T221689 Change-Id: Ibe275c69d5b47fd36efac4a91b2334970dd02fe8
* Refactor edit stashing into a PageEditStash serviceAaron Schulz2019-04-171-336/+8
| | | | | | | | | | | | Additional code cleanup: * Call setCacheTime() in parseAndStash instead of relying on the one in DerivedPageDataUpdater. * Improve the SPI logging by adding more extra fields. * Treat requests in CLI/job mode (aside from tests) like those from bots with regard to checking the stash. This should avoid stats/logging pollution. Change-Id: I8c6be919e399378e401a60502add0ecec7764d2d
* Make ApiStashEdit::pruneExcessStashedEntries use user nameAaron Schulz2019-03-271-1/+1
| | | | | | Follow up to c334883309778 Change-Id: I35213d83a00b50bb469aab5bf8fbeb52239cff5e
* Prune old edit stash entries from users as they create moreAaron Schulz2019-03-261-0/+25
| | | | | | | | | | This should reduce pressure on certain medium-large sized memcached slabs. Pre-1.5 memcached versions have a harder time pruning expired entries in time to avoid evictions, so it will be most useful that scenario. Bug: T203786 Change-Id: Ic357dbfcd9abd525b02e8d631d1344db3745d24c
* Make ApiStashEdit use a separate key for the parser output due to sizeAaron Schulz2019-03-061-34/+69
| | | | | Bug: T204742 Change-Id: Ibab189c8e0dee5e840770bdb0336516fdfc75e4b
* Fix caller name in ApiStashEdit::parseAndStashUmherirrender2018-09-301-3/+4
| | | | | | Seeing {closure} in the logs as caller is not helpful Change-Id: Id77253bdd4b65b0673214e7bf6ca3cc26bd155fa
* Improve test coverage for ApiStashEditAryeh Gregor2018-08-211-0/+4
| | | | Change-Id: I1b7d95e074a7f101d13398a32898b74145ab4056
* Fix incorrect method nameAryeh Gregor2018-08-071-1/+1
| | | | | | | | | getTimestamp() returns the timestamp of the revision, and as far as I can tell that's null here, presumably because we haven't saved the content and thus there is no revision. getCacheTime() returns the time when the page was parsed, which is probably what we want. Change-Id: I7dc446800656236f6ecc872a65e620881e434c54
* Do not return invalid hash from ApiStashEditAryeh Gregor2018-08-061-8/+7
| | | | | | | | If we were rate-limited, we don't store a new hash, so we shouldn't return a new one. If we received a hash from the client, however, that should still be valid, so we can return it. Change-Id: Ifc37ae044172b8838fee15d539b076a0d0f02f22
* Clean up param handling in ApiStashEditAryeh Gregor2018-08-061-10/+5
| | | | | | | | | | It doesn't make sense to submit both stashedtexthash and text, so requireOnlyOneParameter() is correct. This simplifies the code and gives a more helpful error message. (Previously if both parameters were passed, we would ignore text unless stashedtexthash was empty, in which case we would ignore it.) Change-Id: I306b15eefb6fd4379a3eed88d84113c2e43c4a95
* Add `actor` table and code to start using itBrad Jorsch2018-02-231-4/+8
| | | | | | | | | | | | | Storing the user name or IP in every row in large tables like revision and logging takes up space and makes operations on these tables slower. This patch begins the process of moving those into one "actor" table which other tables can reference with a single integer field. A subsequent patch will remove the old columns. Bug: T167246 Depends-On: I9293fd6e0f958d87e52965de925046f1bb8f8a50 Change-Id: I8d825eb02c69cc66d90bd41325133fd3f99f0226
* Avoid blocking locks during API edit stash generationAaron Schulz2017-11-211-2/+7
| | | | | Bug: T180793 Change-Id: Ibc29a20329113c3ee54fd48cfe86ca8251e8098d
* Fix up logging grouping in ApiStashEditChad Horohoe2017-11-091-4/+9
| | | | Change-Id: Ie3d7b465faa26966c5745ca1bb09843a26193b9e
* Sanity check "stashedtexthash" param before checking memcachedAaron Schulz2017-08-311-0/+3
| | | | | | | The makeKey() method should do escaping and shortening, but it is safest and clearer to not rely on that. Change-Id: Ia4a95e0bb12074d141ddcca2089b920403cab100
* Avoid high edit stash TTLs when a user signature was usedAaron Schulz2017-07-061-0/+7
| | | | | | | This adds a new ParserOuput user-signature tracking flag. Bug: T84843 Change-Id: I77de05849c15e17ee2b9b31b34172f4b6a49a38e
* Remove "@author Aaron Schulz" annotationsAaron Schulz2017-06-271-1/+0
| | | | | Bug: T139301 Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
* Cleanup some incorrect return annotationsErik Bernhardson2016-12-121-1/+1
| | | | | | | | | | | | | | Most of these are simply changing annotations to reflect reality. If a function can return false to indicate failure the @return should indicate it. Some are fixing preg_match calls, preg match returns 1, 0 or false, but the functions all claim to return booleans. This is far from all the incorrect return types in mediawiki, there are around 250 detected by phan, but have to start somewhere. Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
* API: i18n for warnings and errorsBrad Jorsch2016-12-061-9/+17
| | | | | | | | | | | | | | | | | | | | | | | | | API warnings and error messages are currently hard-coded English strings. This patch changes that. With a few exceptions, this patch should be compatible with non-updated extensions: * The change to ApiBase::$messageMap will blow up anything trying to mess with it. * The changes to the 'ApiCheckCanExecute' hook will cause a wrong (probably unparsed) error message to be emitted for extensions not already using an ApiMessage. Unless they're currently broken like Wikibase. Bug: T37074 Bug: T47843 Depends-On: Ia2b66b57cd4eaddc30b3ffdd7b97d6ca3e02d898 Depends-On: I2e1bb975bb0045476c03ebe6cdec00259bae22ec Depends-On: I53987bf87c48f6c00deec17a8e957d24fcc3eaa6 Depends-On: Ibf93a459eb62d30f7c70d20e91ec9faeb80d10ed Depends-On: I3cf889811f44a15935e454dd42f081164d4a098c Depends-On: Ieae527de86735ddcba34724730e8730fb277b99b Depends-On: I535344c29d51521147c2a26c341dae38cec3e931 Change-Id: Iae0e2ce3bd42dd4776a9779664086119ac188412
* Use namespaced ScopedCallbackKunal Mehta2016-10-171-0/+1
| | | | | | The un-namespaced \ScopedCallback is deprecated. Change-Id: Ie014d5a775ead66335a24acac9d339915884d1a4
* Fix ApiStashEdit IDEA warningsAaron Schulz2016-09-071-3/+8
| | | | Change-Id: Icc1d0225908e432df10c36d69c6ed282f8761198
* Rename DB_SLAVE constant to DB_REPLICAAaron Schulz2016-09-051-1/+1
| | | | | | | | | 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
* Optimize summary-based extension edit stash cachesAaron Schulz2016-08-101-31/+87
| | | | | | | | | | | | | | * Send stash requests when the summary changes, so that things like AbuseFilter caching have a higher hit rate. * Make the backend API skip parsing if a fresh cache is already present. This makes requests for summary-only changes much faster and more likely to finish in time. * Avoid sending the full text if only the summary changed since the last successful stash. This works via an optional stashedtexthash parameter to the API. * Also always apply the lock in parseAndStash(), even for VE. Change-Id: I9bfd74cf05411853b675c6f54ff5d8934bcfc54c
* Try to predict the rev_id when preparing editsAaron Schulz2016-06-291-1/+4
| | | | | | | | | | | | | | | | During both the edit stash and first parse in on page save, guess what the rev_id will be and use that instead of null. Only reparse if it turns out to be wrong. This avoids extra parsing on wikis that have low-medium traffic, and does not cost much. The parsing that can be avoided is: a) in doEditContent() by using the stash b) in doEditUpdates() by using the doEditContent() result, whether that was able to use the stash or not itself Also improved the parse operation logging in save paths. Bug: T137900 Change-Id: Ic6faae70a78b4e223e4d3585cefd482c0fa00677
* Improve edit stashing when vary-revision is usedAaron Schulz2016-06-171-8/+13
| | | | | | | | | At least avoid the first parse in doEditContent()/filters which never has the revision set either. The second parse cannot be avoided in doEditUpdates() however. Bug: T136678 Change-Id: I12d2c3bbe1b21ad2ed9a484745d976ad62475e0d
* Perform edit stashing when the edit preview or diff form is requestedAaron Schulz2016-06-141-71/+0
| | | | | | | | | | | | * Users are likely to save after they inspect and review their changes. The buttons to do so are also located below the edit summary box. * This obsoletes the backend stashing on preview. Most of those parses would have been useless due to being per-section only. Also, some extensions like the Graph extension disable stashing for "preview" output anyway. Simplify the code by removing that method. Bug: T136678 Change-Id: Ied77bdbd191dd9267d4295b0fa7b942f65b062db
* Send the edit summary/user to the edit stash APIAaron Schulz2016-06-131-4/+9
| | | | | | | This can be useful for pre-caching AbuseFilter check results Bug: T137698 Change-Id: I03e3924408a2a5da09a411b66d09958a1b78cb99
* Add more logging info to parseAndStash() for uncacheable contentAaron Schulz2016-06-091-14/+16
| | | | Change-Id: I2409f0db518d366a747aa01ba5593dccdb34e68c
* Simplify ApiStashEdit::checkCache()Aaron Schulz2016-06-091-58/+5
| | | | | | | | Per https://grafana.wikimedia.org/dashboard/db/edit-stash, the proven_* cases are almost never hit. Simplify the code to avoid complexity and slow link table queries. Change-Id: I3f8bd79a80ddb26c6188b1a301c08766e38f6ad4
* Include title/user in some edit stash log messagesAaron Schulz2016-06-091-9/+11
| | | | Change-Id: I49d61d9cfc5edacf415f6822cb50cc9007735a27
* Remove getOptions() checks from getStashKey() entirelyAaron Schulz2016-06-061-3/+1
| | | | | | | It only avoided a tiny edge case of options lag, which is not worth the complexity. Change-Id: I94bc35fc89eb46436a23b10aee1b7d339859c7ea
* Make edit stash keys less preference sensitiveAaron Schulz2016-06-061-2/+6
| | | | | | | | Only factor in the user ID/name/sig instead of anything that might happen to touch the user row. Bug: T136678 Change-Id: I004790a017c68cfcff6729f6fbfd0f79b6904c20
* Send edit stash metrics for cache attemptsAaron Schulz2016-05-261-0/+2
| | | | Change-Id: I22d5626cca55c2cc35e1b33fced5902e8d364d40
* Bail out in ApiStashEdit for bots for sanityAaron Schulz2016-05-261-0/+4
| | | | | | checkCache() is disabled in this case anyway. Change-Id: I1c18585eecc1a7c4c0e24546799c7ee448b3ea57
* Exclude bots from edit stash statsAaron Schulz2016-05-261-0/+4
| | | | Change-Id: Id309879eaaf039de7ac5f531930fa8e758a959c7
* Improve edit stash hit rate for logged-out usersAaron Schulz2016-05-171-3/+26
| | | | | | | Check whether they made intervening edits just like logged-in users. Bug: T134620 Change-Id: Id1e0808caee0e474570c4f2e4b1cf845572e17e0
* Make "presumed-fresh" edit stash case cover when users make intervening editsAaron Schulz2016-05-131-6/+15
| | | | | | | | This still handles users editing inclusions themselves, but is more relaxed in terms of edits by other users to the inclusions. Bug: T134620 Change-Id: I6c0d189957481dfb6da0e73581b1d5b69fd3a352
* Make stashEditFromPreview() call setCacheTime()Aaron Schulz2016-05-071-0/+3
| | | | | | | This makes sure the output can pass the "presumed fresh" check. Bug: T134620 Change-Id: I4f9ac2f1b9cef5c6b179946ea02a5e2fad2adc09
* Bump PRESUME_FRESH_TTL_SEC to improve hit rate and avoid link queriesAaron Schulz2016-05-071-1/+1
| | | | | Task: T134620 Change-Id: I3f76d81ee0ff42bbab6a1b000907e80f4533519c
* Fix timestamp check in ApiStashEdit::checkCacheAaron Schulz2016-04-281-6/+8
| | | | | | | | | * The wrong time method was used, and it also was not set. * Bumped the threshold a bit while at it, which was basically 0-5 minutes before. Bug: T133332 Change-Id: Ide3e66f551aa6e50410c562e5c917141d59b7f64
* Segment stash edit cache stats by basis for hit/missOri Livneh2016-04-191-6/+6
| | | | | | | | | | | | | | | | Instead of just counting cache hits and misses, segment the counts by reason, so we can differentiate (for example) timestamp-based cache hits from staleness-check-survivor cache hits. I want this data so I can determine whether increasing the cutoff for timestamp-based hits from 3 to 5 seconds has a substantial enough impact to warrant the slightly weaker consistency. Also changed 'cache-hit' to 'cache_hit'. MediaWiki normalizes the dash to an underscore anyway, but the normalization is there for dynamically-constructed key names (or name segments). In the case of hard-coded values, it is desirable for the code to be as close as possible to the final form of the metric name, to simplify metric lookup. Change-Id: I0cd61da9746e3ca3695e23200f698b8b1371798c
* Merge "Use single quotes in API where possible"jenkins-bot2016-03-081-2/+2
|\
| * Use single quotes in API where possibleSiebrand Mazeland2016-03-081-2/+2
| | | | | | | | Change-Id: I972e296f4820f78f5dfcecc27bc4912ca84a3178
* | Declare functions with access modifiersSiebrand Mazeland2016-03-081-4/+4
|/ | | | | | Parents have this visibility. Change-Id: Icb4d0a112def0ac02f9aa42723c81bc63c085450