Wikibase
MediaWiki Wikibase extension
|
Handler for editing activity, providing a unified interface for saving modified entities while performing permission checks and handling edit conflicts. More...
Public Member Functions | |
getEntityId () | |
Returns the ID of the entity being edited. | |
getLatestRevision () | |
Returns the latest revision of the entity. | |
getBaseRevision () | |
Return the base revision for the edit. | |
getStatus () | |
Get the status object. | |
isSuccess () | |
Determines whether the last call to attemptSave was successful. | |
hasError ( $errorType=self::ANY_ERROR) | |
Checks whether this EditEntity encountered any of the given error types while executing attemptSave(). | |
hasEditConflict () | |
Determines whether an edit conflict exists, that is, whether another user has edited the same item after the base revision was created. | |
isTokenOK ( $token) | |
Make sure the given WebRequest contains a valid edit token. | |
attemptSave (EntityDocument $newEntity, string $summary, $flags, $token, $watch=null, array $tags=[]) | |
Attempts to save the given Entity object. | |
Public Attributes | |
const | PERMISSION_ERROR = 1 |
indicates a permission error | |
const | EDIT_CONFLICT_ERROR = 2 |
indicates an unresolved edit conflict | |
const | TOKEN_ERROR = 4 |
indicates a token or session error | |
const | SAVE_ERROR = 8 |
indicates that an error occurred while saving | |
const | PRECONDITION_FAILED_ERROR = 16 |
Indicates that the content failed some precondition to saving, such as a global uniqueness constraint. | |
const | FILTERED_ERROR = 32 |
Indicates that the content triggered an edit filter that uses the EditFilterMergedContent hook to supervise edits. | |
const | RATE_LIMIT_ERROR = 64 |
Indicates that the edit exceeded a rate limit. | |
const | ANY_ERROR = 0xFFFFFFFF |
bit mask for asking for any error. | |
Handler for editing activity, providing a unified interface for saving modified entities while performing permission checks and handling edit conflicts.
Wikibase\Repo\EditEntity\EditEntity::attemptSave | ( | EntityDocument | $newEntity, |
string | $summary, | ||
$flags, | |||
$token, | |||
$watch = null, | |||
array | $tags = [] ) |
Attempts to save the given Entity object.
This method performs entity level permission checks, checks the edit token, enforces rate limits, resolves edit conflicts, and updates user watchlists if appropriate.
Success or failure are reported via the Status object returned by this method.
EntityDocument | $newEntity | |
string | $summary | The edit summary. |
int | $flags | The EDIT_XXX flags as used by WikiPage::doUserEditContent(). Additionally, the EntityContent::EDIT_XXX constants can be used. |
string | bool | $token | Edit token to check, or false to disable the token check. Null will fail the token text, as will the empty string. |
bool | null | $watch | Whether the user wants to watch the entity. Set to null to apply default according to getWatchDefault(). |
string[] | $tags | Change tags to add to the edit. Callers are responsible for checking that the user is permitted to add these tags (typically using ChangeTagsStore::canAddTagsAccompanyingChange ). |
ReadOnlyError |
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::getBaseRevision | ( | ) |
Return the base revision for the edit.
If no base revision ID was supplied to the constructor, this returns the latest revision. If the entity does not exist yet, this returns null.
RevisionedUnresolvedRedirectException | |
StorageException |
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::getEntityId | ( | ) |
Returns the ID of the entity being edited.
May be null if a new entity is to be created.
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::getLatestRevision | ( | ) |
Returns the latest revision of the entity.
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::getStatus | ( | ) |
Get the status object.
Only defined after attemptSave() was called.
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::hasEditConflict | ( | ) |
Determines whether an edit conflict exists, that is, whether another user has edited the same item after the base revision was created.
In other words, this method checks whether the base revision (as provided to the constructor) is still current. If no base revision was provided to the constructor, this will always return false.
If the base revision is different from the current revision, this will return true even if the edit conflict is resolvable. Indeed, it is used to determine whether conflict resolution should be attempted.
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::hasError | ( | $errorType = self::ANY_ERROR | ) |
Checks whether this EditEntity encountered any of the given error types while executing attemptSave().
int | $errorType | bit field using the EditEntity::XXX_ERROR constants. Defaults to EditEntity::ANY_ERROR. |
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::isSuccess | ( | ) |
Determines whether the last call to attemptSave was successful.
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
Wikibase\Repo\EditEntity\EditEntity::isTokenOK | ( | $token | ) |
Make sure the given WebRequest contains a valid edit token.
string | $token | The token to check. |
Implemented in Wikibase\Repo\EditEntity\MediaWikiEditEntity, and Wikibase\Repo\EditEntity\StatsdSaveTimeRecordingEditEntity.
const Wikibase\Repo\EditEntity\EditEntity::ANY_ERROR = 0xFFFFFFFF |
bit mask for asking for any error.
const Wikibase\Repo\EditEntity\EditEntity::EDIT_CONFLICT_ERROR = 2 |
indicates an unresolved edit conflict
const Wikibase\Repo\EditEntity\EditEntity::FILTERED_ERROR = 32 |
Indicates that the content triggered an edit filter that uses the EditFilterMergedContent hook to supervise edits.
const Wikibase\Repo\EditEntity\EditEntity::PERMISSION_ERROR = 1 |
indicates a permission error
const Wikibase\Repo\EditEntity\EditEntity::PRECONDITION_FAILED_ERROR = 16 |
Indicates that the content failed some precondition to saving, such as a global uniqueness constraint.
const Wikibase\Repo\EditEntity\EditEntity::RATE_LIMIT_ERROR = 64 |
Indicates that the edit exceeded a rate limit.
const Wikibase\Repo\EditEntity\EditEntity::SAVE_ERROR = 8 |
indicates that an error occurred while saving
const Wikibase\Repo\EditEntity\EditEntity::TOKEN_ERROR = 4 |
indicates a token or session error