Skip to content

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
2 parents 1a4c67e + 96a5fb9 commit 3ab798f
Show file tree
Hide file tree
Showing 54 changed files with 528 additions and 190 deletions.
6 changes: 5 additions & 1 deletion library/Zend/Barcode/Renderer/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\Barcode\Renderer;

use Zend\Barcode\Exception\RendererCreationException;
use Zend\Stdlib\ErrorHandler;

/**
* Class for rendering the barcode as image
Expand Down Expand Up @@ -312,7 +313,10 @@ public function render()
header("Content-Type: image/" . $this->imageType);
$functionName = 'image' . $this->imageType;
$functionName($this->resource);
@imagedestroy($this->resource);

ErrorHandler::start(E_WARNING);
imagedestroy($this->resource);
ErrorHandler::stop();
}

/**
Expand Down
14 changes: 11 additions & 3 deletions library/Zend/Cache/Pattern/CaptureCache.php
Original file line number Diff line number Diff line change
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 library/Zend/Cache/Storage/Adapter/AdapterOptions.php
Original file line number Diff line number Diff line change
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 library/Zend/Cache/Storage/Adapter/Dba.php
Original file line number Diff line number Diff line change
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
5 changes: 3 additions & 2 deletions library/Zend/Cache/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
},
"target-dir": "Zend/Cache",
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"suggest": {
"zendframework/zend-log": "Zend\\Log component"
}
}
}
9 changes: 7 additions & 2 deletions library/Zend/Cloud/StorageService/Adapter/WindowsAzure.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Zend\Service\WindowsAzure\Storage\Blob\Blob;
use Zend\Service\WindowsAzure\Storage\Storage;
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\ErrorHandler;

/**
*
Expand Down Expand Up @@ -218,11 +219,15 @@ public function storeItem($destinationPath, $data, $options = null)
$temporaryFilePath
);
} catch(WindowsAzureException\ExceptionInterface $e) {
@unlink($temporaryFilePath);
ErrorHandler::start(E_WARNING);
unlink($temporaryFilePath);
ErrorHandler::stop();
throw new Exception\RuntimeException('Error on store: '.$e->getMessage(), $e->getCode(), $e);
}
if ($removeTemporaryFilePath) {
@unlink($temporaryFilePath);
ErrorHandler::start(E_WARNING);
unlink($temporaryFilePath);
ErrorHandler::stop();
}
}

Expand Down
5 changes: 3 additions & 2 deletions library/Zend/Cloud/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
},
"target-dir": "Zend/Cloud",
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"suggest": {
"zendframework/zend-service-amazon": "Zend\\Service\\Amazon component",
"zendframework/zend-service-rackspace": "Zend\\Service\\Rackspace component",
"zendframework/zend-service-gogrid": "Zend\\Service\\GoGrid component",
"zendframework/zend-service-windowsazure": "Zend\\Service\\WindowsAzure component"
}
}
}
8 changes: 5 additions & 3 deletions library/Zend/Feed/Reader/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,12 @@ public static function detectType($feed, $specOnly = false)
} elseif($feed instanceof DOMDocument) {
$dom = $feed;
} elseif(is_string($feed) && !empty($feed)) {
@ini_set('track_errors', 1);
ErrorHandler::start(E_NOTICE|E_WARNING);
ini_set('track_errors', 1);
$dom = new DOMDocument;
$status = @$dom->loadXML($feed);
@ini_restore('track_errors');
$status = $dom->loadXML($feed);
ini_restore('track_errors');
ErrorHandler::stop();
if (!$status) {
if (!isset($php_errormsg)) {
if (function_exists('xdebug_is_enabled')) {
Expand Down
5 changes: 3 additions & 2 deletions library/Zend/Feed/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
},
"target-dir": "Zend/Feed",
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
},
"suggest": {
"zendframework/zend-uri": "Zend\\Uri component",
"zendframework/zend-validator": "Zend\\Validator component"
}
}
}
17 changes: 11 additions & 6 deletions library/Zend/GData/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Zend\Http;
use Zend\Http\Header\Etag;
use Zend\Stdlib\ErrorHandler;
use Zend\Uri;

/**
Expand Down Expand Up @@ -784,10 +785,12 @@ public static function importString($string,
}

// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
ErrorHandler::start(E_WARNING);
ini_set('track_errors', 1);
$doc = new \DOMDocument();
$success = @$doc->loadXML($string);
@ini_restore('track_errors');
$success = $doc->loadXML($string);
ini_restore('track_errors');
ErrorHandler::stop();

if (!$success) {
throw new App\Exception(
Expand Down Expand Up @@ -815,9 +818,11 @@ public static function importString($string,
public static function importFile($filename,
$className='Zend\GData\App\Feed', $useIncludePath = false)
{
@ini_set('track_errors', 1);
$feed = @file_get_contents($filename, $useIncludePath);
@ini_restore('track_errors');
ErrorHandler::start(E_WARNING);
ini_set('track_errors', 1);
$feed = file_get_contents($filename, $useIncludePath);
ini_restore('track_errors');
ErrorHandler::stop();
if ($feed === false) {
throw new App\Exception(
"File could not be loaded: $php_errormsg");
Expand Down
10 changes: 7 additions & 3 deletions library/Zend/GData/App/AbstractBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Zend\GData\App;

use Zend\Stdlib\ErrorHandler;

/**
* Abstract class for all XML elements
*
Expand Down Expand Up @@ -281,10 +283,12 @@ public function transferFromXML($xml)
{
if ($xml) {
// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
ErrorHandler::start(E_WARNING);
ini_set('track_errors', 1);
$doc = new \DOMDocument();
$success = @$doc->loadXML($xml);
@ini_restore('track_errors');
$success = $doc->loadXML($xml);
ini_restore('track_errors');
ErrorHandler::stop();
if (!$success) {
throw new Exception("DOMDocument cannot parse XML: $php_errormsg");
}
Expand Down
9 changes: 6 additions & 3 deletions library/Zend/GData/GApps/ServiceException.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\GData\GApps;

use Zend\GData\App;
use Zend\Stdlib\ErrorHandler;

/**
* Gdata GApps Exception class. This is thrown when an
Expand Down Expand Up @@ -142,10 +143,12 @@ public function importFromString($string)
// track_errors is temporarily enabled so that if an error
// occurs while parsing the XML we can append it to an
// exception by referencing $php_errormsg
@ini_set('track_errors', 1);
ErrorHandler::start(E_WARNING);
ini_set('track_errors', 1);
$doc = new \DOMDocument();
$success = @$doc->loadXML($string);
@ini_restore('track_errors');
$success = $doc->loadXML($string);
ini_restore('track_errors');
ErrorHandler::stop();

if (!$success) {
// $php_errormsg is automatically generated by PHP if
Expand Down
9 changes: 6 additions & 3 deletions library/Zend/GData/YouTube.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Zend\GData;

use Zend\Http;
use Zend\Stdlib\ErrorHandler;

/**
* Service class for interacting with the YouTube Data API.
Expand Down Expand Up @@ -582,10 +583,12 @@ public function getUserProfile($user = null, $location = null)
public static function parseFormUploadTokenResponse($response)
{
// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
ErrorHandler::start(E_WARNING);
ini_set('track_errors', 1);
$doc = new \DOMDocument();
$success = @$doc->loadXML($response);
@ini_restore('track_errors');
$success = $doc->loadXML($response);
ini_restore('track_errors');
ErrorHandler::stop();

if (!$success) {
throw new App\Exception(
Expand Down
5 changes: 3 additions & 2 deletions library/Zend/GData/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
},
"target-dir": "Zend/GData",
"require": {
"php": ">=5.3.3"
"php": ">=5.3.3",
"zendframework/zend-stdlib": "self.version"
}
}
}
14 changes: 7 additions & 7 deletions library/Zend/Http/Client/Adapter/Socket.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ public function read()
$response = '';
$gotStatus = false;

while (($line = @fgets($this->socket)) !== false) {
while (($line = fgets($this->socket)) !== false) {
$gotStatus = $gotStatus || (strpos($line, 'HTTP') !== false);
if ($gotStatus) {
$response .= $line;
Expand Down Expand Up @@ -335,7 +335,7 @@ public function read()
if (strtolower($transfer_encoding->getFieldValue()) == 'chunked') {

do {
$line = @fgets($this->socket);
$line = fgets($this->socket);
$this->_checkSocketReadTimeout();

$chunk = $line;
Expand Down Expand Up @@ -364,7 +364,7 @@ public function read()
break;
}
} else {
$line = @fread($this->socket, $read_to - $current_pos);
$line = fread($this->socket, $read_to - $current_pos);
if ($line === false || strlen($line) === 0) {
$this->_checkSocketReadTimeout();
break;
Expand Down Expand Up @@ -409,12 +409,12 @@ public function read()
$current_pos = ftell($this->socket)) {

if ($this->out_stream) {
if (@stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) {
if (stream_copy_to_stream($this->socket, $this->out_stream, $read_to - $current_pos) == 0) {
$this->_checkSocketReadTimeout();
break;
}
} else {
$chunk = @fread($this->socket, $read_to - $current_pos);
$chunk = fread($this->socket, $read_to - $current_pos);
if ($chunk === false || strlen($chunk) === 0) {
$this->_checkSocketReadTimeout();
break;
Expand All @@ -432,12 +432,12 @@ public function read()

do {
if ($this->out_stream) {
if (@stream_copy_to_stream($this->socket, $this->out_stream) == 0) {
if (stream_copy_to_stream($this->socket, $this->out_stream) == 0) {
$this->_checkSocketReadTimeout();
break;
}
} else {
$buff = @fread($this->socket, 8192);
$buff = fread($this->socket, 8192);
if ($buff === false || strlen($buff) === 0) {
$this->_checkSocketReadTimeout();
break;
Expand Down
5 changes: 4 additions & 1 deletion library/Zend/Http/Response/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Zend\Http\Exception;
use Zend\Http\Response;
use Zend\Stdlib\ErrorHandler;

/**
* Zend_Http_Response represents an HTTP 1.0 / 1.1 response message. It
Expand Down Expand Up @@ -271,7 +272,9 @@ public function __destruct()
$this->stream = null; //Could be listened by others
}
if ($this->cleanup) {
@unlink($this->stream_name);
ErrorHandler::start(E_WARNING);
unlink($this->stream_name);
ErrorHandler::stop();
}
}
}
7 changes: 6 additions & 1 deletion library/Zend/InfoCard/XML/Security.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace Zend\InfoCard\XML;

use Zend\Stdlib\ErrorHandler;

/**
* @category Zend
* @package Zend_InfoCard
Expand Down Expand Up @@ -187,7 +189,10 @@ public static function validateXMLSignature($strXMLInput)

$canonical_signedinfo = $transformer->applyTransforms($sxe->Signature->SignedInfo->asXML());

if(@openssl_verify($canonical_signedinfo, $signatureValue, $public_key)) {
ErrorHandler::start(E_WARNING);
$result = openssl_verify($canonical_signedinfo, $signatureValue, $public_key);
ErrorHandler::stop();
if ($result) {
return (string)$sxe->Signature->SignedInfo->Reference['URI'];
}

Expand Down
Loading

0 comments on commit 3ab798f

Please sign in to comment.