MediaWiki
REL1_22
|
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. | |
error ($message) | |
Add an error, do not set fatal flag This can be used for non-fatal errors. | |
fatal ($message) | |
Add an error and set OK to false, indicating that the operation as a whole was fatal. | |
getErrorsArray () | |
Get the list of errors (but not warnings) | |
getErrorsByType ($type) | |
Returns a list of status messages of the given type, with message and params left untouched, like a sane version of getStatusArray. | |
getHTML ($shortContext=false, $longContext=false) | |
Get the error message as HTML. | |
getMessage ($shortContext=false, $longContext=false) | |
Get the error list as a Message object. | |
getValue () | |
getWarningsArray () | |
Get the list of warnings (but not errors) | |
getWikiText ($shortContext=false, $longContext=false) | |
Get the error list as a wikitext formatted list. | |
hasMessage ($msg) | |
Returns true if the specified message is present as a warning or error. | |
isGood () | |
Returns whether the operation completed and didn't have any error or warnings. | |
isOK () | |
Returns whether the operation completed. | |
merge ($other, $overwriteValue=false) | |
Merge another status object into this one. | |
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. | |
setResult ($ok, $value=null) | |
Change operation result. | |
warning ($message) | |
Add a new warning. | |
Static Public Member Functions | |
static | newFatal ($message) |
Factory function for fatal errors. | |
static | newGood ($value=null) |
Factory function for good results. | |
Public Attributes | |
$cleanCallback = false | |
$errors = array() | |
$failCount = 0 | |
$ok = true | |
$success = array() | |
Array to indicate which items of the batch operations were successful. | |
$successCount = 0 | |
Counters for batch operations. | |
$value | |
Protected Member Functions | |
cleanParams ($params) | |
getErrorMessage ($error) | |
Return the message for a single error. | |
getErrorMessageArray ($errors) | |
Return an array with the wikitext for each item in the array. | |
getStatusArray ($type) | |
Returns a list of status messages of the given type. |
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 153 of file Status.php.
Status::cleanParams | ( | $ | params | ) | [protected] |
$params | array |
Definition at line 161 of file Status.php.
References $params, array(), and as.
Referenced by getErrorMessage().
Status::error | ( | $ | message | ) |
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 141 of file Status.php.
References $params, array(), and errors.
Referenced by getMessage(), and getWikiText().
Status::getErrorMessage | ( | $ | error | ) | [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 271 of file Status.php.
References $error, cleanParams(), and wfMessage().
Referenced by getMessage(), and getWikiText().
Status::getErrorMessageArray | ( | $ | errors | ) | [protected] |
Return an array with the wikitext for each item in the array.
$errors | Array |
Definition at line 307 of file Status.php.
References $errors, and array().
Referenced by getMessage(), and getWikiText().
Get the list of errors (but not warnings)
Definition at line 333 of file Status.php.
References getStatusArray().
Referenced by CliInstaller\showStatusMessage().
Status::getErrorsByType | ( | $ | type | ) |
Status::getHTML | ( | $ | shortContext = false , |
$ | longContext = false |
||
) |
Get the error message as HTML.
This is done by parsing the wikitext error message.
Definition at line 297 of file Status.php.
References getWikiText(), and MessageCache\singleton().
Status::getMessage | ( | $ | shortContext = false , |
$ | longContext = false |
||
) |
Get the error list as a Message object.
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 220 of file Status.php.
References $s, errors, fatal(), getErrorMessage(), getErrorMessageArray(), and wfMessage().
Status::getStatusArray | ( | $ | type | ) | [protected] |
Returns a list of status messages of the given type.
$type | String |
Definition at line 353 of file Status.php.
References $error, $result, array(), as, and errors.
Referenced by getErrorsArray(), and getWarningsArray().
Status::getValue | ( | ) |
Definition at line 430 of file Status.php.
Get the list of warnings (but not errors)
Definition at line 343 of file Status.php.
References getStatusArray().
Referenced by CliInstaller\showStatusMessage().
Status::getWikiText | ( | $ | shortContext = false , |
$ | longContext = false |
||
) |
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 180 of file Status.php.
References $error, $errors, $s, as, errors, fatal(), getErrorMessage(), getErrorMessageArray(), and wfMessage().
Referenced by getHTML().
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 396 of file Status.php.
Status::isGood | ( | ) |
Returns whether the operation completed and didn't have any error or warnings.
Definition at line 95 of file Status.php.
References errors.
Status::isOK | ( | ) |
Status::merge | ( | $ | other, |
$ | overwriteValue = false |
||
) |
Merge another status object into this one.
$other | Status Other Status object |
$overwriteValue | Boolean: whether to override the "value" member |
Definition at line 317 of file Status.php.
References errors.
Referenced by SwiftFileBackend\doPublishInternal(), SwiftFileBackend\doSecureInternal(), and FileOpBatch\runParallelBatches().
static Status::newFatal | ( | $ | message | ) | [static] |
Factory function for fatal errors.
string | Message | $message | message name or object |
Reimplemented in FileRepoStatus.
Definition at line 58 of file Status.php.
References $params, $result, and array().
Referenced by ImportStreamSource\__construct(), UploadFromChunks\addChunk(), ImportReporter\close(), UploadBase\convertVerifyErrorToStatus(), SpecialImport\doImport(), WatchAction\doUnwatch(), WatchAction\doWatch(), CliInstaller\execute(), ZipDirectoryReader\execute(), UploadFromUrl\fetchFile(), UserrightsPage\fetchUser(), SpecialUnlockdb\onSubmit(), SpecialLockdb\onSubmit(), UploadFromUrl\performUpload(), UploadFromUrl\reallyFetchFile(), PublishStashedFileJob\run(), AssembleUploadChunksJob\run(), UserMailer\send(), UserMailer\sendWithPear(), PostgresInstaller\setupPLpgSQL(), PostgresInstaller\setupSchema(), PostgresInstaller\setupUser(), WebInstaller_DBConnect\submit(), PostgresInstaller\submitConnectForm(), OracleInstaller\submitConnectForm(), MysqlInstaller\submitConnectForm(), PostgresInstaller\submitSettingsForm(), MysqlInstaller\submitSettingsForm(), SpecialUploadStash\tryClearStashedUploads(), and Preferences\tryFormSubmit().
static Status::newGood | ( | $ | value = null | ) | [static] |
Factory function for good results.
$value | Mixed |
Definition at line 72 of file Status.php.
References $result, and $value.
Referenced by ImportStreamSource\__construct(), FileOpBatch\attempt(), ImportReporter\close(), PostgresInstaller\commitChanges(), MockFileBackend\doCopyInternal(), MockFileBackend\doCreateInternal(), MockFileBackend\doDeleteInternal(), NullFileJournal\doLogChangeBatch(), RevDel_RevisionList\doPostCommitUpdates(), RevDel_List\doPostCommitUpdates(), RevDel_ArchiveList\doPostCommitUpdates(), RevDel_FileList\doPostCommitUpdates(), RevDel_RevisionList\doPreCommitUpdates(), RevDel_List\doPreCommitUpdates(), RevDel_ArchiveList\doPreCommitUpdates(), RevDel_FileList\doPreCommitUpdates(), SwiftFileBackend\doPublishInternal(), NullFileJournal\doPurgeOldLogs(), SwiftFileBackend\doSecureInternal(), WatchAction\doUnwatch(), WatchAction\doWatch(), WatchAction\doWatchOrUnwatch(), ZipDirectoryReader\execute(), UploadFromUrl\fetchFile(), UploadBase\fetchFile(), UserrightsPage\fetchUser(), RedisLockManager\freeLocksOnServer(), RedisLockManager\getLocksOnServer(), PostgresInstaller\getPgConnection(), WebInstaller_ExistingWiki\importVariables(), FileJournal\logChangeBatch(), SpecialUnlockdb\onSubmit(), SpecialLockdb\onSubmit(), MysqlInstaller\openConnection(), OracleInstaller\openConnection(), PostgresInstaller\openConnectionToAnyDB(), PostgresInstaller\openConnectionWithParams(), OracleInstaller\openSYSDBAConnection(), PostgreSqlLockManager\releaseAllLocks(), PublishStashedFileJob\run(), AssembleUploadChunksJob\run(), UserMailer\send(), UserMailer\sendWithPear(), WikiImporter\setTargetRootPage(), OracleInstaller\setupDatabase(), PostgresInstaller\setupDatabase(), PostgresInstaller\setupPLpgSQL(), PostgresInstaller\setupSchema(), OracleInstaller\setupUser(), MysqlInstaller\setupUser(), PostgresInstaller\setupUser(), RevDel_List\setVisibility(), PostgresInstaller\submitConnectForm(), OracleInstaller\submitConnectForm(), MysqlInstaller\submitConnectForm(), OracleInstaller\submitInstallUserBox(), PostgresInstaller\submitSettingsForm(), MysqlInstaller\submitSettingsForm(), SyncFileBackend\syncFileBatch(), SpecialUploadStash\tryClearStashedUploads(), Preferences\tryUISubmit(), SpecialBlock\validateTarget(), and MediaHandler\verifyUpload().
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.
$source | Message|String: Message key or object to search for |
$dest | Message|String: Replacement message key or object |
Definition at line 416 of file Status.php.
Status::setResult | ( | $ | ok, |
$ | value = null |
||
) |
Change operation result.
$ok | Boolean: whether the operation completed |
$value | Mixed |
Definition at line 84 of file Status.php.
Status::warning | ( | $ | message | ) |
Add a new warning.
string | Message | $message | message name or object |
Definition at line 113 of file Status.php.
References $params, array(), and errors.
Referenced by Installer\createMainpage().
Status::$cleanCallback = false |
Definition at line 50 of file Status.php.
Definition at line 49 of file Status.php.
Referenced by getErrorMessageArray(), and getWikiText().
Status::$failCount = 0 |
Definition at line 45 of file Status.php.
Status::$ok = true |
Definition at line 41 of file Status.php.
Referenced by setResult().
Status::$success = array() |
Array to indicate which items of the batch operations were successful.
Definition at line 47 of file Status.php.
Status::$successCount = 0 |
Counters for batch operations.
Definition at line 45 of file Status.php.
Status::$value |
Definition at line 42 of file Status.php.
Referenced by FileRepoStatus\newGood(), newGood(), and setResult().