]> granicus.if.org Git - php/commitdiff
Remove HAVE_SPL checks
authorNikita Popov <nikic@php.net>
Sat, 30 Jan 2016 13:39:55 +0000 (14:39 +0100)
committerNikita Popov <nikic@php.net>
Sat, 30 Jan 2016 13:53:00 +0000 (14:53 +0100)
SPL is always built.

Also clean up spl_ce_RuntimeException handling in PDO.

ext/mysqli/mysqli.c
ext/mysqli/mysqli_priv.h
ext/mysqli/php_mysqli_structs.h
ext/pdo/pdo.c
ext/phar/phar.c
ext/phar/phar_internal.h
ext/phar/phar_object.c
ext/simplexml/php_simplexml.h
ext/snmp/snmp.c
ext/standard/array.c

index 41b5783d185dbc0e4af74c45f33e31604cd9ad0d..8ffce1813f49a42e017ed2286a49df79e6830a84 100644 (file)
@@ -34,6 +34,7 @@
 #include "php_mysqli_structs.h"
 #include "mysqli_priv.h"
 #include "zend_exceptions.h"
+#include "ext/spl/spl_exceptions.h"
 #include "zend_interfaces.h"
 
 ZEND_DECLARE_MODULE_GLOBALS(mysqli)
@@ -603,11 +604,7 @@ PHP_MINIT_FUNCTION(mysqli)
                "MySqli persistent connection", module_number);
 
        INIT_CLASS_ENTRY(cex, "mysqli_sql_exception", mysqli_exception_methods);
-#ifdef HAVE_SPL
        mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException);
-#else
-       mysqli_exception_class_entry = zend_register_internal_class_ex(&cex, zend_ce_exception);
-#endif
        mysqli_exception_class_entry->ce_flags |= ZEND_ACC_FINAL;
        zend_declare_property_long(mysqli_exception_class_entry, "code", sizeof("code")-1, 0, ZEND_ACC_PROTECTED);
        zend_declare_property_string(mysqli_exception_class_entry, "sqlstate", sizeof("sqlstate")-1, "00000", ZEND_ACC_PROTECTED);
@@ -999,9 +996,7 @@ PHP_MINFO_FUNCTION(mysqli)
 
 /* Dependancies */
 static const  zend_module_dep mysqli_deps[] = {
-#if defined(HAVE_SPL) && (PHP_VERSION_ID >= 50100)
        ZEND_MOD_REQUIRED("spl")
-#endif
 #if defined(MYSQLI_USE_MYSQLND)
        ZEND_MOD_REQUIRED("mysqlnd")
 #endif
index 0a1122a836ff81596e218ae7451508690ea613eb..c34049c89e926a6d2690c556c4198e18a950476d 100644 (file)
@@ -78,10 +78,6 @@ extern void php_mysqli_report_error(const char *sqlstate, int errorno, const cha
 extern void php_mysqli_report_index(const char *query, unsigned int status);
 extern void php_mysqli_throw_sql_exception(char *sqlstate, int errorno, char *format, ...);
 
-#ifdef HAVE_SPL
-extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
-#endif
-
 #define PHP_MYSQLI_EXPORT(__type) PHP_MYSQLI_API __type
 
 PHP_MYSQLI_EXPORT(zend_object *) mysqli_objects_new(zend_class_entry *);
index 4ef13fd198098f4f6af82cd28acd3abe04cc1f0f..7bfffa83c8658d95ee771d24f9a6ec12390636b0 100644 (file)
@@ -216,10 +216,6 @@ extern zend_object_iterator *php_mysqli_result_get_iterator(zend_class_entry *ce
 
 extern void php_mysqli_fetch_into_hash_aux(zval *return_value, MYSQL_RES * result, zend_long fetchtype);
 
-#ifdef HAVE_SPL
-extern PHPAPI zend_class_entry *spl_ce_RuntimeException;
-#endif
-
 #define MYSQLI_DISABLE_MQ if (mysql->multi_query) { \
        mysql_set_server_option(mysql->mysql, MYSQL_OPTION_MULTI_STATEMENTS_OFF); \
        mysql->multi_query = 0; \
index 77366f817dd1280b4ea6c1849a9ada22949eb4ce..8195c650ab914a770335097a3461f4b8ebd424c0 100644 (file)
@@ -32,8 +32,7 @@
 #include "php_pdo_driver.h"
 #include "php_pdo_int.h"
 #include "zend_exceptions.h"
-
-static zend_class_entry *spl_ce_RuntimeException;
+#include "ext/spl/spl_exceptions.h"
 
 zend_class_entry *pdo_dbh_ce, *pdo_dbstmt_ce, *pdo_row_ce;
 
@@ -79,20 +78,9 @@ PDO_API char *php_pdo_str_tolower_dup(const char *src, int len) /* {{{ */
 
 PDO_API zend_class_entry *php_pdo_get_exception_base(int root) /* {{{ */
 {
-#if defined(HAVE_SPL)
        if (!root) {
-               if (!spl_ce_RuntimeException) {
-                       zend_class_entry *pce;
-
-                       if ((pce = zend_hash_str_find_ptr(CG(class_table), "runtimeexception", sizeof("RuntimeException") - 1))) {
-                               spl_ce_RuntimeException = pce;
-                               return pce;
-                       }
-               } else {
-                       return spl_ce_RuntimeException;
-               }
+               return spl_ce_RuntimeException;
        }
-#endif
        return zend_ce_exception;
 }
 /* }}} */
@@ -130,9 +118,7 @@ const zend_function_entry pdo_functions[] = {
 /* {{{ pdo_functions[] */
 #if ZEND_MODULE_API_NO >= 20050922
 static const zend_module_dep pdo_deps[] = {
-#ifdef HAVE_SPL
        ZEND_MOD_REQUIRED("spl")
-#endif
        ZEND_MOD_END
 };
 #endif
@@ -351,8 +337,6 @@ PHP_MINIT_FUNCTION(pdo)
 {
        zend_class_entry ce;
 
-       spl_ce_RuntimeException = NULL;
-
        if (FAILURE == pdo_sqlstate_init_error_table()) {
                return FAILURE;
        }
index 0ed34dbfcd0576adc02983de692e3ad4873155c3..9e1b52981d09b35be6d6efb2c2c4673482da4401 100644 (file)
@@ -3581,9 +3581,7 @@ static const zend_module_dep phar_deps[] = {
 #if defined(HAVE_HASH) && !defined(COMPILE_DL_HASH)
        ZEND_MOD_REQUIRED("hash")
 #endif
-#if HAVE_SPL
        ZEND_MOD_REQUIRED("spl")
-#endif
        ZEND_MOD_END
 };
 
index 1e7ab7a324aea7e07b0d996087a021f3949ac43c..003287543c9aeea3545829ea03b56d71c163b9d2 100644 (file)
 #include "TSRM/tsrm_strtok_r.h"
 #endif
 #include "Zend/zend_virtual_cwd.h"
-#if HAVE_SPL
 #include "ext/spl/spl_array.h"
 #include "ext/spl/spl_directory.h"
 #include "ext/spl/spl_engine.h"
 #include "ext/spl/spl_exceptions.h"
 #include "ext/spl/spl_iterators.h"
-#endif
 #include "php_phar.h"
 #ifdef PHAR_HASH_OK
 #include "ext/hash/php_hash.h"
@@ -210,10 +208,8 @@ ZEND_TSRMLS_CACHE_EXTERN();
 #endif
 #include "pharzip.h"
 
-#if HAVE_SPL
 typedef union _phar_archive_object  phar_archive_object;
 typedef union _phar_entry_object    phar_entry_object;
-#endif
 
 /*
  * used in phar_entry_info->fp_type to
@@ -473,21 +469,17 @@ typedef struct _phar_entry_data {
        phar_entry_info          *internal_file;
 } phar_entry_data;
 
-#if HAVE_SPL
 /* archive php object */
 union _phar_archive_object {
        spl_filesystem_object    spl;
        phar_archive_data        *archive;
 };
-#endif
 
-#if HAVE_SPL
 /* entry php object */
 union _phar_entry_object {
        spl_filesystem_object    spl;
        phar_entry_info          *entry;
 };
-#endif
 
 #ifndef PHAR_MAIN
 extern zend_string *(*phar_save_resolve_path)(const char *filename, int filename_len);
index 22404dddbc2130648699dc9081b4b18083ba2f46..a212c1bdab4a4cd5437f4047e7df1cb47230dbab 100644 (file)
 static zend_class_entry *phar_ce_archive;
 static zend_class_entry *phar_ce_data;
 static zend_class_entry *phar_ce_PharException;
-
-#if HAVE_SPL
 static zend_class_entry *phar_ce_entry;
-#endif
 
 #if PHP_VERSION_ID >= 50300
 # define PHAR_ARG_INFO
@@ -1071,7 +1068,6 @@ PHP_METHOD(Phar, isValidPharFilename)
 }
 /* }}} */
 
-#if HAVE_SPL
 /**
  * from spl_directory
  */
@@ -1104,7 +1100,6 @@ static spl_other_handler phar_spl_foreign_handler = {
        phar_spl_foreign_dtor,
        phar_spl_foreign_clone
 };
-#endif /* HAVE_SPL */
 
 /* {{{ proto void Phar::__construct(string fname [, int flags [, string alias]])
  * Construct a Phar archive object
@@ -1117,9 +1112,6 @@ static spl_other_handler phar_spl_foreign_handler = {
  */
 PHP_METHOD(Phar, __construct)
 {
-#if !HAVE_SPL
-       zend_throw_exception_ex(zend_ce_exception, 0, "Cannot instantiate Phar object without SPL extension");
-#else
        char *fname, *alias = NULL, *error, *arch = NULL, *entry = NULL, *save_fname;
        size_t fname_len, alias_len = 0;
        int arch_len, entry_len, is_data;
@@ -1244,7 +1236,6 @@ PHP_METHOD(Phar, __construct)
 
        phar_obj->spl.info_class = phar_ce_entry;
        efree(fname);
-#endif /* HAVE_SPL */
 }
 /* }}} */
 
@@ -1363,8 +1354,6 @@ PHP_METHOD(Phar, unlinkArchive)
 }
 /* }}} */
 
-#if HAVE_SPL
-
 #define PHAR_ARCHIVE_OBJECT() \
        zval *zobj = getThis(); \
        phar_archive_object *phar_obj = (phar_archive_object*)((char*)Z_OBJ_P(zobj) - Z_OBJ_P(zobj)->handlers->offset); \
@@ -5043,8 +5032,6 @@ PHP_METHOD(PharFileInfo, decompress)
 }
 /* }}} */
 
-#endif /* HAVE_SPL */
-
 /* {{{ phar methods */
 PHAR_ARG_INFO
 ZEND_BEGIN_ARG_INFO_EX(arginfo_phar___construct, 0, 0, 1)
@@ -5113,7 +5100,6 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_ua, 0, 0, 1)
        ZEND_ARG_INFO(0, archive)
 ZEND_END_ARG_INFO()
 
-#if HAVE_SPL
 PHAR_ARG_INFO
 ZEND_BEGIN_ARG_INFO_EX(arginfo_phar_build, 0, 0, 1)
        ZEND_ARG_INFO(0, iterator)
@@ -5232,12 +5218,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_phar__void, 0)
 ZEND_END_ARG_INFO()
 
 
-#endif /* HAVE_SPL */
-
 zend_function_entry php_archive_methods[] = {
-#if !HAVE_SPL
-       PHP_ME(Phar, __construct,           arginfo_phar___construct,  ZEND_ACC_PRIVATE)
-#else
        PHP_ME(Phar, __construct,           arginfo_phar___construct,  ZEND_ACC_PUBLIC)
        PHP_ME(Phar, __destruct,            arginfo_phar__void,        ZEND_ACC_PUBLIC)
        PHP_ME(Phar, addEmptyDir,           arginfo_phar_emptydir,     ZEND_ACC_PUBLIC)
@@ -5279,7 +5260,6 @@ zend_function_entry php_archive_methods[] = {
        PHP_ME(Phar, setStub,               arginfo_phar_setStub,      ZEND_ACC_PUBLIC)
        PHP_ME(Phar, startBuffering,        arginfo_phar__void,        ZEND_ACC_PUBLIC)
        PHP_ME(Phar, stopBuffering,         arginfo_phar__void,        ZEND_ACC_PUBLIC)
-#endif
        /* static member functions */
        PHP_ME(Phar, apiVersion,            arginfo_phar__void,        ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
        PHP_ME(Phar, canCompress,           arginfo_phar_cancompress,  ZEND_ACC_PUBLIC|ZEND_ACC_STATIC|ZEND_ACC_FINAL)
@@ -5299,7 +5279,6 @@ zend_function_entry php_archive_methods[] = {
        PHP_FE_END
 };
 
-#if HAVE_SPL
 PHAR_ARG_INFO
 ZEND_BEGIN_ARG_INFO_EX(arginfo_entry___construct, 0, 0, 1)
        ZEND_ARG_INFO(0, filename)
@@ -5328,7 +5307,6 @@ zend_function_entry php_entry_methods[] = {
        PHP_ME(PharFileInfo, setMetadata,        arginfo_phar_setMetadata,   ZEND_ACC_PUBLIC)
        PHP_FE_END
 };
-#endif /* HAVE_SPL */
 
 zend_function_entry phar_exception_methods[] = {
        PHP_FE_END
@@ -5345,7 +5323,6 @@ void phar_object_init(void) /* {{{ */
        INIT_CLASS_ENTRY(ce, "PharException", phar_exception_methods);
        phar_ce_PharException = zend_register_internal_class_ex(&ce, zend_ce_exception);
 
-#if HAVE_SPL
        INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
        phar_ce_archive = zend_register_internal_class_ex(&ce, spl_ce_RecursiveDirectoryIterator);
 
@@ -5358,15 +5335,6 @@ void phar_object_init(void) /* {{{ */
 
        INIT_CLASS_ENTRY(ce, "PharFileInfo", php_entry_methods);
        phar_ce_entry = zend_register_internal_class_ex(&ce, spl_ce_SplFileInfo);
-#else
-       INIT_CLASS_ENTRY(ce, "Phar", php_archive_methods);
-       phar_ce_archive = zend_register_internal_class(&ce);
-       phar_ce_archive->ce_flags |= ZEND_ACC_FINAL;
-
-       INIT_CLASS_ENTRY(ce, "PharData", php_archive_methods);
-       phar_ce_data = zend_register_internal_class(&ce);
-       phar_ce_data->ce_flags |= ZEND_ACC_FINAL;
-#endif
 
        REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "BZ2", PHAR_ENT_COMPRESSED_BZ2)
        REGISTER_PHAR_CLASS_CONST_LONG(phar_ce_archive, "GZ", PHAR_ENT_COMPRESSED_GZ)
index a6d5ffc7ff20adbefdb3242c594cbb7a4b01aa83..ea29f1399c6c1b5bc9d8dd22106f731062b0af79 100644 (file)
@@ -45,9 +45,6 @@ extern zend_module_entry simplexml_module_entry;
 
 PHP_MINIT_FUNCTION(simplexml);
 PHP_MSHUTDOWN_FUNCTION(simplexml);
-#ifdef HAVE_SPL
-PHP_RINIT_FUNCTION(simplexml);
-#endif
 PHP_MINFO_FUNCTION(simplexml);
 
 typedef enum {
index be8888c348ccd3979180bb2d620b487632eb3731..8d3d095e6b323ea2b29d991fd8683527666ee058 100644 (file)
 #include "php_snmp.h"
 
 #include "zend_exceptions.h"
-
-#if HAVE_SPL
 #include "ext/spl/spl_exceptions.h"
-#endif
 
 #if HAVE_SNMP
 
@@ -2414,11 +2411,7 @@ PHP_MINIT_FUNCTION(snmp)
 
        /* Register SNMPException class */
        INIT_CLASS_ENTRY(cex, "SNMPException", NULL);
-#ifdef HAVE_SPL
        php_snmp_exception_ce = zend_register_internal_class_ex(&cex, spl_ce_RuntimeException);
-#else
-       php_snmp_exception_ce = zend_register_internal_class_ex(&cex, zend_ce_exception);
-#endif
 
        return SUCCESS;
 }
@@ -2452,9 +2445,7 @@ PHP_MINFO_FUNCTION(snmp)
  */
 #if ZEND_MODULE_API_NO >= 20050922
 static const zend_module_dep snmp_module_deps[] = {
-#ifdef HAVE_SPL
        ZEND_MOD_REQUIRED("spl")
-#endif
        ZEND_MOD_END
 };
 #endif
index 4152cc4b1f51239ce56dc52bd3851a9d2c48f258..6e30eae8a1b08d6fb10fcddab868c48e03f953e2 100644 (file)
@@ -46,9 +46,7 @@
 #include "php_string.h"
 #include "php_rand.h"
 #include "zend_smart_str.h"
-#ifdef HAVE_SPL
 #include "ext/spl/spl_array.h"
-#endif
 
 /* {{{ defines */
 #define EXTR_OVERWRITE                 0
@@ -821,9 +819,7 @@ PHP_FUNCTION(count)
                        RETURN_LONG(cnt);
                        break;
                case IS_OBJECT: {
-#ifdef HAVE_SPL
                        zval retval;
-#endif
                        /* first, we check if the handler is defined */
                        if (Z_OBJ_HT_P(array)->count_elements) {
                                RETVAL_LONG(1);
@@ -831,7 +827,6 @@ PHP_FUNCTION(count)
                                        return;
                                }
                        }
-#ifdef HAVE_SPL
                        /* if not and the object implements Countable we call its count() method */
                        if (instanceof_function(Z_OBJCE_P(array), spl_ce_Countable)) {
                                zend_call_method_with_0_params(array, NULL, NULL, "count", &retval);
@@ -841,7 +836,6 @@ PHP_FUNCTION(count)
                                }
                                return;
                        }
-#endif
                }
                default:
                        RETURN_LONG(1);