From: Tim Düsterhus Date: Mon, 8 Sep 2014 15:54:47 +0000 (+0200) Subject: Write options.inc.php atomically X-Git-Tag: 2.1.0_Alpha_1~344^2~32^2~1^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=b4db90186303bce029f3d65331a82e6292ad418e;p=GitHub%2FWoltLab%2FWCF.git Write options.inc.php atomically --- diff --git a/wcfsetup/install/files/lib/data/option/OptionEditor.class.php b/wcfsetup/install/files/lib/data/option/OptionEditor.class.php index 9e4a78cf2e..aad1a9ae91 100644 --- a/wcfsetup/install/files/lib/data/option/OptionEditor.class.php +++ b/wcfsetup/install/files/lib/data/option/OptionEditor.class.php @@ -4,7 +4,7 @@ use wcf\data\DatabaseObjectEditor; use wcf\data\IEditableCachedObject; use wcf\system\cache\builder\OptionCacheBuilder; use wcf\system\cache\CacheHandler; -use wcf\system\io\File; +use wcf\system\io\AtomicWriter; use wcf\system\WCF; use wcf\util\FileUtil; @@ -118,29 +118,23 @@ class OptionEditor extends DatabaseObjectEditor implements IEditableCachedObject * Rebuilds the option file. */ public static function rebuild() { - $buffer = ''; + $writer = new AtomicWriter(WCF_DIR.'options.inc.php'); // file header - $buffer .= "write(" $option) { - $buffer .= "if (!defined('".$optionName."')) define('".$optionName."', ".(($option->optionType == 'boolean' || $option->optionType == 'integer') ? intval($option->optionValue) : "'".addcslashes($option->optionValue, "'\\")."'").");\n"; + $writer->write("if (!defined('".$optionName."')) define('".$optionName."', ".(($option->optionType == 'boolean' || $option->optionType == 'integer') ? intval($option->optionValue) : "'".addcslashes($option->optionValue, "'\\")."'").");\n"); } unset($options); // file footer - $buffer .= "\n"; + $writer->write("\n"); + $writer->flush(); + $writer->close(); - // open file - $file = new File(WCF_DIR.'options.inc.php'); - - // write buffer - $file->write($buffer); - - // close file - $file->close(); FileUtil::makeWritable(WCF_DIR.'options.inc.php'); } }