MediaWiki  REL1_22
Status Class Reference

Generic operation result class Has warning/error list, boolean status and arbitrary value. More...

Inheritance diagram for Status:

List of all members.

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.

Detailed Description

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.


Member Function Documentation

Sanitize the callback parameter on wakeup, to avoid arbitrary execution.

Definition at line 153 of file Status.php.

Status::cleanParams ( params) [protected]
Parameters:
$paramsarray
Returns:
array

Definition at line 161 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.

Parameters:
string | Message$messagemessage name or object

Definition at line 127 of file Status.php.

References $params, array(), and errors.

Status::fatal ( message)

Add an error and set OK to false, indicating that the operation as a whole was fatal.

Parameters:
string | Message$messagemessage 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.

Parameters:
$errorMixed 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.
Returns:
String

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.

Parameters:
$errorsArray
Returns:
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)

Returns:
array A list in which each entry is an array with a message key as its first element. The remaining array elements are the message parameters.

Definition at line 333 of file Status.php.

References getStatusArray().

Referenced by CliInstaller\showStatusMessage().

Returns a list of status messages of the given type, with message and params left untouched, like a sane version of getStatusArray.

Parameters:
$typeString
Returns:
Array

Definition at line 377 of file Status.php.

References $error, $result, array(), as, and errors.

Status::getHTML ( shortContext = false,
longContext = false 
)

Get the error message as HTML.

This is done by parsing the wikitext error message.

Note:
: this does not perform a full wikitext to HTML conversion, it merely applies a message transformation.
Todo:
figure out whether that is actually The Right Thing.

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.

Parameters:
string$shortContexta short enclosing context message name, to be used when there is a single error
string$longContexta long enclosing context message name, for a list
Returns:
Message

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.

Parameters:
$typeString
Returns:
Array

Definition at line 353 of file Status.php.

References $error, $result, array(), as, and errors.

Referenced by getErrorsArray(), and getWarningsArray().

Returns:
mixed

Definition at line 430 of file Status.php.

Get the list of warnings (but not errors)

Returns:
array A list in which each entry is an array with a message key as its first element. The remaining array elements are the message parameters.

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.

Parameters:
string$shortContexta short enclosing context message name, to be used when there is a single error
string$longContexta long enclosing context message name, for a list
Returns:
String

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.

Parameters:
string$msgmessage name
Returns:
Boolean

Definition at line 396 of file Status.php.

References $error, as, and errors.

Returns whether the operation completed and didn't have any error or warnings.

Returns:
Boolean

Definition at line 95 of file Status.php.

References errors.

Returns whether the operation completed.

Returns:
Boolean

Definition at line 104 of file Status.php.

Status::merge ( other,
overwriteValue = false 
)

Merge another status object into this one.

Parameters:
$otherStatus Other Status object
$overwriteValueBoolean: 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::newGood ( value = null) [static]

Factory function for good results.

Parameters:
$valueMixed
Returns:
Status

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.

Parameters:
$sourceMessage|String: Message key or object to search for
$destMessage|String: Replacement message key or object
Returns:
bool Return true if the replacement was done, false otherwise.

Definition at line 416 of file Status.php.

References $error, $source, as, and errors.

Status::setResult ( ok,
value = null 
)

Change operation result.

Parameters:
$okBoolean: whether the operation completed
$valueMixed

Definition at line 84 of file Status.php.

References $ok, and $value.

Status::warning ( message)

Add a new warning.

Parameters:
string | Message$messagemessage name or object

Definition at line 113 of file Status.php.

References $params, array(), and errors.

Referenced by Installer\createMainpage().


Member Data Documentation

Status::$cleanCallback = false

Definition at line 50 of file Status.php.

Status::$errors = array()

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().


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