MediaWiki
master
|
Manage the pre-emptive page parsing for edits to wiki pages. More...
Public Member Functions | |
__construct (BagOStuff $cache, ILoadBalancer $lb, LoggerInterface $logger, StatsdDataFactoryInterface $stats, UserEditTracker $userEditTracker, UserFactory $userFactory, WikiPageFactory $wikiPageFactory, HookContainer $hookContainer, $initiator) | |
checkCache (PageIdentity $page, Content $content, UserIdentity $user) | |
Check that a prepared edit is in cache and still up-to-date. More... | |
fetchInputText ( $textHash) | |
parseAndCache ( $pageUpdater, Content $content, UserIdentity $user, string $summary) | |
stashInputText ( $text, $textHash) | |
Public Attributes | |
const | ERROR_BUSY = 'busy' |
const | ERROR_CACHE = 'error_cache' |
const | ERROR_NONE = 'stashed' |
const | ERROR_PARSE = 'error_parse' |
const | ERROR_UNCACHEABLE = 'uncacheable' |
const | INITIATOR_JOB_OR_CLI = 2 |
const | INITIATOR_USER = 1 |
const | MAX_CACHE_TTL = 300 |
const | MAX_SIGNATURE_TTL = 60 |
const | PRESUME_FRESH_TTL_SEC = 30 |
Private Member Functions | |
getAndWaitForStashValue ( $key) | |
getContentHash (Content $content) | |
Get hash of the content, factoring in model/format. More... | |
getStashKey (PageIdentity $page, $contentHash, UserIdentity $user) | |
Get the temporary prepared edit stash key for a user. More... | |
getStashValue ( $key) | |
incrStatsByContent ( $subkey, Content $content) | |
lastEditTime (UserIdentity $user) | |
pruneExcessStashedEntries (UserIdentity $user, $newKey) | |
recentStashEntryCount (UserIdentity $user) | |
storeStashValue ( $key, Content $pstContent, ParserOutput $parserOutput, $timestamp, UserIdentity $user) | |
Build a value to store in memcached based on the PST content and parser output. More... | |
Private Attributes | |
BagOStuff | $cache |
ParserOutputStashForEditHook | $hookRunner |
int | $initiator |
ILoadBalancer | $lb |
LoggerInterface | $logger |
StatsdDataFactoryInterface | $stats |
UserEditTracker | $userEditTracker |
UserFactory | $userFactory |
WikiPageFactory | $wikiPageFactory |
const | MAX_CACHE_RECENT = 2 |
Manage the pre-emptive page parsing for edits to wiki pages.
This is written to by ApiStashEdit, and consumed by ApiEditPage and EditPage (via PageUpdaterFactory and DerivedPageDataUpdater).
See also mediawiki.action.edit/stash.js.
Definition at line 53 of file PageEditStash.php.
MediaWiki\Storage\PageEditStash::__construct | ( | BagOStuff | $cache, |
ILoadBalancer | $lb, | ||
LoggerInterface | $logger, | ||
StatsdDataFactoryInterface | $stats, | ||
UserEditTracker | $userEditTracker, | ||
UserFactory | $userFactory, | ||
WikiPageFactory | $wikiPageFactory, | ||
HookContainer | $hookContainer, | ||
$initiator | |||
) |
BagOStuff | $cache | |
ILoadBalancer | $lb | |
LoggerInterface | $logger | |
StatsdDataFactoryInterface | $stats | |
UserEditTracker | $userEditTracker | |
UserFactory | $userFactory | |
WikiPageFactory | $wikiPageFactory | |
HookContainer | $hookContainer | |
int | $initiator | Class INITIATOR__* constant |
Definition at line 99 of file PageEditStash.php.
References MediaWiki\Storage\PageEditStash\$cache, MediaWiki\Storage\PageEditStash\$initiator, MediaWiki\Storage\PageEditStash\$lb, MediaWiki\Storage\PageEditStash\$logger, MediaWiki\Storage\PageEditStash\$stats, MediaWiki\Storage\PageEditStash\$userEditTracker, MediaWiki\Storage\PageEditStash\$userFactory, and MediaWiki\Storage\PageEditStash\$wikiPageFactory.
MediaWiki\Storage\PageEditStash::checkCache | ( | PageIdentity | $page, |
Content | $content, | ||
UserIdentity | $user | ||
) |
Check that a prepared edit is in cache and still up-to-date.
This method blocks if the prepared edit is already being rendered, waiting until rendering finishes before doing final validity checks.
The cache is rejected if template or file changes are detected. Note that foreign template or file transclusions are not checked.
This returns an object with the following fields:
PageIdentity | $page | |
Content | $content | |
UserIdentity | $user | to get parser options from |
Definition at line 247 of file PageEditStash.php.
References MediaWiki\Storage\PageEditStash\$logger, MediaWiki\Storage\PageEditStash\getAndWaitForStashValue(), MediaWiki\Storage\PageEditStash\getContentHash(), MediaWiki\User\UserIdentity\getName(), MediaWiki\Storage\PageEditStash\getStashKey(), MediaWiki\Storage\PageEditStash\incrStatsByContent(), MediaWiki\User\UserIdentity\isRegistered(), MediaWiki\Storage\PageEditStash\lastEditTime(), MediaWiki\Storage\PageEditStash\recentStashEntryCount(), and wfTimestamp().
MediaWiki\Storage\PageEditStash::fetchInputText | ( | $textHash | ) |
string | $textHash |
Definition at line 388 of file PageEditStash.php.
|
private |
string | $key |
Definition at line 362 of file PageEditStash.php.
References MediaWiki\Storage\PageEditStash\getStashValue().
Referenced by MediaWiki\Storage\PageEditStash\checkCache().
|
private |
Get hash of the content, factoring in model/format.
Content | $content |
Definition at line 434 of file PageEditStash.php.
References $content.
Referenced by MediaWiki\Storage\PageEditStash\checkCache(), and MediaWiki\Storage\PageEditStash\parseAndCache().
|
private |
Get the temporary prepared edit stash key for a user.
This key can be used for caching prepared edits provided:
PageIdentity | $page | |
string | $contentHash | Result of getContentHash() |
UserIdentity | $user | User to get parser options from |
Definition at line 454 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\checkCache(), and MediaWiki\Storage\PageEditStash\parseAndCache().
|
private |
string | $key |
Definition at line 469 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\getAndWaitForStashValue(), and MediaWiki\Storage\PageEditStash\parseAndCache().
|
private |
string | $subkey | |
Content | $content |
Definition at line 353 of file PageEditStash.php.
References $content.
Referenced by MediaWiki\Storage\PageEditStash\checkCache().
|
private |
UserIdentity | $user |
Definition at line 414 of file PageEditStash.php.
References DB_REPLICA, MediaWiki\User\UserIdentity\getName(), and wfTimestampOrNull().
Referenced by MediaWiki\Storage\PageEditStash\checkCache().
MediaWiki\Storage\PageEditStash::parseAndCache | ( | $pageUpdater, | |
Content | $content, | ||
UserIdentity | $user, | ||
string | $summary | ||
) |
PageUpdater | $pageUpdater | (a WikiPage instance is also supported but deprecated) |
Content | $content | Edit content |
UserIdentity | $user | |
string | $summary | Edit summary |
Definition at line 128 of file PageEditStash.php.
References $content, MediaWiki\Storage\PageEditStash\$logger, DB_PRIMARY, EDIT_INTERNAL, MediaWiki\Storage\PageEditStash\ERROR_BUSY, MediaWiki\Storage\PageEditStash\ERROR_CACHE, MediaWiki\Storage\PageEditStash\ERROR_NONE, MediaWiki\Storage\PageEditStash\ERROR_PARSE, MediaWiki\Storage\PageEditStash\ERROR_UNCACHEABLE, MediaWiki\Storage\PageEditStash\getContentHash(), MediaWiki\Storage\PageEditStash\getStashKey(), MediaWiki\Storage\PageEditStash\getStashValue(), MediaWiki\Revision\SlotRecord\MAIN, MediaWiki\Storage\PageEditStash\PRESUME_FRESH_TTL_SEC, MediaWiki\Storage\PageEditStash\storeStashValue(), and wfTimestamp().
|
private |
UserIdentity | $user | |
string | $newKey |
Definition at line 531 of file PageEditStash.php.
References MediaWiki\User\UserIdentity\getName(), and BagOStuff\WRITE_PRUNE_SEGMENTS.
Referenced by MediaWiki\Storage\PageEditStash\storeStashValue().
|
private |
UserIdentity | $user |
Definition at line 548 of file PageEditStash.php.
References MediaWiki\User\UserIdentity\getName().
Referenced by MediaWiki\Storage\PageEditStash\checkCache().
MediaWiki\Storage\PageEditStash::stashInputText | ( | $text, | |
$textHash | |||
) |
string | $text | |
string | $textHash |
Definition at line 399 of file PageEditStash.php.
References BagOStuff\WRITE_ALLOW_SEGMENTS.
|
private |
Build a value to store in memcached based on the PST content and parser output.
This makes a simple version of WikiPage::prepareContentForEdit() as stash info
string | $key | |
Content | $pstContent | Pre-Save transformed content |
ParserOutput | $parserOutput | |
string | $timestamp | TS_MW |
UserIdentity | $user |
Definition at line 490 of file PageEditStash.php.
References CacheTime\getCacheExpiry(), CacheTime\getCacheTime(), ParserOutput\getOutputFlag(), MediaWiki\User\UserIdentity\isRegistered(), MediaWiki\Storage\PageEditStash\pruneExcessStashedEntries(), true, wfTimestamp(), and BagOStuff\WRITE_ALLOW_SEGMENTS.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().
|
private |
Definition at line 55 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
|
private |
Definition at line 63 of file PageEditStash.php.
|
private |
Definition at line 71 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
|
private |
Definition at line 57 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
|
private |
Definition at line 59 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct(), MediaWiki\Storage\PageEditStash\checkCache(), and MediaWiki\Storage\PageEditStash\parseAndCache().
|
private |
Definition at line 61 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
|
private |
Definition at line 65 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
|
private |
Definition at line 67 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
|
private |
Definition at line 69 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\__construct().
const MediaWiki\Storage\PageEditStash::ERROR_BUSY = 'busy' |
Definition at line 77 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().
const MediaWiki\Storage\PageEditStash::ERROR_CACHE = 'error_cache' |
Definition at line 75 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().
const MediaWiki\Storage\PageEditStash::ERROR_NONE = 'stashed' |
Definition at line 73 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().
const MediaWiki\Storage\PageEditStash::ERROR_PARSE = 'error_parse' |
Definition at line 74 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().
const MediaWiki\Storage\PageEditStash::ERROR_UNCACHEABLE = 'uncacheable' |
Definition at line 76 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().
const MediaWiki\Storage\PageEditStash::INITIATOR_JOB_OR_CLI = 2 |
Definition at line 86 of file PageEditStash.php.
const MediaWiki\Storage\PageEditStash::INITIATOR_USER = 1 |
Definition at line 85 of file PageEditStash.php.
|
private |
Definition at line 83 of file PageEditStash.php.
const MediaWiki\Storage\PageEditStash::MAX_CACHE_TTL = 300 |
Definition at line 80 of file PageEditStash.php.
const MediaWiki\Storage\PageEditStash::MAX_SIGNATURE_TTL = 60 |
Definition at line 81 of file PageEditStash.php.
const MediaWiki\Storage\PageEditStash::PRESUME_FRESH_TTL_SEC = 30 |
Definition at line 79 of file PageEditStash.php.
Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().