* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: Registry.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 0.1
*/
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version Release: 1.9.4
+ * @version Release: 1.10.1
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
*/
*
* @access public
*/
- function PEAR_Registry($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
- $pecl_channel = false)
+ function __construct($pear_install_dir = PEAR_INSTALL_DIR, $pear_channel = false,
+ $pecl_channel = false, $pear_metadata_dir = '')
{
- parent::PEAR();
- $this->setInstallDir($pear_install_dir);
+ parent::__construct();
+ $this->setInstallDir($pear_install_dir, $pear_metadata_dir);
$this->_pearChannel = $pear_channel;
$this->_peclChannel = $pecl_channel;
$this->_config = false;
}
- function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR)
+ function setInstallDir($pear_install_dir = PEAR_INSTALL_DIR, $pear_metadata_dir = '')
{
$ds = DIRECTORY_SEPARATOR;
$this->install_dir = $pear_install_dir;
- $this->channelsdir = $pear_install_dir.$ds.'.channels';
- $this->statedir = $pear_install_dir.$ds.'.registry';
- $this->filemap = $pear_install_dir.$ds.'.filemap';
- $this->lockfile = $pear_install_dir.$ds.'.lock';
+ if (!$pear_metadata_dir) {
+ $pear_metadata_dir = $pear_install_dir;
+ }
+ $this->channelsdir = $pear_metadata_dir.$ds.'.channels';
+ $this->statedir = $pear_metadata_dir.$ds.'.registry';
+ $this->filemap = $pear_metadata_dir.$ds.'.filemap';
+ $this->lockfile = $pear_metadata_dir.$ds.'.lock';
}
function hasWriteAccess()
{
$this->_config = &$config;
if ($resetInstallDir) {
- $this->setInstallDir($config->get('php_dir'));
+ $this->setInstallDir($config->get('php_dir'), $config->get('metadata_dir'));
}
}
$initializing = true;
if (!$this->_config) { // never used?
$file = OS_WINDOWS ? 'pear.ini' : '.pearrc';
- $this->_config = &new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR .
+ $this->_config = new PEAR_Config($this->statedir . DIRECTORY_SEPARATOR .
$file);
$this->_config->setRegistry($this);
$this->_config->set('php_dir', $this->install_dir);
$this->_dependencyDB = &PEAR_DependencyDB::singleton($this->_config);
if (PEAR::isError($this->_dependencyDB)) {
// attempt to recover by removing the dep db
- if (file_exists($this->_config->get('php_dir', null, 'pear.php.net') .
+ if (file_exists($this->_config->get('metadata_dir', null, 'pear.php.net') .
DIRECTORY_SEPARATOR . '.depdb')) {
- @unlink($this->_config->get('php_dir', null, 'pear.php.net') .
+ @unlink($this->_config->get('metadata_dir', null, 'pear.php.net') .
DIRECTORY_SEPARATOR . '.depdb');
}
}
clearstatcache();
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
$fsize = filesize($this->filemap);
fclose($fp);
$data = file_get_contents($this->filemap);
- set_magic_quotes_runtime($rt);
$tmp = unserialize($data);
if (!$tmp && $fsize > 7) {
return $this->raiseError('PEAR_Registry: invalid filemap data', PEAR_REGISTRY_ERROR_FORMAT, null, null, $data);
return null;
}
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
clearstatcache();
$this->_closePackageFile($fp);
$data = file_get_contents($this->_packageFileName($package, $channel));
- set_magic_quotes_runtime($rt);
$data = unserialize($data);
if ($key === null) {
return $data;
return null;
}
- $rt = get_magic_quotes_runtime();
- set_magic_quotes_runtime(0);
clearstatcache();
$this->_closeChannelFile($fp);
$data = file_get_contents($this->_channelFileName($channel));
- set_magic_quotes_runtime($rt);
$data = unserialize($data);
return $data;
}
$a = $this->_config;
if (!$a) {
- $this->_config = &new PEAR_Config;
+ $this->_config = new PEAR_Config;
$this->_config->set('php_dir', $this->statedir);
}
require_once 'PEAR/PackageFile.php';
}
- $pkg = &new PEAR_PackageFile($this->_config);
+ $pkg = new PEAR_PackageFile($this->_config);
$pf = &$pkg->fromArray($info);
return $pf;
}
* @param bool whether to strictly return raw channels (no aliases)
* @return PEAR_ChannelFile|PEAR_Error
*/
- function &getChannel($channel, $noaliases = false)
+ function getChannel($channel, $noaliases = false)
{
if (PEAR::isError($e = $this->_lock(LOCK_SH))) {
return $e;
}
- $ret = &$this->_getChannel($channel, $noaliases);
+ $ret = $this->_getChannel($channel, $noaliases);
$this->_unlock();
if (!$ret) {
return PEAR::raiseError('Unknown channel: ' . $channel);
}
return $ret;
}
-}
\ No newline at end of file
+}