|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
Patch spl.autoload_extensions-take2 for SPL related Bug #50871Patch version 2010-12-25 12:37 UTC Return to Bug #50871 | Download this patchThis patch renders other patches obsolete Obsolete patches: Patch Revisions:Developer: kalle@php.net
Index: php_spl.c
===================================================================
--- php_spl.c (revision 306632)
+++ php_spl.c (working copy)
@@ -51,14 +51,35 @@
#define SPL_DEFAULT_FILE_EXTENSIONS ".inc,.php"
+/* {{{ PHP_INI_BEGIN */
+PHP_INI_BEGIN()
+ PHP_INI_ENTRY("spl.autoload_extensions", SPL_DEFAULT_FILE_EXTENSIONS, PHP_INI_ALL, OnUpdateAutoloadExtensions)
+PHP_INI_END()
+/* }}} */
+
+static PHP_INI_MH(OnUpdateAutoloadExtensions) /* {{{ */
+{
+ if (SPL_G(ini_autoload_extensions)) {
+ efree(SPL_G(ini_autoload_extensions);
+ }
+
+ SPL_G(ini_autoload_extensions) = new_value;
+ SPL_G(ini_autoload_extensions_len) = new_value_len;
+
+ return SUCCESS;
+} /* }}} */
+
+
/* {{{ PHP_GINIT_FUNCTION
*/
static PHP_GINIT_FUNCTION(spl)
{
- spl_globals->autoload_extensions = NULL;
- spl_globals->autoload_extensions_len = 0;
- spl_globals->autoload_functions = NULL;
- spl_globals->autoload_running = 0;
+ spl_globals->autoload_extensions = NULL;
+ spl_globals->autoload_extensions_len = 0;
+ spl_globals->autoload_functions = NULL;
+ spl_globals->autoload_running = 0;
+ spl_globals->ini_autoload_extensions = NULL;
+ spl_globals->ini_autoload_extensions_len = 0;
}
/* }}} */
@@ -905,12 +926,30 @@
}
/* }}} */
+/* {{{ PHP_MSHUTDOWN_FUNCTION(spl)
+ */
+PHP_MSHUTDOWN_FUNCTION(spl)
+{
+ if (SPL_G(ini_autoload_extensions)) {
+ efree(SPL_G(ini_autoload_extensions));
+ }
+
+ return SUCCESS;
+}
+/* }}} */
+
PHP_RINIT_FUNCTION(spl) /* {{{ */
{
SPL_G(autoload_extensions) = NULL;
SPL_G(autoload_extensions_len) = 0;
SPL_G(autoload_functions) = NULL;
SPL_G(hash_mask_init) = 0;
+
+ if (SPL_G(ini_autoload_extensions)) {
+ SPL_G(autoload_extensions) = estrdup(SPL_G(ini_autoload_extensions));
+ SPL_G(autoload_extensions_len) = SPL_G(ini_autoload_extensions_len);
+ }
+
return SUCCESS;
} /* }}} */
@@ -939,7 +978,7 @@
"SPL",
spl_functions,
PHP_MINIT(spl),
- NULL,
+ PHP_MSHUTDOWN(spl),
PHP_RINIT(spl),
PHP_RSHUTDOWN(spl),
PHP_MINFO(spl),
Index: php_spl.h
===================================================================
--- php_spl.h (revision 306632)
+++ php_spl.h (working copy)
@@ -70,6 +70,8 @@
intptr_t hash_mask_handle;
intptr_t hash_mask_handlers;
int hash_mask_init;
+ char * ini_autoload_extensions;
+ int ini_autoload_extensions_len;
ZEND_END_MODULE_GLOBALS(spl)
#ifdef ZTS
Index: tests/spl_autoload_extensions_001.phpt
===================================================================
--- tests/spl_autoload_extensions_001.phpt (revision 0)
+++ tests/spl_autoload_extensions_001.phpt (revision 0)
@@ -0,0 +1,12 @@
+--TEST--
+SPL: spl_autoload_extensions INI test
+--INI--
+spl.autoload_extensions=.phtml
+--FILE--
+<?php
+
+var_dump(spl_autoload_extensions());
+
+?>
+--EXPECTF--
+string(6) ".phtml"
\ No newline at end of file
|
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 18 16:00:01 2025 UTC |