if ( $wgSharedDB && in_array( $tbl, $wgSharedTables, true ) ) {
// Shared tables don't work properly when cloning due to
// how prefixes are handled (bug 65654)
- throw new MWException( "Cannot clone shared table $tbl." );
+ throw new RuntimeException( "Cannot clone shared table $tbl." );
}
# Clean up from previous aborted run. So that table escaping
# works correctly across DB engines, we need to change the pre-
) {
if ( $oldTableName === $newTableName ) {
// Last ditch check to avoid data loss
- throw new MWException( "Not dropping new table, as '$newTableName'"
+ throw new LogicException( "Not dropping new table, as '$newTableName'"
. " is name of both the old and the new table." );
}
$this->db->dropTable( $tbl, __METHOD__ );
if ( in_array( $p['driver'], $possibleDrivers ) ) {
$driver = $p['driver'];
} else {
- throw new MWException( __METHOD__ .
- " cannot construct Database with type '$dbType' and driver '{$p['driver']}'" );
+ throw new InvalidArgumentException( __METHOD__ .
+ " type '$dbType' does not support driver '{$p['driver']}'" );
}
} else {
foreach ( $possibleDrivers as $posDriver ) {
* not restored on unserialize.
*/
public function __sleep() {
- throw new MWException( 'Database serialization may cause problems, since ' .
+ throw new RuntimeException( 'Database serialization may cause problems, since ' .
'the connection is not restored on wakeup.' );
}
$closed = $this->closeConnection();
$this->mConn = false;
} elseif ( $this->mTrxIdleCallbacks || $this->mTrxEndCallbacks ) { // sanity
- throw new MWException( "Transaction callbacks still pending." );
+ throw new RuntimeException( "Transaction callbacks still pending." );
} else {
$closed = true;
}
unset( $value[$nullKey] );
}
if ( count( $value ) == 0 && !$includeNull ) {
- throw new MWException( __METHOD__ . ": empty input for field $field" );
+ throw new InvalidArgumentException( __METHOD__ . ": empty input for field $field" );
} elseif ( count( $value ) == 0 ) {
// only check if $field is null
$list .= "$field IS NULL";
public function duplicateTableStructure( $oldName, $newName, $temporary = false,
$fname = __METHOD__
) {
- throw new MWException(
+ throw new RuntimeException(
'DatabaseBase::duplicateTableStructure is not implemented in descendant class' );
}
function listTables( $prefix = null, $fname = __METHOD__ ) {
- throw new MWException( 'DatabaseBase::listTables is not implemented in descendant class' );
+ throw new RuntimeException( 'DatabaseBase::listTables is not implemented in descendant class' );
}
/**
* @since 1.22
*/
public function listViews( $prefix = null, $fname = __METHOD__ ) {
- throw new MWException( 'DatabaseBase::listViews is not implemented in descendant class' );
+ throw new RuntimeException( 'DatabaseBase::listViews is not implemented in descendant class' );
}
/**
* @since 1.22
*/
public function isView( $name ) {
- throw new MWException( 'DatabaseBase::isView is not implemented in descendant class' );
+ throw new RuntimeException( 'DatabaseBase::isView is not implemented in descendant class' );
}
public function timestamp( $ts = 0 ) {
MediaWiki\restoreWarnings();
if ( false === $fp ) {
- throw new MWException( "Could not open \"{$filename}\".\n" );
+ throw new RuntimeException( "Could not open \"{$filename}\".\n" );
}
if ( !$fname ) {
*/
private function escapeIdentifier( $identifier ) {
if ( strlen( $identifier ) == 0 ) {
- throw new MWException( "An identifier must not be empty" );
+ throw new InvalidArgumentException( "An identifier must not be empty" );
}
if ( strlen( $identifier ) > 128 ) {
- throw new MWException( "The identifier '$identifier' is too long (max. 128)" );
+ throw new InvalidArgumentException( "The identifier '$identifier' is too long (max. 128)" );
}
if ( ( strpos( $identifier, '[' ) !== false )
|| ( strpos( $identifier, ']' ) !== false )
) {
// It may be allowed if you quoted with double quotation marks, but
// that would break if QUOTED_IDENTIFIER is OFF
- throw new MWException( "Square brackets are not allowed in '$identifier'" );
+ throw new InvalidArgumentException( "Square brackets are not allowed in '$identifier'" );
}
return "[$identifier]";
protected function doQuery( $sql ) {
wfDebug( "SQL: [$sql]\n" );
if ( !StringUtils::isUtf8( $sql ) ) {
- throw new MWException( "SQL encoding is invalid\n$sql" );
+ throw new InvalidArgumentException( "SQL encoding is invalid\n$sql" );
}
// handle some oracle specifics
$this->addQuotes( $oldName ) . " AND type='table'", $fname );
$obj = $this->fetchObject( $res );
if ( !$obj ) {
- throw new MWException( "Couldn't retrieve structure for table $oldName" );
+ throw new RuntimeException( "Couldn't retrieve structure for table $oldName" );
}
$sql = $obj->sql;
$sql = preg_replace(
foreach ( $required as $key ) {
if ( !isset( $conf[$key] ) ) {
- throw new MWException( __CLASS__ . ": $key is required in configuration" );
+ throw new InvalidArgumentException( __CLASS__ . ": $key is required in configuration" );
}
$this->$key = $conf[$key];
}
*/
protected function newExternalLB( $cluster, $wiki = false ) {
if ( !isset( $this->externalLoads[$cluster] ) ) {
- throw new MWException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
+ throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
}
$template = $this->serverTemplate;
if ( isset( $this->externalTemplateOverrides ) ) {
protected function newExternalLB( $cluster, $wiki = false ) {
global $wgExternalServers;
if ( !isset( $wgExternalServers[$cluster] ) ) {
- throw new MWException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
+ throw new InvalidArgumentException( __METHOD__ . ": Unknown cluster \"$cluster\"" );
}
return $this->newLoadBalancer( $wgExternalServers[$cluster] );
}
if ( !count( $nonErrorLoads ) ) {
- throw new MWException( "Empty server array given to LoadBalancer" );
+ throw new InvalidArgumentException( "Empty server array given to LoadBalancer" );
}
# Scale the configured load ratios according to the dynamic load if supported
public function getConnection( $i, $groups = [], $wiki = false ) {
if ( $i === null || $i === false ) {
- throw new MWException( 'Attempt to call ' . __METHOD__ .
+ throw new InvalidArgumentException( 'Attempt to call ' . __METHOD__ .
' with invalid server index' );
}
$wiki = $dbName;
}
if ( $this->mConns['foreignUsed'][$serverIndex][$wiki] !== $conn ) {
- throw new MWException( __METHOD__ . ": connection not found, has " .
+ throw new InvalidArgumentException( __METHOD__ . ": connection not found, has " .
"the connection been freed already?" );
}
$conn->setLBInfo( 'foreignPoolRefCount', --$refCount );
}
if ( !is_array( $server ) ) {
- throw new MWException( 'You must update your load-balancing configuration. ' .
+ throw new InvalidArgumentException( 'You must update your load-balancing configuration. ' .
'See DefaultSettings.php entry for $wgDBservers.' );
}