Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed issue #6341: Installation fails if ./tmp/runtime is not writable
  • Loading branch information
c-schmitz committed Jul 20, 2012
1 parent 73545ac commit b5fdd3a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
28 changes: 22 additions & 6 deletions application/controllers/InstallerController.php
Expand Up @@ -703,6 +703,22 @@ function check_HTML_image($result)
return sprintf('<img src="%s/installer/images/tick-%s.png" alt="Found" />', Yii::app()->baseUrl, $label[$result]);
}


function is_writable_recursive($dir)
{
$folder = opendir($dir);
while($file = readdir( $folder ))
if($file != '.' && $file != '..' &&
( !is_writable( $dir."/".$file ) ||
( is_dir( $dir."/".$file ) && !is_writable_recursive( $dir."/".$file ) ) ))
{
closedir($folder);
return false;
}
closedir($folder);
return true;
}

/**
* check for a specific PHPFunction, return HTML image
*
Expand All @@ -727,7 +743,7 @@ function check_PHPFunction($function, &$image)
* @param string $keyError key for error data
* @return bool result of check (that it is writeable which implies existance)
*/
function check_PathWriteable($path, $type, &$data, $base, $keyError)
function check_PathWriteable($path, $type, &$data, $base, $keyError, $bRecursive=false)
{
$result = false;
$data[$base.'Present'] = 'Not Found';
Expand All @@ -745,7 +761,7 @@ function check_PathWriteable($path, $type, &$data, $base, $keyError)
if ($exists)
{
$data[$base.'Present'] = 'Found';
if (is_writable($path))
if ((!$bRecursive && is_writable($path)) || ($bRecursive && is_writable_recursive($path)))
{
$data[$base.'Writable'] = 'Writable';
$result = true;
Expand Down Expand Up @@ -783,9 +799,9 @@ function check_FileWriteable($file, &$data, $base, $keyError)
* @param string $keyError key for error data
* @return bool result of check (that it is writeable which implies existance)
*/
function check_DirectoryWriteable($directory, &$data, $base, $keyError)
function check_DirectoryWriteable($directory, &$data, $base, $keyError, $bRecursive=false)
{
return check_PathWriteable($directory, 2, $data, $base, $keyError);
return check_PathWriteable($directory, 2, $data, $base, $keyError, $bRecursive);
}

// version check
Expand All @@ -803,11 +819,11 @@ function check_DirectoryWriteable($directory, &$data, $base, $keyError)
$bProceed = false;

// templates directory check
if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/templates/', $data, 'templatedir', 'tperror') )
if (!check_DirectoryWriteable(Yii::app()->getConfig('tempdir').'/', $data, 'tmpdir', 'tperror',true) )
$bProceed = false;

//upload directory check
if (!check_DirectoryWriteable(Yii::app()->getConfig('rootdir').'/upload/', $data, 'uploaddir', 'uerror') )
if (!check_DirectoryWriteable(Yii::app()->getConfig('uploaddir').'/', $data, 'uploaddir', 'uerror',true) )
$bProceed = false;

// ** optional settings check **
Expand Down
4 changes: 2 additions & 2 deletions application/views/installer/precheck_view.php
Expand Up @@ -83,9 +83,9 @@ function dirReport($dir, $write, $clang)
<td align="center" style="width: 225px;"><?php echo dirReport($uploaddirPresent,$uploaddirWritable,$clang); ?></td>
</tr>
<tr>
<td style="width: 209px;">/templates <?php $clang->eT("directory"); ?></td>
<td style="width: 209px;">/tmp <?php $clang->eT("directory"); ?></td>
<td align="center" style="width: 225px;"><?php $clang->eT("Found & writable"); ?></td>
<td align="center" style="width: 225px;"><?php echo dirReport($templatedirPresent,$templatedirWritable,$clang); ?></td>
<td align="center" style="width: 225px;"><?php echo dirReport($tmpdirPresent,$tmpdirWritable,$clang); ?></td>
</tr>

</table>
Expand Down

0 comments on commit b5fdd3a

Please sign in to comment.