# [PATCH] Enable extension loading from .user.ini when run as CGI.

- Thread: https://externals.io/message/61846
- Original archive: https://news-web.php.net/php.internals/61846
- Started by Edward Z. Yang on 2012-07-27T22:57:05+00:00
- Messages: 5
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #61846 — Edward Z. Yang — 2012-07-27T22:57:05+00:00

URL: https://externals.io/message/61846#61846

From: "Edward Z. Yang" <ezyang@mit.edu>

Functionality is not included for other SAPIs because they either do not
support .user.ini (e.g. CLI) or they serve multiple requests and thus
do not support `dl()` (e.g. FastCGI).

There is also a bugfix to invoke zlist_clean, to ensure extension_lists can be
reused for the second round of extension appliations (since the head and tail
pointers have garbage in them).

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
---
 main/php_ini.c      | 4 ++--
 sapi/cgi/cgi_main.c | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/main/php_ini.c b/main/php_ini.c
index 89a3d7e..1fde28e 100644
--- a/main/php_ini.c
+++ b/main/php_ini.c
@@ -709,8 +709,8 @@ void php_ini_register_extensions(TSRMLS_D)
 	zend_llist_apply(&extension_lists.engine, php_load_zend_extension_cb TSRMLS_CC);
 	zend_llist_apply(&extension_lists.functions, php_load_php_extension_cb TSRMLS_CC);
 
-	zend_llist_destroy(&extension_lists.engine);
-	zend_llist_destroy(&extension_lists.functions);
+	zend_llist_clean(&extension_lists.engine);
+	zend_llist_clean(&extension_lists.functions);
 }
 /* }}} */
 
diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c
index 7856e0c..d944f3a 100644
--- a/sapi/cgi/cgi_main.c
+++ b/sapi/cgi/cgi_main.c
@@ -818,6 +818,7 @@ static void php_cgi_ini_activate_user_config(char *path, int path_len, const cha
 
 	/* Activate ini entries with values from the user config hash */
 	php_ini_activate_config(entry->user_config, PHP_INI_PERDIR, PHP_INI_STAGE_HTACCESS TSRMLS_CC);
+	php_ini_register_extensions(TSRMLS_CC);
 }
 /* }}} */
 
-- 
1.7.11.3

---

## #61849 — Pierre Joye — 2012-07-28T06:20:51+00:00

URL: https://externals.io/message/61846#61849 · In reply to: #61846

Hi Edward,


> From: "Edward Z. Yang" <ezyang@mit.edu>
>
> Functionality is not included for other SAPIs because they either do not
> support .user.ini (e.g. CLI) or they serve multiple requests and thus
> do not support `dl()` (e.g. FastCGI).

dl has been disabled in FastCGI and other web SAPIs for a reason, it
is not working well and brings php to instability. I do not think
adding this to .user.ini will be any better.

> There is also a bugfix to invoke zlist_clean, to ensure extension_lists can be
> reused for the second round of extension appliations (since the head and tail
> pointers have garbage in them).

Can you create a patch only for this bug fix please? Ideally a bug
report + patch or pull request :-)

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

---

## #61850 — Edward Z. Yang — 2012-07-28T06:27:42+00:00

URL: https://externals.io/message/61846#61850 · In reply to: #61849

Excerpts from Pierre Joye's message of Sat Jul 28 02:20:51 -0400 2012:
> > […]
> 
> dl has been disabled in FastCGI and other web SAPIs for a reason, it
> is not working well and brings php to instability. I do not think
> adding this to .user.ini will be any better.

It has been a while, but last winter we discussed this patch and decided
that extension loading was OK for short-lived PHP processes, e.g. CGI.
So this patch only enables it for CGI.

> Can you create a patch only for this bug fix please? Ideally a bug
> report + patch or pull request :-)

Sure, I can split in two. Does PHP use pull requests?

Edward

---

## #61851 — Pierre Joye — 2012-07-28T06:34:23+00:00

URL: https://externals.io/message/61846#61851 · In reply to: #61850

> Excerpts from Pierre Joye's message of Sat Jul 28 02:20:51 -0400 2012:
> > […]
>
> It has been a while, but last winter we discussed this patch and decided
> that extension loading was OK for short-lived PHP processes, e.g. CGI.
> So this patch only enables it for CGI.

Oh, I miss the CGI only part. It makes sense then, while I am not over
warm about the idea tho' :-).

> > […]
>
> Sure, I can split in two. Does PHP use pull requests?

Yes, via github's php mirror, see https://wiki.php.net/vcs/gitworkflow

Cheers,
-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org

---

## #61852 — Pierre Joye — 2012-07-28T06:34:55+00:00

URL: https://externals.io/message/61846#61852 · In reply to: #61851

> > […]
>
> Yes, via github's php mirror, see https://wiki.php.net/vcs/gitworkflow

https://github.com/php/php-src

-- 
Pierre

@pierrejoye | http://blog.thepimp.net | http://www.libgd.org
