php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4683 php doesn't initialize itself properly
Submitted: 2000-05-30 01:46 UTC Modified: 2000-06-28 17:09 UTC
From: asun at cobalt dot com Assigned:
Status: Closed Package: Other
PHP Version: 4.0.0 Release OS: linux 2.2.14
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: asun at cobalt dot com
New email:
PHP Version: OS:

 

 [2000-05-30 01:46 UTC] asun at cobalt dot com
php doesn't set up its known_directives hash properly before reading
php.ini. as a result, php.ini doesn't set any values. this has the
effect of making things like document_root and extensions_dir not work. 

here's a patch that changes the setup order and removes a circular
dependency in the known_directives initialization:

--- php-4.0.0/main.c.init	Mon May 29 16:29:16 2000
+++ php-4.0.0/main.c	Mon May 29 16:29:57 2000
@@ -890,12 +890,11 @@
 	FREE_MUTEX(gLock);
 
 	php_ini_mstartup();
+	REGISTER_INI_ENTRIES();
 
 	if (php_config_ini_startup() == FAILURE) {
 		return FAILURE;
 	}
-
-	REGISTER_INI_ENTRIES();
 
 	zuv.short_tags = (zend_bool) PG(short_tags);
 	zuv.asp_tags = (zend_bool) PG(asp_tags);
--- php-4.0.0/php_ini.c.init	Mon May 29 16:29:27 2000
+++ php-4.0.0/php_ini.c	Mon May 29 16:29:49 2000
@@ -101,17 +101,6 @@
 		if (hashed_ini_entry->on_modify) {
 			hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP);
 		}
-		if ((default_value=cfg_get_entry(p->name, p->name_length))) {
-			if (!hashed_ini_entry->on_modify
-				|| hashed_ini_entry->on_modify(hashed_ini_entry, default_value->value.str.val, default_value->value.str.len, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP)==SUCCESS) {
-				hashed_ini_entry->value = default_value->value.str.val;
-				hashed_ini_entry->value_length = default_value->value.str.len;
-			}
-		} else {
-			if (hashed_ini_entry->on_modify) {
-				hashed_ini_entry->on_modify(hashed_ini_entry, hashed_ini_entry->value, hashed_ini_entry->value_length, hashed_ini_entry->mh_arg1, hashed_ini_entry->mh_arg2, hashed_ini_entry->mh_arg3, PHP_INI_STAGE_STARTUP);
-			}
-		}
 		hashed_ini_entry->modified = 0;
 		p++;
 	}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-30 06:36 UTC] asun at cobalt dot com
some more clarification: because modules are loaded in the config file
parsing stage, the lack of extensions_dir was causing problems. the
previous patch had too many side effects and looked like it was going
to take too much trouble to get right. as module loading is the
only thing that needs real values, here's a simpler patch that just deals
with that case:

--- php-4.0.0/ext/standard/dl.c.init    Mon May 29 21:21:32 2000
+++ php-4.0.0/ext/standard/dl.c Mon May 29 21:26:21 2000
@@ -78,18 +78,22 @@
 void php_dl(pval *file,int type,pval *return_value)
 {
        void *handle;
-       char *libpath;
+       char *libpath, *extension_dir;
        zend_module_entry *module_entry,*tmp;
        zend_module_entry *(*get_module)(void);
        PLS_FETCH();
        ELS_FETCH();

-       if (PG(extension_dir) && PG(extension_dir)[0]){
-               int extension_dir_len = strlen(PG(extension_dir));
+       if (PG(extension_dir))
+               extension_dir = PG(extension_dir);
+       else
+               cfg_get_string("extension_dir", &extension_dir);
+       if (extension_dir && extension_dir[0]) {
+               int extension_dir_len = strlen(extension_dir);

                libpath = emalloc(extension_dir_len+file->value.str.len+2);

-               sprintf(libpath,"%s/%s",PG(extension_dir),file->value.str.val);
+               sprintf(libpath,"%s/%s",extension_dir,file->value.str.val);
        } else {
                libpath = estrndup(file->value.str.val, file->value.str.len);
        }
 [2000-06-28 17:09 UTC] zeev at cvs dot php dot net
The bug description is bogus, and the fix isn't quite valid either.

There was a bug in PHP 4.0.0 that did prevent extension_dir from working properly, which was in fact related to the new INI mechanism (it was being misused).  It's been fixed in 4.0.1, and was unique to that directive, that's supposed to affect PHP's behavior while reading the php.ini file itself.

There were separate bugs that prevented doc_root from working properly under some circumstances, which have been fixed in 4.0.1 as well.

However, the INI code as it was in 4.0.0 is correct.

At any rate - thanks for the bug report!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 11:01:27 2024 UTC