MediaWiki
1.23.2
|
Generic operation result class Has warning/error list, boolean status and arbitrary value. More...
Public Member Functions | |
__wakeup () | |
Sanitize the callback parameter on wakeup, to avoid arbitrary execution. More... | |
error ( $message) | |
Add an error, do not set fatal flag This can be used for non-fatal errors. More... | |
fatal ( $message) | |
Add an error and set OK to false, indicating that the operation as a whole was fatal. More... | |
getErrorsArray () | |
Get the list of errors (but not warnings) More... | |
getErrorsByType ( $type) | |
Returns a list of status messages of the given type, with message and params left untouched, like a sane version of getStatusArray. More... | |
getHTML ( $shortContext=false, $longContext=false) | |
Get the error message as HTML. More... | |
getMessage ( $shortContext=false, $longContext=false) | |
Get the error list as a Message object. More... | |
getValue () | |
getWarningsArray () | |
Get the list of warnings (but not errors) More... | |
getWikiText ( $shortContext=false, $longContext=false) | |
Get the error list as a wikitext formatted list. More... | |
hasMessage ( $msg) | |
Returns true if the specified message is present as a warning or error. More... | |
isGood () | |
Returns whether the operation completed and didn't have any error or warnings. More... | |
isOK () | |
Returns whether the operation completed. More... | |
merge ( $other, $overwriteValue=false) | |
Merge another status object into this one. More... | |
replaceMessage ( $source, $dest) | |
If the specified source message exists, replace it with the specified destination message, but keep the same parameters as in the original error. More... | |
setResult ( $ok, $value=null) | |
Change operation result. More... | |
warning ( $message) | |
Add a new warning. More... | |
Static Public Member Functions | |
static | newFatal ( $message) |
Factory function for fatal errors. More... | |
static | newGood ( $value=null) |
Factory function for good results. More... | |
Public Attributes | |
callable | $cleanCallback = false |
array | $errors = array() |
int | $failCount = 0 |
bool | $ok = true |
array | $success = array() |
Array to indicate which items of the batch operations were successful. More... | |
int | $successCount = 0 |
Counters for batch operations. More... | |
mixed | $value |
Protected Member Functions | |
cleanParams ( $params) | |
getErrorMessage ( $error) | |
Return the message for a single error. More... | |
getErrorMessageArray ( $errors) | |
Return an array with the wikitext for each item in the array. More... | |
getStatusArray ( $type) | |
Returns a list of status messages of the given type. More... | |
Generic operation result class Has warning/error list, boolean status and arbitrary value.
"Good" means the operation was completed with no warnings or errors.
"OK" means the operation was partially or wholly completed.
An operation which is not OK should have errors so that the user can be informed as to what went wrong. Calling the fatal() function sets an error message and simultaneously switches off the OK flag.
The recommended pattern for Status objects is to return a Status object unconditionally, i.e. both on success and on failure – so that the developer of the calling code is reminded that the function can fail, and so that a lack of error-handling will be explicit.
Definition at line 40 of file Status.php.
Status::__wakeup | ( | ) |
Sanitize the callback parameter on wakeup, to avoid arbitrary execution.
Definition at line 158 of file Status.php.
Referenced by StatusTest\testWakeUpSanitizesCallback().
|
protected |
$params | array |
Definition at line 166 of file Status.php.
References $params, array(), and as.
Referenced by getErrorMessage().
Status::error | ( | $message | ) |
Add an error, do not set fatal flag This can be used for non-fatal errors.
string | Message | $message | message name or object |
Definition at line 132 of file Status.php.
References $params, array(), and errors.
Referenced by StatusTest\testGetErrorsByType(), and StatusTest\testReplaceMessage().
Status::fatal | ( | $message | ) |
Add an error and set OK to false, indicating that the operation as a whole was fatal.
string | Message | $message | message name or object |
Definition at line 146 of file Status.php.
References $params, array(), and errors.
Referenced by getMessage(), FSFileBackend\getResponseCopy(), FSFileBackend\getResponseCreate(), FSFileBackend\getResponseDelete(), FSFileBackend\getResponseMove(), FSFileBackend\getResponseStore(), and getWikiText().
|
protected |
Return the message for a single error.
$error | Mixed With an array & two values keyed by 'message' and 'params', use those keys-value pairs. Otherwise, if its an array, just use the first value as the message and the remaining items as the params. |
Definition at line 278 of file Status.php.
References $error, cleanParams(), and wfMessage().
Referenced by getMessage(), and getWikiText().
|
protected |
Return an array with the wikitext for each item in the array.
$errors | Array |
Definition at line 315 of file Status.php.
References $errors, and array().
Referenced by getMessage(), and getWikiText().
Status::getErrorsArray | ( | ) |
Get the list of errors (but not warnings)
Definition at line 341 of file Status.php.
References getStatusArray().
Referenced by WebInstaller\showStatusMessage().
Status::getErrorsByType | ( | $type | ) |
Returns a list of status messages of the given type, with message and params left untouched, like a sane version of getStatusArray.
$type | String |
Definition at line 388 of file Status.php.
References $error, $type, array(), as, and errors.
Referenced by StatusTest\testGetErrorsByType().
Get the error message as HTML.
This is done by parsing the wikitext error message.
string | $shortContext | a short enclosing context message name, to be used when there is a single error |
string | $longContext | a long enclosing context message name, for a list |
Definition at line 304 of file Status.php.
References $out, getWikiText(), and MessageCache\singleton().
Referenced by StatusTest\testGetHtml().
Get the error list as a Message object.
string | string[] | $shortContext | A short enclosing context message name (or an array of message names), to be used when there is a single error. |
string | string[] | $longContext | A long enclosing context message name (or an array of message names), for a list. |
Definition at line 227 of file Status.php.
References $s, errors, fatal(), getErrorMessage(), getErrorMessageArray(), and wfMessage().
Referenced by StatusTest\testGetMessage().
|
protected |
Returns a list of status messages of the given type.
$type | String |
Definition at line 360 of file Status.php.
References $error, $type, array(), as, and errors.
Referenced by getErrorsArray(), and getWarningsArray().
Status::getValue | ( | ) |
Status::getWarningsArray | ( | ) |
Get the list of warnings (but not errors)
Definition at line 351 of file Status.php.
References getStatusArray().
Referenced by WebInstaller\showStatusMessage(), and StatusTest\testGetStatusArrayWithNonObjectMessages().
Get the error list as a wikitext formatted list.
string | $shortContext | a short enclosing context message name, to be used when there is a single error |
string | $longContext | a long enclosing context message name, for a list |
Definition at line 185 of file Status.php.
References $error, $errors, $s, as, errors, fatal(), getErrorMessage(), getErrorMessageArray(), and wfMessage().
Referenced by getHTML(), and StatusTest\testGetWikiText().
Status::hasMessage | ( | $msg | ) |
Returns true if the specified message is present as a warning or error.
Note, due to the lack of tools for comparing Message objects, this function will not work when using a Message object as a parameter.
string | $msg | message name |
Definition at line 407 of file Status.php.
Status::isGood | ( | ) |
Returns whether the operation completed and didn't have any error or warnings.
Definition at line 100 of file Status.php.
References $errors.
Referenced by SpecialEmailUser\execute(), LocalFileDeleteBatch\execute(), and HTMLForm\show().
Status::isOK | ( | ) |
Returns whether the operation completed.
Definition at line 109 of file Status.php.
References $ok.
Status::merge | ( | $other, | |
$overwriteValue = false |
|||
) |
Merge another status object into this one.
Status | $other | Other Status object |
bool | $overwriteValue | Whether to override the "value" member |
Definition at line 325 of file Status.php.
References errors.
Referenced by ScopedLock\factory(), and FileOpBatch\runParallelBatches().
|
static |
Factory function for fatal errors.
string | Message | $message | message name or object |
Reimplemented in FileRepoStatus.
Definition at line 63 of file Status.php.
References $params, and array().
Referenced by MWHttpRequest\__construct(), UploadFromChunks\addChunk(), LoginForm\addNewAccountInternal(), User\addToDatabase(), FileOp\attempt(), FileBackend\clean(), ImportReporter\close(), UploadBase\convertVerifyErrorToStatus(), FileBackendStore\createInternal(), Installer\createSysop(), SqliteInstaller\dataDirOKmaybeCreate(), SpecialRedirect\dispatch(), FileDeleteForm\doDelete(), WikiPage\doEditContent(), Installer\doEnvironmentChecks(), SwiftFileBackend\doExecuteOpHandlesInternal(), SpecialImport\doImport(), FileBackend\doOperations(), FileBackend\doQuickOperations(), WatchAction\doUnwatch(), WikiPage\doUpdateRestrictions(), WatchAction\doWatch(), PoolCounterWork\execute(), ZipDirectoryReader\execute(), UploadFromUrl\fetchFile(), UserrightsPage\fetchUser(), PoolCounterRedis\getConnection(), LoginForm\mailPasswordInternal(), User\newFatalPermissionDeniedStatus(), ImportStreamSource\newFromFile(), ImportStreamSource\newFromInterwiki(), ImportStreamSource\newFromUpload(), ImportStreamSource\newFromURL(), SpecialUnlockdb\onSubmit(), SpecialLockdb\onSubmit(), UploadFromUrl\performUpload(), DatabaseInstaller\populateInterwikiTable(), FileOp\precheck(), FileBackend\prepare(), AbstractContent\prepareSave(), FileBackend\publish(), UploadFromUrl\reallyFetchFile(), PoolCounterRedis\release(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), FileBackend\secure(), UserMailer\send(), UserMailer\sendWithPear(), User\setEmailWithConfirmation(), SqliteInstaller\setupDatabase(), PostgresInstaller\setupPLpgSQL(), PostgresInstaller\setupSchema(), PostgresInstaller\setupUser(), RevDel_List\setVisibility(), FileBackendStore\storeInternal(), PostgresInstaller\submitConnectForm(), OracleInstaller\submitConnectForm(), MysqlInstaller\submitConnectForm(), MssqlInstaller\submitConnectForm(), PostgresInstaller\submitSettingsForm(), MssqlInstaller\submitSettingsForm(), MysqlInstaller\submitSettingsForm(), DatabaseInstaller\submitWebUserBox(), StatusTest\testNewFatalWithMessage(), StatusTest\testNewFatalWithString(), SpecialUploadStash\tryClearStashedUploads(), Preferences\tryFormSubmit(), PageArchive\undeleteRevisions(), and PoolCounterRedis\waitForSlotOrNotif().
|
static |
Factory function for good results.
$value | Mixed |
Definition at line 77 of file Status.php.
References $value.
Referenced by MWHttpRequest\__construct(), FileBackendMultiWrite\accessibilityCheck(), PoolCounter_Stub\acquireForAnyone(), PoolCounter_Stub\acquireForMe(), SwiftFileBackend\addMissingMetadata(), User\addToDatabase(), FileOpBatch\attempt(), FileOp\attempt(), User\checkPasswordValidity(), SqliteInstaller\checkPrerequisites(), DatabaseInstaller\checkPrerequisites(), ImportReporter\close(), FSLockManager\closeLockHandles(), PostgresInstaller\commitChanges(), FileBackendStore\concatenate(), FileBackendMultiWrite\consistencyCheck(), SwiftFileBackend\createContainer(), Installer\createMainpage(), Installer\createSysop(), SqliteInstaller\dataDirOKmaybeCreate(), SwiftFileBackend\deleteContainer(), FileBackendStore\describeInternal(), FileOp\doAttempt(), CreateFileOp\doAttempt(), StoreFileOp\doAttempt(), CopyFileOp\doAttempt(), MoveFileOp\doAttempt(), FileBackendMultiWrite\doClean(), FileBackendStore\doClean(), FSFileBackend\doCleanInternal(), SwiftFileBackend\doCleanInternal(), FileBackendStore\doCleanInternal(), FileBackendStore\doConcatenate(), MemoryFileBackend\doCopyInternal(), FSFileBackend\doCopyInternal(), SwiftFileBackend\doCopyInternal(), MemoryFileBackend\doCreateInternal(), FSFileBackend\doCreateInternal(), SwiftFileBackend\doCreateInternal(), WikiPage\doDeleteArticleReal(), MemoryFileBackend\doDeleteInternal(), FSFileBackend\doDeleteInternal(), SwiftFileBackend\doDeleteInternal(), FileBackendStore\doDescribeInternal(), SwiftFileBackend\doDescribeInternal(), WikiPage\doEditContent(), Installer\doEnvironmentChecks(), FSFileBackend\doExecuteOpHandlesInternal(), SwiftFileBackend\doExecuteOpHandlesInternal(), MemcLockManager\doFreeLocksOnServer(), Installer\doGenerateKeys(), MemcLockManager\doGetLocksOnServer(), MySqlLockManager\doGetLocksOnServer(), PostgreSqlLockManager\doGetLocksOnServer(), FSLockManager\doLock(), NullLockManager\doLock(), QuorumLockManager\doLockByType(), LockManager\doLockByType(), QuorumLockManager\doLockingRequestBucket(), DBFileJournal\doLogChangeBatch(), NullFileJournal\doLogChangeBatch(), FSFileBackend\doMoveInternal(), SwiftFileBackend\doMoveInternal(), FileBackend\doOperations(), FileBackendMultiWrite\doOperationsInternal(), FileBackendStore\doOperationsInternal(), RevDel_RevisionList\doPostCommitUpdates(), RevDel_List\doPostCommitUpdates(), RevDel_ArchiveList\doPostCommitUpdates(), RevDel_FileList\doPostCommitUpdates(), FileOp\doPrecheck(), CreateFileOp\doPrecheck(), StoreFileOp\doPrecheck(), CopyFileOp\doPrecheck(), MoveFileOp\doPrecheck(), DeleteFileOp\doPrecheck(), DescribeFileOp\doPrecheck(), RevDel_RevisionList\doPreCommitUpdates(), RevDel_List\doPreCommitUpdates(), RevDel_ArchiveList\doPreCommitUpdates(), RevDel_FileList\doPreCommitUpdates(), FileBackendStore\doPrepare(), FileBackendMultiWrite\doPrepare(), FSFileBackend\doPrepareInternal(), FileBackendStore\doPrepareInternal(), SwiftFileBackend\doPrepareInternal(), FileBackendMultiWrite\doPublish(), FileBackendStore\doPublish(), FSFileBackend\doPublishInternal(), FileBackendStore\doPublishInternal(), SwiftFileBackend\doPublishInternal(), DBFileJournal\doPurgeOldLogs(), NullFileJournal\doPurgeOldLogs(), FileBackend\doQuickOperations(), FileBackendMultiWrite\doQuickOperationsInternal(), FileBackendStore\doQuickOperationsInternal(), FileBackendStore\doSecure(), FileBackendMultiWrite\doSecure(), FSFileBackend\doSecureInternal(), FileBackendStore\doSecureInternal(), SwiftFileBackend\doSecureInternal(), FSLockManager\doSingleLock(), FSLockManager\doSingleUnlock(), MemoryFileBackend\doStoreInternal(), FSFileBackend\doStoreInternal(), SwiftFileBackend\doStoreInternal(), MemoryFileBackend\doStreamFile(), FileBackendStore\doStreamFile(), SwiftFileBackend\doStreamFile(), FileBackendTest\doTestLockCalls(), FSLockManager\doUnlock(), NullLockManager\doUnlock(), QuorumLockManager\doUnlockByType(), LockManager\doUnlockByType(), QuorumLockManager\doUnlockingRequestBucket(), WatchAction\doUnwatch(), WikiPage\doUpdateRestrictions(), WatchAction\doWatch(), WatchAction\doWatchOrUnwatch(), ZipDirectoryReader\execute(), UploadFromUrl\fetchFile(), UploadBase\fetchFile(), UserrightsPage\fetchUser(), MemcLockManager\freeLocksOnServer(), DBLockManager\freeLocksOnServer(), RedisLockManager\freeLocksOnServer(), ApiUpload\getChunkResult(), PoolCounterRedis\getConnection(), DatabaseInstaller\getConnection(), RedisLockManager\getLocksOnServer(), MemcLockManager\getLocksOnServer(), DBLockManager\getLocksOnServer(), PostgresInstaller\getPgConnection(), Installer\includeExtensions(), LoginForm\initUser(), LockManager\lockByType(), FileJournal\logChangeBatch(), ImportStreamSource\newFromFile(), ImportStreamSource\newFromURL(), FileBackendStore\nullInternal(), SwiftFileBackend\objectListing(), SpecialUnlockdb\onSubmit(), SpecialLockdb\onSubmit(), MysqlInstaller\openConnection(), OracleInstaller\openConnection(), SqliteInstaller\openConnection(), MssqlInstaller\openConnection(), PostgresInstaller\openConnectionToAnyDB(), PostgresInstaller\openConnectionWithParams(), OracleInstaller\openSYSDBAConnection(), ApiUpload\performUpload(), DatabaseInstaller\populateInterwikiTable(), Installer\populateSiteStats(), FileOp\precheckDestExistence(), AbstractContent\prepareSave(), FSLockManager\pruneKeyLockFiles(), PoolCounterRedis\release(), PoolCounter_Stub\release(), RedisLockManager\releaseAllLocks(), MemcLockManager\releaseAllLocks(), MySqlLockManager\releaseAllLocks(), PostgreSqlLockManager\releaseAllLocks(), FileBackendMultiWrite\resyncFiles(), AssembleUploadChunksJob\run(), PublishStashedFileJob\run(), UserMailer\send(), UserMailer\sendWithPear(), SwiftFileBackend\setContainerAccess(), User\setEmailWithConfirmation(), WikiImporter\setTargetRootPage(), OracleInstaller\setupDatabase(), PostgresInstaller\setupDatabase(), PostgresInstaller\setupPLpgSQL(), PostgresInstaller\setupSchema(), OracleInstaller\setupUser(), MssqlInstaller\setupUser(), MysqlInstaller\setupUser(), PostgresInstaller\setupUser(), RevDel_List\setVisibility(), FileBackendStore\streamFile(), PostgresInstaller\submitConnectForm(), OracleInstaller\submitConnectForm(), MysqlInstaller\submitConnectForm(), MssqlInstaller\submitConnectForm(), OracleInstaller\submitInstallUserBox(), DatabaseInstaller\submitInstallUserBox(), DatabaseInstaller\submitSettingsForm(), PostgresInstaller\submitSettingsForm(), MssqlInstaller\submitSettingsForm(), MysqlInstaller\submitSettingsForm(), DatabaseInstaller\submitWebUserBox(), SyncFileBackend\syncFileBatch(), StatusTest\testNewGood(), SpecialUploadStash\tryClearStashedUploads(), Preferences\tryUISubmit(), PageArchive\undeleteRevisions(), SpecialBlock\validateTarget(), MediaHandler\verifyUpload(), and PoolCounterRedis\waitForSlotOrNotif().
Status::replaceMessage | ( | $source, | |
$dest | |||
) |
If the specified source message exists, replace it with the specified destination message, but keep the same parameters as in the original error.
Note, due to the lack of tools for comparing Message objects, this function will not work when using a Message object as the search parameter.
Message | string | $source | Message key or object to search for |
Message | string | $dest | Replacement message key or object |
Definition at line 427 of file Status.php.
References $error, $source, as, and errors.
Referenced by StatusTest\testReplaceMessage().
Status::setResult | ( | $ok, | |
$value = null |
|||
) |
Change operation result.
bool | $ok | Whether the operation completed |
mixed | $value |
Definition at line 89 of file Status.php.
Status::warning | ( | $message | ) |
Add a new warning.
string | Message | $message | message name or object |
Definition at line 118 of file Status.php.
References $params, array(), and errors.
Referenced by StatusTest\provideGetMessage(), StatusTest\testGetErrorsByType(), and StatusTest\testGetStatusArrayWithNonObjectMessages().
callable Status::$cleanCallback = false |
Definition at line 55 of file Status.php.
Definition at line 53 of file Status.php.
Referenced by getErrorMessageArray(), getWikiText(), and isGood().
int Status::$failCount = 0 |
Definition at line 48 of file Status.php.
bool Status::$ok = true |
Array to indicate which items of the batch operations were successful.
Definition at line 51 of file Status.php.
int Status::$successCount = 0 |
mixed Status::$value |
Definition at line 43 of file Status.php.
Referenced by getValue(), FileRepoStatus\newGood(), newGood(), and setResult().