MediaWiki master
MediaWiki\Storage\PageEditStash Class Reference

Manage the pre-emptive page parsing for edits to wiki pages. More...

Public Member Functions

 __construct (private BagOStuff $cache, private IConnectionProvider $dbProvider, private LoggerInterface $logger, private StatsFactory $stats, private UserEditTracker $userEditTracker, private UserFactory $userFactory, private WikiPageFactory $wikiPageFactory, private JsonCodec $jsonCodec, HookContainer $hookContainer, $initiator)
 
 checkCache (PageIdentity $page, Content $content, UserIdentity $user)
 Check that a prepared edit is in cache and still up-to-date.
 
 fetchInputText (string $textHash)
 
 parseAndCache ( $pageUpdater, Content $content, UserIdentity $user, string $summary)
 
 stashInputText (string $text, string $textHash)
 

Public Attributes

const CURRENT_FORMAT_VERSION = 3
 
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 OTHER_FORMAT_VERSIONS = []
 
const PRESUME_FRESH_TTL_SEC = 30
 

Detailed Description

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.

Since
1.34

Definition at line 42 of file PageEditStash.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Storage\PageEditStash::__construct ( private BagOStuff $cache,
private IConnectionProvider $dbProvider,
private LoggerInterface $logger,
private StatsFactory $stats,
private UserEditTracker $userEditTracker,
private UserFactory $userFactory,
private WikiPageFactory $wikiPageFactory,
private JsonCodec $jsonCodec,
HookContainer $hookContainer,
$initiator )
Parameters
BagOStuff$cache
IConnectionProvider$dbProvider
LoggerInterface$logger
StatsFactory$stats
UserEditTracker$userEditTracker
UserFactory$userFactory
WikiPageFactory$wikiPageFactory
JsonCodec$jsonCodec
HookContainer$hookContainer
int$initiatorClass INITIATOR__* constant

Definition at line 85 of file PageEditStash.php.

Member Function Documentation

◆ checkCache()

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 a PageEditStashContents object with the following fields:

  • pstContent: the Content after pre-save-transform
  • output: the ParserOutput instance
  • timestamp: the timestamp of the parse
  • edits: author edit count if they are logged in or NULL otherwise
Parameters
PageIdentity$page
Content$content
UserIdentity$userto get parser options from
Returns
PageEditStashContents|false Returns edit stash object or false on cache miss

Definition at line 236 of file PageEditStash.php.

◆ fetchInputText()

MediaWiki\Storage\PageEditStash::fetchInputText ( string $textHash)
Parameters
string$textHash
Returns
string|false Text or false if missing

Definition at line 387 of file PageEditStash.php.

◆ parseAndCache()

MediaWiki\Storage\PageEditStash::parseAndCache ( $pageUpdater,
Content $content,
UserIdentity $user,
string $summary )
Parameters
PageUpdater$pageUpdater(a WikiPage instance is also supported but deprecated)
Content$contentEdit content
UserIdentity$user
string$summaryEdit summary
Returns
string Class ERROR_* constant

Definition at line 108 of file PageEditStash.php.

References 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\PRESUME_FRESH_TTL_SEC, wfDeprecated(), and wfTimestamp().

◆ stashInputText()

MediaWiki\Storage\PageEditStash::stashInputText ( string $text,
string $textHash )
Parameters
string$text
string$textHash
Returns
bool Success

Definition at line 398 of file PageEditStash.php.

Member Data Documentation

◆ CURRENT_FORMAT_VERSION

const MediaWiki\Storage\PageEditStash::CURRENT_FORMAT_VERSION = 3

Definition at line 66 of file PageEditStash.php.

◆ ERROR_BUSY

const MediaWiki\Storage\PageEditStash::ERROR_BUSY = 'busy'

Definition at line 52 of file PageEditStash.php.

Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().

◆ ERROR_CACHE

const MediaWiki\Storage\PageEditStash::ERROR_CACHE = 'error_cache'

Definition at line 50 of file PageEditStash.php.

Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().

◆ ERROR_NONE

const MediaWiki\Storage\PageEditStash::ERROR_NONE = 'stashed'

Definition at line 48 of file PageEditStash.php.

Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().

◆ ERROR_PARSE

const MediaWiki\Storage\PageEditStash::ERROR_PARSE = 'error_parse'

Definition at line 49 of file PageEditStash.php.

Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().

◆ ERROR_UNCACHEABLE

const MediaWiki\Storage\PageEditStash::ERROR_UNCACHEABLE = 'uncacheable'

Definition at line 51 of file PageEditStash.php.

Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().

◆ INITIATOR_JOB_OR_CLI

const MediaWiki\Storage\PageEditStash::INITIATOR_JOB_OR_CLI = 2

Definition at line 61 of file PageEditStash.php.

◆ INITIATOR_USER

const MediaWiki\Storage\PageEditStash::INITIATOR_USER = 1

Definition at line 60 of file PageEditStash.php.

◆ MAX_CACHE_TTL

const MediaWiki\Storage\PageEditStash::MAX_CACHE_TTL = 300

Definition at line 55 of file PageEditStash.php.

◆ MAX_SIGNATURE_TTL

const MediaWiki\Storage\PageEditStash::MAX_SIGNATURE_TTL = 60

Definition at line 56 of file PageEditStash.php.

◆ OTHER_FORMAT_VERSIONS

const MediaWiki\Storage\PageEditStash::OTHER_FORMAT_VERSIONS = []

Definition at line 71 of file PageEditStash.php.

◆ PRESUME_FRESH_TTL_SEC

const MediaWiki\Storage\PageEditStash::PRESUME_FRESH_TTL_SEC = 30

Definition at line 54 of file PageEditStash.php.

Referenced by MediaWiki\Storage\PageEditStash\parseAndCache().


The documentation for this class was generated from the following file: