Page 1 of 1
Suggested Change to serendipity_config.inc.php
Posted: Sat Jan 20, 2007 6:36 am
by axelseaa
I run a multi-install site, and i scripted the installation and was not able to get around changing 1 line in the serendipity_config.inc.php file.
Is it possible to change line 31 from:
include(S9Y_INCLUDE_PATH . 'include/compat.inc.php');
To:
include_once(S9Y_INCLUDE_PATH . 'include/compat.inc.php');
Re: Suggested Change to serendipity_config.inc.php
Posted: Mon Jan 22, 2007 12:11 pm
by garvinhicking
Hi!
The problem is we use include calls instead of include_once to allow PHP bytecode caches to better operate, so I'm afraid we can't change that.
However in serendipity 1.1 the compact file already has a return statement that bails out if the file was included twice!?
HTH,
Garvin
Posted: Tue Jan 23, 2007 4:14 am
by axelseaa
Garvin,
I did some testing, and this is what I concluded.
First, I created the following file:
Code: Select all
<?php
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";
?>
I then called it as follows:
Code: Select all
include('test.php');
include('test.php');
include('test.php');
The output is:
blah blah blah blah
Second, I changed the test.php file to be the following:
Code: Select all
<?php
if (defined('TEST_LOADED')) {
return;
}
define('TEST_LOADED',true);
echo "blah blah blah blah<br/>";
function myFunc($test) {
}
?>
When I load the page now, it throws the following error: PHP Fatal error: Cannot redeclare myfunc()
It appears that if there are functions in the include page that you can't use return to bail out. Is this your understanding of it? Or does it work correctly for you?
Posted: Tue Jan 23, 2007 5:28 am
by axelseaa
Here is a response I got from the php list:
If there are functions defined in the included file, they can be used in the main file independent if they are before return() or after. If the file is included twice, PHP 5 issues fatal error because functions were already declared, while PHP 4 doesn't complain about functions defined after return().
Posted: Tue Jan 23, 2007 10:49 am
by garvinhicking
Hi!
Hm, okay. I didn't think of that, I'm sorry.
Is there a way for you to prevent the double inclusion of that file? Usually also in shared installs it should not be necessary that the serendipity_config.inc.php is called twice?
HTH,
Garvin
Posted: Tue Jan 23, 2007 2:24 pm
by axelseaa
The problem isn't serendipity_config.inc.php directly.
For my install script to process, it needs to include both the functions.inc.php file and the serendipity_config.inc.php. Both of those files try to include compat.inc.php, which is what causes the problems.
Is it necessary to call compat.inc.php directly from serendipity_config.inc.php? Shouldn't it already be included from functions.inc.php?
Posted: Tue Jan 23, 2007 2:26 pm
by garvinhicking
Hi!
But functions.inc.php should be included by serendipity_config, so you shouldn't need to include both?
So functions.inc.php should actually be called after compat.inc.php...?!
Regards,
Garvin
Posted: Tue Jan 23, 2007 2:57 pm
by axelseaa
Currently in my installer I have the following chunk of code:
Code: Select all
define('IN_installer', true);
define('IN_upgrader', true);
define('IN_serendipity', true);
define('IN_serendipity_admin', true);
define('IS_installed', false);
define('S9Y_INCLUDE_PATH', '/usr/local/lib/s9y/');
$serendipity['dbType'] = 'mysql';
require_once('/usr/local/lib/s9y/include/functions.inc.php');
require_once('/usr/local/lib/s9y/serendipity_config.inc.php');
If I remove the call to functions.inc.php, its also apparent that its not loaded directly from serendipity_config because it errors out with missing functions.
I was not suggesting functions.inc.php should be called after compat.inc.php. Is functions.php loaded in the main s9y app from a global level, before serendpity_config is loaded?
I hope that clears up what i'm attempting to do, if not let me know.
Posted: Tue Jan 23, 2007 3:08 pm
by garvinhicking
Hi!
Hm, I just check the serendipity_config.inc.php - it bails out and does not load the functions file because IS_installed = false.
I'm afraid I currently have no solution to the problem. If we use include_once, we will impact the performance on all s9y installations so that the functions file cannot be cached pretty well by bytecode caches. On the other hand, not all s9y installations have bytecode caches and then the impact would also be below 1%.
Then, if I do not use the include_once patch, your installer won't work. However, not all people need that installer.
So no matter what I do, I hurt one part of the public. Sadly I can also not introcude if() checks before the include code call, because doing so will have the same impact like include_once.
Well, I hate maintaining software at times like these.
