Skip to content
Browse files

removed set_error_handler from MemcachedStorage & SendmailMailer

  • Loading branch information...
1 parent 475a8d4 commit 7c9e8bdebe34844afd625442e1f24d981058f027 @dg dg committed Sep 20, 2012
View
10 Nette/Caching/Storages/MemcachedStorage.php
@@ -68,12 +68,10 @@ public function __construct($host = 'localhost', $port = 11211, $prefix = '', IJ
public function addServer($host = 'localhost', $port = 11211, $timeout = 1)
{
- set_error_handler(function($severity, $message) {
- restore_error_handler();
- throw new Nette\InvalidStateException("Memcache::addServer(): $message");
- });
- $this->memcache->addServer($host, $port, TRUE, 1, $timeout);
- restore_error_handler();
+ if ($this->memcache->addServer($host, $port, TRUE, 1, $timeout) === FALSE) {
+ $error = error_get_last();
+ throw new Nette\InvalidStateException("Memcache::addServer(): $error[message].");
+ }
}
View
2 Nette/Config/Adapters/IniAdapter.php
@@ -38,7 +38,7 @@ class IniAdapter extends Nette\Object implements Nette\Config\IAdapter
*/
public function load($file)
{
- set_error_handler(function($severity, $message) {
+ set_error_handler(function($severity, $message) { // parse_ini_file returns FALSE on failure since PHP 5.2.7
restore_error_handler();
throw new Nette\InvalidStateException("parse_ini_file(): $message");
});
View
2 Nette/Http/Session.php
@@ -94,7 +94,7 @@ public function start()
$this->configure($this->options);
- set_error_handler(function($severity, $message) use (& $error) {
+ set_error_handler(function($severity, $message) use (& $error) { // session_start returns FALSE on failure since PHP 5.3.0.
if (($severity & error_reporting()) === $severity) {
$error = $message;
restore_error_handler();
View
11 Nette/Mail/SendmailMailer.php
@@ -48,14 +48,9 @@ public function send(Message $mail)
if ($this->commandArgs) {
$args[] = (string) $this->commandArgs;
}
- set_error_handler(function($severity, $message) {
- restore_error_handler();
- throw new Nette\InvalidStateException("mail(): $message");
- });
- $res = call_user_func_array('mail', $args);
- restore_error_handler();
- if (!$res) {
- throw new Nette\InvalidStateException('Unable to send email.');
+ if (call_user_func_array('mail', $args) === FALSE) {
+ $error = error_get_last();
+ throw new Nette\InvalidStateException("Unable to send email: $error[message].");
}
}
View
2 Nette/Utils/Arrays.php
@@ -170,7 +170,7 @@ public static function renameKey(array &$arr, $oldKey, $newKey)
*/
public static function grep(array $arr, $pattern, $flags = 0)
{
- set_error_handler(function($severity, $message) use ($pattern) { // compile error
+ set_error_handler(function($severity, $message) use ($pattern) { // preg_last_error does not return compile errors
restore_error_handler();
throw new RegexpException("$message in pattern: $pattern");
});
View
10 Nette/Utils/Strings.php
@@ -447,7 +447,7 @@ public static function random($length = 10, $charlist = '0-9a-z')
*/
public static function split($subject, $pattern, $flags = 0)
{
- set_error_handler(function($severity, $message) use ($pattern) { // compile error
+ set_error_handler(function($severity, $message) use ($pattern) { // preg_last_error does not return compile errors
restore_error_handler();
throw new RegexpException("$message in pattern: $pattern");
});
@@ -474,7 +474,7 @@ public static function match($subject, $pattern, $flags = 0, $offset = 0)
if ($offset > strlen($subject)) {
return NULL;
}
- set_error_handler(function($severity, $message) use ($pattern) { // compile error
+ set_error_handler(function($severity, $message) use ($pattern) { // preg_last_error does not return compile errors
restore_error_handler();
throw new RegexpException("$message in pattern: $pattern");
});
@@ -503,7 +503,7 @@ public static function matchAll($subject, $pattern, $flags = 0, $offset = 0)
if ($offset > strlen($subject)) {
return array();
}
- set_error_handler(function($severity, $message) use ($pattern) { // compile error
+ set_error_handler(function($severity, $message) use ($pattern) { // preg_last_error does not return compile errors
restore_error_handler();
throw new RegexpException("$message in pattern: $pattern");
});
@@ -539,7 +539,7 @@ public static function replace($subject, $pattern, $replacement = NULL, $limit =
throw new Nette\InvalidStateException("Callback '$textual' is not callable.");
}
- set_error_handler(function($severity, $message) use (& $tmp) { // compile error
+ set_error_handler(function($severity, $message) use (& $tmp) { // preg_last_error does not return compile errors
restore_error_handler();
throw new RegexpException("$message in pattern: $tmp");
});
@@ -559,7 +559,7 @@ public static function replace($subject, $pattern, $replacement = NULL, $limit =
$pattern = array_keys($pattern);
}
- set_error_handler(function($severity, $message) use ($pattern) { // compile error
+ set_error_handler(function($severity, $message) use ($pattern) { // preg_last_error does not return compile errors
restore_error_handler();
throw new RegexpException("$message in pattern: " . implode(' or ', (array) $pattern));
});

0 comments on commit 7c9e8bd

Please sign in to comment.
Something went wrong with that request. Please try again.