aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <gohr@cosmocode.de>2019-10-15 16:41:57 +0200
committerAndreas Gohr <gohr@cosmocode.de>2019-10-15 16:41:57 +0200
commit49bcbaeeb263008d6eb9a6e290600888a57a142d (patch)
treef17947d36e8a41e058838d734971f05465506cc2
parentbba3d82504d773deca05e47caebbdfe3a167590a (diff)
downloaddokuwiki-49bcbaeeb263008d6eb9a6e290600888a57a142d.tar.gz
dokuwiki-49bcbaeeb263008d6eb9a6e290600888a57a142d.zip
Do config backups with .php extension fixes #2446
-rw-r--r--lib/plugins/config/_test/WriterTest.php8
-rw-r--r--lib/plugins/config/core/Writer.php6
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/plugins/config/_test/WriterTest.php b/lib/plugins/config/_test/WriterTest.php
index 62e4a56d5..739f68be4 100644
--- a/lib/plugins/config/_test/WriterTest.php
+++ b/lib/plugins/config/_test/WriterTest.php
@@ -25,7 +25,7 @@ class WriterTest extends \DokuWikiTest {
// before running, no backup should exist
$this->assertFileExists($config);
- $this->assertFileNotExists("$config.bak");
+ $this->assertFileNotExists("$config.bak.php");
$old = filesize($config);
/** @noinspection PhpUnhandledExceptionInspection */
@@ -33,8 +33,8 @@ class WriterTest extends \DokuWikiTest {
// after running, both should exist
$this->assertFileExists($config);
- $this->assertFileExists("$config.bak");
- $this->assertEquals($old, filesize("$config.bak"), 'backup should have size of old file');
+ $this->assertFileExists("$config.bak.php");
+ $this->assertEquals($old, filesize("$config.bak.php"), 'backup should have size of old file');
// check contents
$conf = [];
@@ -45,7 +45,7 @@ class WriterTest extends \DokuWikiTest {
/** @noinspection PhpUnhandledExceptionInspection */
$writer->save($settings);
- $this->assertEquals(filesize($config), filesize("$config.bak"));
+ $this->assertEquals(filesize($config), filesize("$config.bak.php"));
}
public function testTouch() {
diff --git a/lib/plugins/config/core/Writer.php b/lib/plugins/config/core/Writer.php
index 6dee223ac..56de621d9 100644
--- a/lib/plugins/config/core/Writer.php
+++ b/lib/plugins/config/core/Writer.php
@@ -33,12 +33,12 @@ class Writer {
// backup current file (remove any existing backup)
if(file_exists($this->savefile)) {
- if(file_exists($this->savefile . '.bak')) @unlink($this->savefile . '.bak');
- if(!io_rename($this->savefile, $this->savefile . '.bak')) throw new \Exception('no backup');
+ if(file_exists($this->savefile . '.bak.php')) @unlink($this->savefile . '.bak.php');
+ if(!io_rename($this->savefile, $this->savefile . '.bak.php')) throw new \Exception('no backup');
}
if(!$fh = @fopen($this->savefile, 'wb')) {
- io_rename($this->savefile . '.bak', $this->savefile); // problem opening, restore the backup
+ io_rename($this->savefile . '.bak.php', $this->savefile); // problem opening, restore the backup
throw new \Exception('no save');
}