* @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: REST.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
*/
* @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
*/
var $config;
var $_options;
- function PEAR_REST(&$config, $options = array())
+ function __construct(&$config, $options = array())
{
$this->config = &$config;
$this->_options = $options;
}
if (isset($headers['content-type'])) {
- switch ($headers['content-type']) {
+ $content_type = explode(";", $headers['content-type']);
+ $content_type = $content_type[0];
+ switch ($content_type) {
case 'text/xml' :
case 'application/xml' :
case 'text/plain' :
- if ($headers['content-type'] === 'text/plain') {
+ if ($content_type === 'text/plain') {
$check = substr($content, 0, 5);
if ($check !== '<?xml') {
break;
}
}
+ if (!is_writeable($cache_dir)) {
+ // If writing to the cache dir is not going to work, silently do nothing.
+ // An ugly hack, but retains compat with PEAR 1.9.1 where many commands
+ // work fine as non-root user (w/out write access to default cache dir).
+ return true;
+ }
+
if ($cacheid === null && $nochange) {
$cacheid = unserialize(implode('', file($cacheidfile)));
}
return PEAR::raiseError("Could not write $file.");
}
} else { // update file
- $cachefile_lstat = lstat($file);
- $cachefile_fp = @fopen($file, 'wb');
+ $cachefile_fp = @fopen($file, 'r+b'); // do not truncate file
if (!$cachefile_fp) {
return PEAR::raiseError("Could not open $file for writing.");
}
- $cachefile_fstat = fstat($cachefile_fp);
- if (
- $cachefile_lstat['mode'] == $cachefile_fstat['mode'] &&
- $cachefile_lstat['ino'] == $cachefile_fstat['ino'] &&
- $cachefile_lstat['dev'] == $cachefile_fstat['dev'] &&
- $cachefile_fstat['nlink'] === 1
- ) {
+ if (OS_WINDOWS) {
+ $not_symlink = !is_link($file); // see bug #18834
+ } else {
+ $cachefile_lstat = lstat($file);
+ $cachefile_fstat = fstat($cachefile_fp);
+ $not_symlink = $cachefile_lstat['mode'] == $cachefile_fstat['mode']
+ && $cachefile_lstat['ino'] == $cachefile_fstat['ino']
+ && $cachefile_lstat['dev'] == $cachefile_fstat['dev']
+ && $cachefile_fstat['nlink'] === 1;
+ }
+
+ if ($not_symlink) {
+ ftruncate($cachefile_fp, 0); // NOW truncate
if (fwrite($cachefile_fp, $contents, $len) < $len) {
fclose($cachefile_fp);
return PEAR::raiseError("Could not write $file.");
}
$request .= $ifmodifiedsince .
- "User-Agent: PEAR/1.9.4/PHP/" . PHP_VERSION . "\r\n";
+ "User-Agent: PEAR/1.10.1/PHP/" . PHP_VERSION . "\r\n";
$username = $this->config->get('username', null, $channel);
$password = $this->config->get('password', null, $channel);
return $data;
}
-}
\ No newline at end of file
+}