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

Skip to content

Commit 7c14071

Browse files
committed
Remove redis_get_exception_base
1 parent 1ab89e1 commit 7c14071

3 files changed

Lines changed: 19 additions & 26 deletions

File tree

library.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,6 @@
4949
extern zend_class_entry *redis_ce;
5050
extern zend_class_entry *redis_exception_ce;
5151

52-
static zend_class_entry *runtime_exception_ce = NULL;
53-
54-
PHP_REDIS_API zend_class_entry *
55-
redis_get_exception_base(TSRMLS_D)
56-
{
57-
if (runtime_exception_ce == NULL) {
58-
#if HAVE_SPL
59-
runtime_exception_ce = zend_hash_str_find_ptr(CG(class_table), "RuntimeException", sizeof("RuntimeException") - 1);
60-
#else
61-
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
62-
runtime_exception_ce = zend_exception_get_default();
63-
#else
64-
runtime_exception_ce = zend_exception_get_default(TSRMLS_C);
65-
#endif
66-
#endif
67-
}
68-
return runtime_exception_ce;
69-
}
70-
7152
/* Helper to reselect the proper DB number when we reconnect */
7253
static int reselect_db(RedisSock *redis_sock TSRMLS_DC) {
7354
char *cmd, *response;

library.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,4 @@ PHP_REDIS_API int redis_read_variant_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSo
8888

8989
PHP_REDIS_API void redis_client_list_reply(INTERNAL_FUNCTION_PARAMETERS, RedisSock *redis_sock, zval *z_tab);
9090

91-
PHP_REDIS_API zend_class_entry *redis_get_exception_base(TSRMLS_D);
9291
#endif

redis.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,6 +1121,8 @@ PHP_MINIT_FUNCTION(redis)
11211121
zend_class_entry redis_exception_class_entry;
11221122
zend_class_entry redis_cluster_exception_class_entry;
11231123

1124+
zend_class_entry *exception_ce = NULL;
1125+
11241126
/* Seed random generator (for RedisCluster failover) */
11251127
gettimeofday(&tv, NULL);
11261128
srand(tv.tv_usec * tv.tv_sec);
@@ -1142,15 +1144,27 @@ PHP_MINIT_FUNCTION(redis)
11421144
redis_cluster_ce = zend_register_internal_class(&redis_cluster_class_entry TSRMLS_CC);
11431145
redis_cluster_ce->create_object = create_cluster_context;
11441146

1147+
1148+
/* Base Exception class */
1149+
#if HAVE_SPL
1150+
exception_ce = zend_hash_str_find_ptr(CG(class_table), "RuntimeException", sizeof("RuntimeException") - 1);
1151+
#endif
1152+
if (exception_ce == NULL) {
1153+
#if (PHP_MAJOR_VERSION == 5) && (PHP_MINOR_VERSION < 2)
1154+
exception_ce = zend_exception_get_default();
1155+
#else
1156+
exception_ce = zend_exception_get_default(TSRMLS_C);
1157+
#endif
1158+
}
1159+
11451160
/* RedisException class */
11461161
INIT_CLASS_ENTRY(redis_exception_class_entry, "RedisException", NULL);
11471162
redis_exception_ce = zend_register_internal_class_ex(
11481163
&redis_exception_class_entry,
11491164
#if (PHP_MAJOR_VERSION < 7)
1150-
redis_get_exception_base(TSRMLS_C),
1151-
NULL TSRMLS_CC
1165+
exception_ce, NULL TSRMLS_CC
11521166
#else
1153-
redis_get_exception_base(TSRMLS_C)
1167+
exception_ce
11541168
#endif
11551169
);
11561170

@@ -1160,10 +1174,9 @@ PHP_MINIT_FUNCTION(redis)
11601174
redis_cluster_exception_ce = zend_register_internal_class_ex(
11611175
&redis_cluster_exception_class_entry,
11621176
#if (PHP_MAJOR_VERSION < 7)
1163-
redis_get_exception_base(TSRMLS_C),
1164-
NULL TSRMLS_CC
1177+
exception_ce, NULL TSRMLS_CC
11651178
#else
1166-
redis_get_exception_base(TSRMLS_C)
1179+
exception_ce
11671180
#endif
11681181
);
11691182

0 commit comments

Comments
 (0)