if (!$fp) {
return $this->raiseError($php_errormsg);
}
- $contents = fread($fp, filesize($file));
+ $size = filesize($file);
+ $contents = fread($fp, $size);
$data = unserialize($contents);
- if ($data === false) {
+ if ($data === false && $size > 1) {
return $this->raiseError("PEAR_Config::readConfigFile: bad data");
}
$this->configuration = $data;
function writeConfigFile($file = null, $what_keys = 'userdefined')
{
- print "storing $what_keys keys\n";
if ($what_keys == 'both') {
$this->writeConfigFile($file, 'userdefined');
$this->writeConfigFile($file, 'default');
+ return;
}
if ($file === null) {
if ($what_keys == 'default') {
}
$fp = @fopen($file, "w");
if (!$fp) {
- return $this->raiseError("PEAR_Config::writeConfigFile fopen failed");
+ return $this->raiseError("PEAR_Config::writeConfigFile fopen('$file','w') failed");
}
if (!@fwrite($fp, serialize($data))) {
return $this->raiseError("PEAR_Config::writeConfigFile serialize failed");
error_reporting(E_ALL ^ E_NOTICE);
+PEAR::setErrorHandling(PEAR_ERROR_PRINT, "pear: %s\n");
+
// {{{ config file and option parsing
$options = Console_Getopt::getopt($argv, "c:C:d:D:h?sS");
}
}
+if ($store_default_config) {
+ if (@is_writeable($pear_default_config)) {
+ $config->writeConfigFile($pear_default_config, 'default');
+ } else {
+ die("You don't have write access to $pear_default_config, exiting!\n");
+ }
+}
+
+if ($store_user_config) {
+ $config->writeConfigFile($pear_user_config, 'userdefined');
+}
+
$fallback_config = array(
'php_dir' => PEAR_INSTALL_DIR,
'ext_dir' => PEAR_EXTENSION_DIR,
// }}}
-PEAR::setErrorHandling(PEAR_ERROR_PRINT, "pear: %s\n");
-
$command = $options[1][1];
switch ($command) {
// {{{ install