Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3cd5ac1

Browse files
committed
use spl_ce_RuntimeException (exists since 5.6)
1 parent 3675f44 commit 3cd5ac1

2 files changed

Lines changed: 4 additions & 16 deletions

File tree

redis.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "redis_commands.h"
2929
#include "redis_sentinel.h"
3030
#include <standard/php_random.h>
31+
#include <ext/spl/spl_exceptions.h>
3132
#include <zend_exceptions.h>
3233
#include <ext/standard/info.h>
3334
#include <ext/hash/php_hash.h>
@@ -436,7 +437,6 @@ static PHP_GINIT_FUNCTION(redis)
436437
PHP_MINIT_FUNCTION(redis)
437438
{
438439
struct timeval tv;
439-
zend_class_entry *exception_ce = NULL;
440440

441441
/* Seed random generator (for RedisCluster failover) */
442442
gettimeofday(&tv, NULL);
@@ -462,14 +462,8 @@ PHP_MINIT_FUNCTION(redis)
462462
"Redis cluster slot cache",
463463
module_number);
464464

465-
/* Base Exception class */
466-
exception_ce = zend_hash_str_find_ptr(CG(class_table), "RuntimeException", sizeof("RuntimeException") - 1);
467-
if (exception_ce == NULL) {
468-
exception_ce = zend_exception_get_default();
469-
}
470-
471465
/* RedisException class */
472-
redis_exception_ce = register_class_RedisException(exception_ce);
466+
redis_exception_ce = register_class_RedisException(spl_ce_RuntimeException);
473467

474468
/* Add shared class constants to Redis and RedisCluster objects */
475469
add_class_constants(redis_ce, 0);

redis_cluster.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "crc16.h"
2626
#include "redis_cluster.h"
2727
#include "redis_commands.h"
28+
#include <ext/spl/spl_exceptions.h>
2829
#include <zend_exceptions.h>
2930
#include "library.h"
3031
#include <php_variables.h>
@@ -44,17 +45,10 @@ zend_class_entry *redis_cluster_exception_ce;
4445

4546
PHP_MINIT_FUNCTION(redis_cluster)
4647
{
47-
zend_class_entry *exception_ce = NULL;
48-
4948
redis_cluster_ce = register_class_RedisCluster();
5049
redis_cluster_ce->create_object = create_cluster_context;
5150

52-
/* Base Exception class */
53-
exception_ce = zend_hash_str_find_ptr(CG(class_table), "RuntimeException", sizeof("RuntimeException") - 1);
54-
if (exception_ce == NULL) {
55-
exception_ce = zend_exception_get_default();
56-
}
57-
redis_cluster_exception_ce = register_class_RedisClusterException(exception_ce);
51+
redis_cluster_exception_ce = register_class_RedisClusterException(spl_ce_RuntimeException);
5852

5953
return SUCCESS;
6054
}

0 commit comments

Comments
 (0)