installer: Minor cleanup

* Minor comment tweaks

Change-Id: I76b44fcd88f27f6182f2b245301298a182e870f5
This commit is contained in:
Reedy 2024-01-05 18:07:37 +00:00
parent 78fc98c9ae
commit db1350ef61
7 changed files with 28 additions and 33 deletions

View file

@ -25,9 +25,7 @@ class InstallDocFormatter {
private $text;
public static function format( $text ) {
$obj = new self( $text );
return $obj->execute();
return ( new self( $text ) )->execute();
}
protected function __construct( $text ) {
@ -66,12 +64,10 @@ class InstallDocFormatter {
);
// add links to manual to every global variable mentioned
$text = preg_replace(
return preg_replace(
'/\$wg[a-z0-9_]+/i',
"{$linkStart}https://www.mediawiki.org/wiki/Manual:$0{$linkEnd}",
$text
);
return $text;
}
}

View file

@ -20,31 +20,32 @@
namespace MediaWiki\Installer;
use MediaWiki\Status\Status;
use Throwable;
/**
* Exception thrown if an error occur which installation
* Exception thrown if an error occurs during installation
* @ingroup Exception
*/
class InstallException extends \MWException {
/**
* @var \MediaWiki\Status\Status State when an exception occurs
* @var Status The state when an exception occurs
*/
private $status;
/**
* @param \MediaWiki\Status\Status $status State when an exception occurs
* @param Status $status The state when an exception occurs
* @param string $message The Exception message to throw
* @param int $code The Exception code
* @param Throwable|null $previous The previous throwable used for the exception chaining
*/
public function __construct( \MediaWiki\Status\Status $status, $message = '', $code = 0,
public function __construct( Status $status, $message = '', $code = 0,
Throwable $previous = null ) {
parent::__construct( $message, $code, $previous );
$this->status = $status;
}
public function getStatus(): \MediaWiki\Status\Status {
public function getStatus(): Status {
return $this->status;
}
}

View file

@ -437,7 +437,7 @@ class MysqlInstaller extends DatabaseInstaller {
}
// Validate engines and charsets
// This is done pre-submit already so it's just for security
// This is done pre-submit already, so it's just for security
$engines = $this->getEngines();
if ( !in_array( $this->getVar( '_MysqlEngine' ), $engines ) ) {
$this->setVar( '_MysqlEngine', reset( $engines ) );

View file

@ -159,7 +159,7 @@ class MysqlUpdater extends DatabaseUpdater {
}
/**
* Check whether an index contain a field
* Check whether an index contains a field
*
* @param string $table Table name
* @param string $index Index name to check
@ -238,7 +238,7 @@ class MysqlUpdater extends DatabaseUpdater {
}
/**
* Drop a default value from a field
* Drops the default value from a field
*
* @since 1.36
* @param string $table

View file

@ -140,7 +140,7 @@ class Pingback {
if ( $timestamp === false ) {
return false;
}
// send heartbeat ping if last ping was over a month ago
// send heartbeat ping if the last ping was over a month ago
if ( ConvertibleTimestamp::time() - (int)$timestamp > 60 * 60 * 24 * 30 ) {
return false;
}

View file

@ -144,23 +144,21 @@ class SqliteInstaller extends DatabaseInstaller {
if ( !is_readable( $dir ) ) {
return Status::newFatal( 'config-sqlite-dir-unwritable', $dir );
}
} else {
} elseif ( !is_writable( dirname( $dir ) ) ) {
// Check the parent directory if $dir not exists
if ( !is_writable( dirname( $dir ) ) ) {
$webserverGroup = Installer::maybeGetWebserverPrimaryGroup();
if ( $webserverGroup !== null ) {
return Status::newFatal(
'config-sqlite-parent-unwritable-group',
$dir, dirname( $dir ), basename( $dir ),
$webserverGroup
);
} else {
return Status::newFatal(
'config-sqlite-parent-unwritable-nogroup',
$dir, dirname( $dir ), basename( $dir )
);
}
$webserverGroup = Installer::maybeGetWebserverPrimaryGroup();
if ( $webserverGroup !== null ) {
return Status::newFatal(
'config-sqlite-parent-unwritable-group',
$dir, dirname( $dir ), basename( $dir ),
$webserverGroup
);
}
return Status::newFatal(
'config-sqlite-parent-unwritable-nogroup',
$dir, dirname( $dir ), basename( $dir )
);
}
return Status::newGood();
}
@ -384,8 +382,8 @@ EOT;
public function getLocalSettings() {
$dir = LocalSettingsGenerator::escapePhpString( $this->getVar( 'wgSQLiteDataDir' ) );
// These tables have frequent writes and are thus split off from the main one.
// Since the code using these tables only uses transactions for writes then set
// them to using BEGIN IMMEDIATE. This avoids frequent lock errors on first write.
// Since the code using these tables only uses transactions for writes, then set
// them to using BEGIN IMMEDIATE. This avoids frequent lock errors on the first write action.
return "# SQLite-specific settings
\$wgSQLiteDataDir = \"{$dir}\";
\$wgObjectCaches[CACHE_DB] = [

View file

@ -141,7 +141,7 @@ class SqliteUpdater extends DatabaseUpdater {
}
/**
* Check whether an index contain a field
* Check whether an index contains a field
*
* @param string $table Table name
* @param string $index Index name to check