diff options
| author | Greg Beaver <cellog@php.net> | 2006-05-22 10:19:34 +0000 |
|---|---|---|
| committer | Greg Beaver <cellog@php.net> | 2006-05-22 10:19:34 +0000 |
| commit | 5fb5cfdbca3a21414050638313549789c42bdac2 (patch) | |
| tree | 32f42818a9a50655e9bda01cdaf1975fc854979d /pear/PEAR/REST.php | |
| parent | 4d0daac7384de9be60d7976523083e6a9fc13ab9 (diff) | |
| download | php-git-5fb5cfdbca3a21414050638313549789c42bdac2.tar.gz | |
sync to PEAR 1.4.9
add PEAR 1.4.9 to installed tarballs
Diffstat (limited to 'pear/PEAR/REST.php')
| -rw-r--r-- | pear/PEAR/REST.php | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/pear/PEAR/REST.php b/pear/PEAR/REST.php index 99a739de41..89b783a6d8 100644 --- a/pear/PEAR/REST.php +++ b/pear/PEAR/REST.php @@ -106,9 +106,15 @@ class PEAR_REST } return $ret; } - $headers = $file[2]; - $lastmodified = $file[1]; - $content = $file[0]; + if (is_array($file)) { + $headers = $file[2]; + $lastmodified = $file[1]; + $content = $file[0]; + } else { + $content = $file; + $lastmodified = false; + $headers = array(); + } if ($forcestring) { $this->saveCache($url, $content, $lastmodified, false, $cacheId); return $content; @@ -133,7 +139,7 @@ class PEAR_REST } else { // assume XML $parser = new PEAR_XMLParser; - $parser->parse($file); + $parser->parse($content); $content = $parser->getData(); } $this->saveCache($url, $content, $lastmodified, false, $cacheId); @@ -198,10 +204,21 @@ class PEAR_REST if ($cacheid === null && $nochange) { $cacheid = unserialize(implode('', file($cacheidfile))); } + $fp = @fopen($cacheidfile, 'wb'); if (!$fp) { - return false; + $cache_dir = $this->config->get('cache_dir'); + if (!is_dir($cache_dir)) { + System::mkdir(array('-p', $cache_dir)); + $fp = @fopen($cacheidfile, 'wb'); + if (!$fp) { + return false; + } + } else { + return false; + } } + if ($nochange) { fwrite($fp, serialize(array( 'age' => time(), @@ -347,7 +364,7 @@ class PEAR_REST return false; } if ($matches[1] != 200) { - return PEAR::raiseError("File http://$host:$port$path not valid (received: $line)"); + return PEAR::raiseError("File http://$host:$port$path not valid (received: $line)", (int) $matches[1]); } } } |
