Permalink
Browse files

BUGFIX Fixed unlink of mysite/_config.php and truncate it instead - w…

…hen re-creating the file it may not get write permissions on Windows (from r98783)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/phpinstaller/trunk@112098 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 3c8aba8 commit 7cec02c3f3d001b4f73162eb85a47f345a2ad43b sminnee committed Oct 13, 2010
Showing with 13 additions and 10 deletions.
  1. +13 −10 install.php
View
@@ -928,14 +928,17 @@ function install($config) {
}
if(file_exists('mysite/_config.php')) {
- unlink('mysite/_config.php');
+ // Truncate the contents of _config instead of deleting it - we can't re-create it because Windows handles permissions slightly
+ // differently to UNIX based filesystems - it takes the permissions from the parent directory instead of retaining them
+ $fh = fopen('mysite/_config.php', 'wb');
+ fclose($fh);
}
$theme = isset($_POST['template']) ? $_POST['template'] : 'blackcandy';
// Write the config file
global $usingEnv;
if($usingEnv) {
- $this->statusMessage("Creating 'mysite/_config.php' for use with _ss_environment.php...");
- $this->createFile("mysite/_config.php", <<<PHP
+ $this->statusMessage("Setting up 'mysite/_config.php' for use with _ss_environment.php...");
+ $this->writeToFile("mysite/_config.php", <<<PHP
<?php
global \$project;
@@ -960,12 +963,12 @@ function install($config) {
} else {
- $this->statusMessage("Creating 'mysite/_config.php'...");
+ $this->statusMessage("Setting up 'mysite/_config.php'...");
$devServers = $this->var_export_array_nokeys(explode("\n", $_POST['devsites']));
$escapedPassword = addslashes($config['db']['password']);
- $this->createFile("mysite/_config.php", <<<PHP
+ $this->writeToFile("mysite/_config.php", <<<PHP
<?php
global \$project;
@@ -997,7 +1000,7 @@ function install($config) {
);
}
- $this->statusMessage("Creating '.htaccess' file...");
+ $this->statusMessage("Setting up '.htaccess' file...");
$this->createHtaccess();
@@ -1089,9 +1092,9 @@ function copyFolder($oldName, $newName) {
}
}
- function createFile($filename, $content) {
+ function writeToFile($filename, $content) {
$base = $this->getBaseDir();
- $this->statusMessage("Creating $base$filename");
+ $this->statusMessage("Setting up $base$filename");
if((@$fh = fopen($base . $filename, 'wb')) && fwrite($fh, $content) && fclose($fh)) {
return true;
@@ -1140,7 +1143,7 @@ function createHtaccess() {
}
}
- $this->createFile('.htaccess', $start . $rewrite . $end);
+ $this->writeToFile('.htaccess', $start . $rewrite . $end);
}
function restoreHtaccess() {
@@ -1160,7 +1163,7 @@ function restoreHtaccess() {
}
}
- $this->createFile('.htaccess', $start . $end);
+ $this->writeToFile('.htaccess', $start . $end);
}
function checkModRewrite() {

0 comments on commit 7cec02c

Please sign in to comment.