Jump to content

include() vs include_once() in Admin section.


bsmither

Recommended Posts

I've noticed that the code in 3.0.16 has include_once() most everywhere except in almost all the files in the admin folder.

I'm trying to troubleshoot a "Fatal Error: Cannot Redeclare unsetGlobals ..." error immediately after I successfully log in.

So far, if I put a echo"Hello";die(); before line 29 in the login.php, I get the Hello. If I put it after line 29, I get the Fatal Error. So somehow, ini.inc.php is getting called twice - which it is, once through admin/index.php and again through admin/login.php.

My research suggests that PHP 4 doesn't care. And CC3.0.15 with PHP 5.1.4 seems to be working fine (installed on a dev server). But on another dev server (WinXPSP2 with Abyss Web Server X1 v2.4) running CC3.0.16 and PHP 5.2.3, I get these Fatal Errors.

So, examining the code and placing echo/die at places where I want the thing to stop in the admin section, I see lots of include() and very few include_once().

Before I do a global replace of include("../includes/ini.inc.php") with include_once, I would like to know if the programmers had a specific reason to keep the include() construct instead of universally changing it to include_once(). And is there any comment as whether this global replace will even work?

Other research suggest wrapping (something like) IfExists("unsetGlobals") around the function declaration, but that only solves that function - until the next is stumbled upon. Wouldn't using include_once() be the more elegant programming fix?

Now, I realize I have yet to discover the exact reason why I am having this problem: code changes in the PHP engine, Zend optimization, CC 15 vs 16, or the fact that it's July in Colorado -- I don't know.

...a global replace of include("../includes/ini.inc.php") with include_once...

Well, that didn't work. Still got the fatal error.

So I commented out line 29 in login.php and didn't get the error for unsetGlobals. But I did get another Fatal Error: Cannot redeclare detectssl() in /includes/functions.inc.php.

Will keep on experimenting.

Link to comment
Share on other sites

Why not put in a support ticket...

Would if I could.

I went ahead and wrapped each function definition block in a if (!function_exists()) test. I don't get any more Fatal Errors..., I don't get anything at all. Just Firefox burning up 15% CPU power waiting for the host to deliver something.

I'm going to see if I can find a PHP 5.1.2 installation package and see if that makes any difference.

Link to comment
Share on other sites

CC 3.0.16 works under PHP 5.1.2 while under PHP 5.2.3, it doesn't (according to my experiments).

I still have all the wrappers around the function definition blocks, and I'll test with original files shortly.

Can we get a poll started as to what's the latest version of PHP that CC 3.0.16 successfully runs under?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...