News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

$_ENV error.

Started by Bonk, December 06, 2005, 12:48:55 PM

Previous topic - Next topic

Bonk

Running SMF 1.0.5 on php 5.1.1 with APC 3.0.8 on apache 2.0.55.

I started getting this error in my apache logs a few days ago:

Quote
PHP Notice:  Undefined variable: _ENV in \\forum\\Sources\\QueryString.php on line 134

QueryString.php around line 134:

// Clean up after annoying ini settings.  (magic_quotes_gpc might be off...)
if (get_magic_quotes_gpc() == 0)
{
// E(G)PCS: ENV, (GET was already done), POST, COOKIE, SERVER.
$_ENV = addslashes__recursive($_ENV);
$_POST = addslashes__recursive($_POST);
$_COOKIE = addslashes__recursive($_COOKIE);
$_SERVER = addslashes__recursive($_SERVER);

// FILES work like this: k -> name -> array.  So be careful.
foreach ($_FILES as $k => $dummy)
$_FILES[$k]['name'] = addslashes__recursive($_FILES[$k]['name']);
}


Also getting this error periodically on the forums:
Quote
An Error Has Occurred!
2: call_user_func() [<a href='function.call-user-func'>function.call-user-func</a>]: First argument is expected to be a valid callback
File: \forum\index.php
Line: 119 

line 119 of index.php:

// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());


This started when I installed APC 3.0.8, but that same day I removed a php5ts.dll from the windows system32 folder placed there by the Zend Optimiser when I tested it on php 5.1.0. I removed this unnecessary copy of the dll because php5.1.1 was reporting itself as php5.1.0 in the phpinfo function. removing the dll from the system32 folder corrected this (as I read in the php bugs database).

The following script:

<?php
var_dump
($_ENV);
?>



Does not produce the undefined $_ENV error as QueryString.php does.

Thoughts?

edit: for reference the php 5 changelog: http://www.php.net/ChangeLog-5.php#5.1.1

edit#2: the windows server 2003 this is running on has not been rebooted since the install/uninstall of the Zend Optimiser and dll deletion... damn Zend Optimiser...  >:(  I am waiting for our onsite admin to reboot the box...

Oldiesmann

I'm not sure why $_ENV would be undefined there, but if you enable magic_quotes_gpc in php.ini, that section of code won't be executed...

The other error is most likely due to an incomplete file in the Sources directory. Try re-uploading everything in the Sources directory.
Michael Eshom
Christian Metal Fans

Bonk

Quote from: Oldiesmann on December 06, 2005, 03:55:50 PM
I'm not sure why $_ENV would be undefined there, but if you enable magic_quotes_gpc in php.ini, that section of code won't be executed...

From the code I figured that turning on magic_quotes_gpc would eliminate the error, but I never had them on before and never got this error.  I'm going to wait until the server can be rebooted before I try that.

Quote from: Oldiesmann on December 06, 2005, 03:55:50 PM
The other error is most likely due to an incomplete file in the Sources directory. Try re-uploading everything in the Sources directory.

I fail to understand how a file could be spontaneously and suddenly incomplete.  We have modified some of the sources files and have many mods installed that the users and moderators depend on. So I would rather not do that. I will inspect the date modified on all the sources files and inspect them for spontaneous and mysterious truncation.

Thanks for the reply!

Bonk

Just occurred to me that since the call_user_func() error I'm getting is intermittent (forgot to mention) that it is not likely due to a spontaneously truncated file.  (still don't know how that could happen unless SMF writes back to the sources files in the normal course of operation outside upgrades or mods from the package manager...)

Bonk

Well instead of waiting for the onsite admin to reboot the box, I tested my theory by replacing the dlls Zend Optimiser had put in the windows system folder and restarting apache - the $_ENV error persisted, so that was not it. I tested the $_ENV vars outside SMF, they were fine - no error. So I just turned on magic_quotes_gpc in the php.ini to placate SMF. This eliminated the $_ENV error. So no reboot necessary.

I suspect this is a quirk of running SMF under php 5.1.1 / APC 3.0.8. Since the $_ENV var error is no longer ocurring, I suspect the intermittent callback error wil disappear as well...

Bonk

QuoteAn Error Has Occurred!
2: call_user_func() [<a href='function.call-user-func'>function.call-user-func</a>]: First argument is expected to be a valid callback
File: \forum\index.php
Line: 119 

This error persists, I will continue to look for a cause... I am beginning to suspect a bug in APC...

Bonk

It seems to me that the use of:
Quote
// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

in SMF 1.0.5 is not consistent with the php documentation:
http://ca.php.net/manual/en/function.call-user-func.php


The hint is:
QuoteFirst argument is expected to be a valid callback

There seems to be only one argument here...

Bonk

Though I do see one example of the use of the function like:
QuoteIf you need to call ordinary function:
call_user_func('funcFoo');


I checked all the files in my sources directory, none of them have been mystically-magically truncated, all are complete, the latest modiciation of the files was November 7th. This error only started appearing a few days ago. It happens to correspond with my installation of APC... I suspect it may be a bug there, or perhaps APC is fussy about this on windows. (there were warnings in the build about signed/unsigned mismatches)

I updated to my build of apache 2.2.0 and the corresponding php5apache2 module today, it does not seem to have affected things.

I am going to try modifying the index php line 119 to:
call_user_func('smf_main');
to see if that helps.

If not I guess I'll have to dump APC and if that fixes it I'll just wait until eAcclerator manages to produce a php 5.1.x compatible version and go without caching until then...

Bonk

Nope, it does not like:
call_user_func('smf_main');
or
call_user_func('smf_main()');
at all.

The first try produced an unable to find template 'main' error. The second produced the above callback error consistently, with no template, just the text of the error.

Bonk

I just tried turning on magic_quotes_runtime to see if the error persists.

Bonk

Nope, that didn't do it, gonna turn them back off and disable APC...  :(

Bonk

I turned magic_quotes_gpc and magic_quotes_runtime back off in the php ini and disabled APC, the installation of which corresponded to the start of these errors. I think that will fix it, though our forums will be a bit slower until a new version of eAcclerator is released that is compatible with php 5.1.x.

Pretty sure APC was the cause of both errors.

Advertisement: