'FileAwareNodeVisitor' => __DIR__ . '/maintenance/findDeprecated.php',
'FileBackend' => __DIR__ . '/includes/libs/filebackend/FileBackend.php',
'FileBackendDBRepoWrapper' => __DIR__ . '/includes/filerepo/FileBackendDBRepoWrapper.php',
- 'FileBackendError' => __DIR__ . '/includes/libs/filebackend/FileBackendException.php',
- 'FileBackendException' => __DIR__ . '/includes/libs/filebackend/FileBackendException.php',
+ 'FileBackendError' => __DIR__ . '/includes/libs/filebackend/FileBackendError.php',
'FileBackendGroup' => __DIR__ . '/includes/filebackend/FileBackendGroup.php',
'FileBackendMultiWrite' => __DIR__ . '/includes/filebackend/FileBackendMultiWrite.php',
'FileBackendStore' => __DIR__ . '/includes/filebackend/FileBackendStore.php',
*
* @param array $configs
* @param string|null $readOnlyReason
- * @throws FileBackendException
+ * @throws InvalidArgumentException
*/
protected function register( array $configs, $readOnlyReason = null ) {
foreach ( $configs as $config ) {
if ( !isset( $config['name'] ) ) {
- throw new FileBackendException( "Cannot register a backend with no name." );
+ throw new InvalidArgumentException( "Cannot register a backend with no name." );
}
$name = $config['name'];
if ( isset( $this->backends[$name] ) ) {
- throw new FileBackendException( "Backend with name `{$name}` already registered." );
+ throw new LogicException( "Backend with name `{$name}` already registered." );
} elseif ( !isset( $config['class'] ) ) {
- throw new FileBackendException( "Backend with name `{$name}` has no class." );
+ throw new InvalidArgumentException( "Backend with name `{$name}` has no class." );
}
$class = $config['class'];
*
* @param string $name
* @return FileBackend
- * @throws FileBackendException
+ * @throws InvalidArgumentException
*/
public function get( $name ) {
if ( !isset( $this->backends[$name] ) ) {
- throw new FileBackendException( "No backend defined with the name `$name`." );
+ throw new InvalidArgumentException( "No backend defined with the name `$name`." );
}
// Lazy-load the actual backend instance
if ( !isset( $this->backends[$name]['instance'] ) ) {
*
* @param string $name
* @return array
- * @throws FileBackendException
+ * @throws InvalidArgumentException
*/
public function config( $name ) {
if ( !isset( $this->backends[$name] ) ) {
- throw new FileBackendException( "No backend defined with the name `$name`." );
+ throw new InvalidArgumentException( "No backend defined with the name `$name`." );
}
$class = $this->backends[$name]['class'];
}
$name = $config['name'];
if ( isset( $namesUsed[$name] ) ) { // don't break FileOp predicates
- throw new FileBackendError( "Two or more backends defined with the name $name." );
+ throw new LogicException( "Two or more backends defined with the name $name." );
}
$namesUsed[$name] = 1;
// Alter certain sub-backend settings for sanity
$config['wikiId'] = $this->wikiId; // use the proxy backend wiki ID
if ( !empty( $config['isMultiMaster'] ) ) {
if ( $this->masterIndex >= 0 ) {
- throw new FileBackendError( 'More than one master backend defined.' );
+ throw new LogicException( 'More than one master backend defined.' );
}
$this->masterIndex = $index; // this is the "master"
$config['fileJournal'] = $this->fileJournal; // log under proxy backend
}
// Create sub-backend object
if ( !isset( $config['class'] ) ) {
- throw new FileBackendError( 'No class given for a backend config.' );
+ throw new InvalidArgumentException( 'No class given for a backend config.' );
}
$class = $config['class'];
$this->backends[$index] = new $class( $config );
}
if ( $this->masterIndex < 0 ) { // need backends and must have a master
- throw new FileBackendError( 'No master backend defined.' );
+ throw new LogicException( 'No master backend defined.' );
}
if ( $this->readIndex < 0 ) {
$this->readIndex = $this->masterIndex; // default
foreach ( $fileOpHandles as $fileOpHandle ) {
if ( !( $fileOpHandle instanceof FileBackendStoreOpHandle ) ) {
- throw new FileBackendError( "Given a non-FileBackendStoreOpHandle object." );
+ throw new InvalidArgumentException( "Got a non-FileBackendStoreOpHandle object." );
} elseif ( $fileOpHandle->backend->getName() !== $this->getName() ) {
- throw new FileBackendError( "Given a FileBackendStoreOpHandle for the wrong backend." );
+ throw new InvalidArgumentException(
+ "Got a FileBackendStoreOpHandle for the wrong backend." );
}
}
$res = $this->doExecuteOpHandlesInternal( $fileOpHandles );
*/
protected function doExecuteOpHandlesInternal( array $fileOpHandles ) {
if ( count( $fileOpHandles ) ) {
- throw new FileBackendError( "This backend supports no asynchronous operations." );
+ throw new LogicException( "Backend does not support asynchronous operations." );
}
return [];
if ( isset( $params[$name] ) ) {
$this->params[$name] = $params[$name];
} else {
- throw new FileBackendError( "File operation missing parameter '$name'." );
+ throw new InvalidArgumentException( "File operation missing parameter '$name'." );
}
}
foreach ( $optional as $name ) {
* - concurrency : How many file operations can be done in parallel.
* - tmpDirectory : Directory to use for temporary files. If this is not set or null,
* then the backend will try to discover a usable temporary directory.
- * @throws FileBackendException
+ * @throws InvalidArgumentException
*/
public function __construct( array $config ) {
$this->name = $config['name'];
$this->wikiId = $config['wikiId']; // e.g. "my_wiki-en_"
if ( !preg_match( '!^[a-zA-Z0-9-_]{1,255}$!', $this->name ) ) {
- throw new FileBackendException( "Backend name '{$this->name}' is invalid." );
+ throw new InvalidArgumentException( "Backend name '{$this->name}' is invalid." );
} elseif ( !is_string( $this->wikiId ) ) {
- throw new FileBackendException( "Backend wiki ID not provided for '{$this->name}'." );
+ throw new InvalidArgumentException( "Backend wiki ID not provided for '{$this->name}'." );
}
$this->lockManager = isset( $config['lockManager'] )
? $config['lockManager']
$type = strtolower( $type );
if ( !in_array( $type, [ 'inline', 'attachment' ] ) ) {
- throw new FileBackendError( "Invalid Content-Disposition type '$type'." );
+ throw new InvalidArgumentException( "Invalid Content-Disposition type '$type'." );
}
$parts[] = $type;
--- /dev/null
+<?php
+/**
+ * File backend exception for checked exceptions (e.g. I/O errors)
+ *
+ * @ingroup FileBackend
+ * @since 1.22
+ */
+class FileBackendError extends Exception {
+}
+++ /dev/null
-<?php
-/**
- * Generic file backend exception for checked and unexpected (e.g. config) exceptions
- *
- * @ingroup FileBackend
- * @since 1.23
- */
-class FileBackendException extends Exception {
-}
-
-/**
- * File backend exception for checked exceptions (e.g. I/O errors)
- *
- * @ingroup FileBackend
- * @since 1.22
- */
-class FileBackendError extends FileBackendException {
-}