Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'weierophinney/feature/error-suppression…
Browse files Browse the repository at this point in the history
…-removal'
  • Loading branch information
akrabat committed Jul 13, 2012
5 parents 9852497 + 016f50c + 073b126 + bd99c5c + 6a346bb commit 1582c31
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
14 changes: 11 additions & 3 deletions src/Pattern/CaptureCache.php
Expand Up @@ -11,6 +11,7 @@
namespace Zend\Cache\Pattern;

use Zend\Cache\Exception;
use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
Expand Down Expand Up @@ -80,7 +81,10 @@ public function get($pageId = null, array $options = array())
. DIRECTORY_SEPARATOR . $this->pageId2Filename($pageId);

if (file_exists($file)) {
if (($content = @file_get_contents($file)) === false) {
ErrorHandler::start(E_WARNING);
$content = file_get_contents($file);
ErrorHandler::stop();
if ($content === false) {
$lastErr = error_get_last();
throw new Exception\RuntimeException("Failed to read cached pageId '{$pageId}': {$lastErr['message']}");
}
Expand Down Expand Up @@ -268,10 +272,14 @@ protected function putFileContent($file, $data)
$flags = $flags | LOCK_EX;
}

$put = @file_put_contents($file, $data, $flags);
ErrorHandler::start(E_WARNING);
$put = file_put_contents($file, $data, $flags);
ErrorHandler::stop();
if ( $put < strlen((binary)$data) ) {
$lastErr = error_get_last();
@unlink($file); // remove old or incomplete written file
ErrorHandler::start(E_WARNING);
unlink($file); // remove old or incomplete written file
ErrorHandler::stop();
throw new Exception\RuntimeException($lastErr['message']);
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/Storage/Adapter/AdapterOptions.php
Expand Up @@ -16,6 +16,7 @@
use Zend\Cache\Storage\StorageInterface;
use Zend\EventManager\EventsCapableInterface;
use Zend\Stdlib\AbstractOptions;
use Zend\Stdlib\ErrorHandler;

/**
* Unless otherwise marked, all options in this class affect all adapters.
Expand Down Expand Up @@ -112,7 +113,10 @@ public function setKeyPattern($keyPattern)
if ($this->keyPattern !== $keyPattern) {
// validate pattern
if ($keyPattern !== '') {
if (@preg_match($keyPattern, '') === false) {
ErrorHandler::start(E_WARNING);
$result = preg_match($keyPattern, '');
ErrorHandler::stop();
if ($result === false) {
$err = error_get_last();
throw new Exception\InvalidArgumentException("Invalid pattern '{$keyPattern}': {$err['message']}");
}
Expand Down
4 changes: 3 additions & 1 deletion src/Storage/Adapter/Dba.php
Expand Up @@ -516,7 +516,9 @@ protected function _open()
protected function _close()
{
if ($this->handle) {
@dba_close($this->handle);
ErrorHandler::start(E_WARNING);
dba_close($this->handle);
ErrorHandler::stop();
$this->handle = null;
}
}
Expand Down

0 comments on commit 1582c31

Please sign in to comment.