cellog Sat Jun 16 18:41:59 2007 UTC
Added files:
/pear-core/tests/PEAR_Registry/api1_1 test_hasWriteAccess.phpt
Modified files:
/pear-core/PEAR Registry.php
Log:
fix Bug #11317 Registry::hasWriteAccess loops endless
http://cvs.php.net/viewvc.cgi/pear-core/PEAR/Registry.php?r1=1.165&r2=1.166&diff_format=u
Index: pear-core/PEAR/Registry.php
diff -u pear-core/PEAR/Registry.php:1.165 pear-core/PEAR/Registry.php:1.166
--- pear-core/PEAR/Registry.php:1.165 Sun Jun 10 04:16:51 2007
+++ pear-core/PEAR/Registry.php Sat Jun 16 18:41:59 2007
@@ -17,7 +17,7 @@
* @author Greg Beaver <cellog@xxxxxxx>
* @copyright 1997-2006 The PHP Group
* @license http://www.php.net/license/3_0.txt PHP License 3.0
- * @version CVS: $Id: Registry.php,v 1.165 2007/06/10 04:16:51 cellog Exp $
+ * @version CVS: $Id: Registry.php,v 1.166 2007/06/16 18:41:59 cellog Exp $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
@@ -157,6 +157,7 @@
if (!file_exists($this->install_dir)) {
$dir = $this->install_dir;
while ($dir && $dir != '.') {
+ $olddir = $dir;
$dir = dirname($dir); // cd ..
if ($dir != '.' && file_exists($dir)) {
if (is_writeable($dir)) {
@@ -165,6 +166,9 @@
return false;
}
}
+ if ($dir == $olddir) { // this can happen in safe mode
+ return @is_writable($dir);
+ }
}
return false;
}
http://cvs.php.net/viewvc.cgi/pear-core/tests/PEAR_Registry/api1_1/test_hasWriteAccess.phpt?view=markup&rev=1.1
Index: pear-core/tests/PEAR_Registry/api1_1/test_hasWriteAccess.phpt
+++ pear-core/tests/PEAR_Registry/api1_1/test_hasWriteAccess.phpt
--TEST--
PEAR_Registry->hasWriteAccess() (API v1.1)
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
require_once 'PEAR/Registry.php';
$pv = phpversion() . '';
$av = $pv{0} == '4' ? 'apiversion' : 'apiVersion';
if (!in_array($av, get_class_methods('PEAR_Registry'))) {
echo 'skip';
}
if (PEAR_Registry::apiVersion() != '1.1') {
echo 'skip';
}
?>
--INI--
safe_mode=1
safe_mode_include_dir=/
safe_mode_allowed_env_vars=HOME,PHP_
--FILE--
<?php
error_reporting(E_ALL);
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'setup.php.inc';
if (OS_WINDOWS) {
$reg->install_dir = '/';
} else {
$reg->install_dir = '\\';
}
$phpunit->assertFalse($reg->hasWriteAccess(), 1);
if (OS_WINDOWS) {
$reg->install_dir = '\\';
} else {
$reg->install_dir = '/';
}
$phpunit->assertFalse($reg->hasWriteAccess(), 2);
if (OS_WINDOWS) {
$reg->install_dir = '\\$*#';
} else {
$reg->install_dir = '/$*#';
}
$phpunit->assertFalse($reg->hasWriteAccess(), 3);
if (OS_WINDOWS) {
$reg->install_dir = '\\windows';
} else {
$reg->install_dir = '/usr/local/lib/foo/bar';
}
$phpunit->assertFalse($reg->hasWriteAccess(), 4);
?>
===DONE===
--CLEAN--
<?php
require_once dirname(__FILE__) . '/teardown.php.inc';
?>
--EXPECT--
===DONE===
--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|