This page is a translated version of the page Manual:$wgReadOnly and the translation is 48% complete.
保守スクリプトの設定: $wgReadOnly
導入されたバージョン:pre 1.1.0
既定値:null (1.5.7+)
false (1.1.0-1.5.6)


機能上は、この設定は $wgReadOnlyFile と同じですが、ファイルの代わりに文字列を使用する点が異なります。

LocalSettings.php ファイル内の文字列に設定した場合は $wgReadOnly により編集が拒絶され、変数に指定した文字列が理由として表示されます。 指定した理由の前に MediaWiki:Readonlywarning の内容が表示されます。

$wgReadOnly = 'This wiki is currently being upgraded to a newer software version. Please check back in a couple of hours.';

上記の例は、ウィキをロックし、編集画面に既定のメッセージを表示し、さらにウィキがロックされている理由の説明としてテキストを表示します。 Wikitext is allowed in this string and will be rendered when the read-only warning is shown which can be used to provide links or highlight upgrade notifications.

  警告: In contrast to its name, this settings does not make the database read only! Even if $wgReadOnly is set, extensions, API scripts and other cacheable events can write data nonetheless.


Since MediaWiki 1.27, running the upgrade script will not work if $wgReadOnly is set.

A simple solution is to set it to read only when not running from the command line, which will not affect the command line update script:

$wgReadOnly = ( PHP_SAPI === 'cli' ) ? false : 'This wiki is currently being upgraded to a newer software version. Please check back in a couple of hours.';


If sessions are not stored on an external caching system such as Redis or Memcached, users may get logged-out, and no further login attempts would succeed during the time the wiki is set read only, receiving a message similar to:

ログインのセッションに問題が発生しました。 セッション乗っ取りを防ぐため、操作を取り消しました。 フォームを再送信してください。


Caches that use the database cannot be written to during read only mode, which could prevent more than just editing (depending on the configuration, logging in or even viewing pages). This can be avoided by disabling cache, albeit at the cost of making your wiki slow. This can be accomplished with the following settings in LocalSettings.php:

$wgMessageCacheType = $wgMainCacheType = $wgParserCacheType = $wgSessionCacheType = CACHE_NONE;
$wgLocalisationCacheConf['storeClass'] = 'LCStoreNull';

If you want your wiki to be fast, while still not using the DB, you should consider using something like Memcached. 詳細は $wgMainCacheType および $wgLocalisationCacheConf を参照してください。 If you want to enable logins while the database is readonly, at least $wgSessionCacheType needs to be set to some real non-DB caching mechanism.


When in read-only mode, images which need to be transformed or scaled will be shown as an error message instead of as an image. To avoid this problem, put the following in the "LocalSettings.php" file:

$wgIgnoreImageErrors = true;