ID:          35811
 Updated by:  [EMAIL PROTECTED]
 Reported By: csaba at alum dot mit dot edu
-Status:      Open
+Status:      Assigned
 Bug Type:    Scripting Engine problem
 PHP Version: 5.1.1
-Assigned To: 
+Assigned To: dmitry
 New Comment:

Dmitry, good luck trying to interpret whatever the problem is supposed
to be. I still don't see any bug here..


Previous Comments:
------------------------------------------------------------------------

[2005-12-27 23:20:21] csaba at alum dot mit dot edu

I start off with: The named auto_prepend_file should act as either a
prepended file (that is, a section placed at the beginning of the main
script) or as an include file (placed at the beginning of the main
script).  If this assumption about the intent of the auto_prepend_file
is incorrect, then sniper would be correct that there is merely a
documentation issue.

In effect, the way a script is run is that first the main script file
is parsed for syntax and (key point!) functions are defined, but the
script is not yet interpreted.  AFTER the parsing/definition phase the
script is interpreted (Script1 in the initial report demonstrates
this). Therefore, if include('includeMe.php') is at the beginning (or
anywhere else) of the main script, all the functions in the main script
should be defined before the script of includeMe.php is interpreted
(Script2 and includeMe.php demonstrate this).

That is to say: the consequence of my main assumption is that all
functions in the main script should be defined before the
auto_prepend_file script is interpreted.  However, this is not what
happens with auto_prepend_file=c:\path\to\includeMe.php.  The script in
includeMe.php is interpreted before the functions in the main script
file are defined (as Script3 in the initial report demonstrates).  This
contradics my initial assumption, which I feel indicates a php bug
rather than an error in my assumption.  That is to say, the
auto_prepend_file is not behaving as it is indended to, and I suggest
this behaviour should be corrected rather than the documentation merely
changed to reflect behaviour.  The use case in the initial report is
intended to bolster this argument.

Csaba

Perhaps auto_prepend_file does behave as the developers meant it to,
but then it doesn't seem consistent with the option name nor the spirit
of the documentation.  If the initial creator of the option had intended
it to behave as it is, would it not have made more sense to have picked
a name along the lines of auto_start or auto_preload or auto_load,
reflecting the intention more strongly?

  There's a documentation problem in any event, but shouldn't that wait
till the true intention of the option has been decided?  Thus, I hope
I'm not out of line in recategorizing this as a Scripting Engine
problem.

------------------------------------------------------------------------

[2005-12-27 14:58:24] [EMAIL PROTECTED]

I don't understand a word of this report so I assume it's documentation
issue. The ini option behaves just like it's meant to.

------------------------------------------------------------------------

[2005-12-27 01:42:33] csaba at alum dot mit dot edu

Description:
------------
auto_prepend_file in the php.ini file neither acts as if it prepends
the designated file nor as if it were included (as stated at
http://hu.php.net/manual/en/ini.core.php#ini.auto-prepend-file).

Specifically, if this were the case, then functions defined in the main
script would take precedence over functions defined in the
auto_prepend_file, but they do not.

Use case: It seems reasonable to define a standard library of all
functions available to all scripts under a php installation (through
the auto_prepend_file php.ini setting).  It also makes sense for select
scripts to be able to override these functions.  In a single .php file
(with no auto_prepend_file present), this would be accomplished as
follows with Script1:

<?php
if (!function_exists('showLine')) {
function showLine($letter) { print "First $letter.\n"; } }
showLine("B");
function showLine($letter) { print "Second $letter.\n"; }
?>

This produces no error, and an output of: Second B.  If the last line
is commented out, you would instead get: First B.



Moving the first two lines to includeMe.php:
<?php
if (!function_exists('showLine')) {
function showLine($letter) { print "First $letter.\n"; } }
?>

and invoking the following script2 leads to the same result:
<?php
include('includeMe.php');
showLine("B");
function showLine($letter) { print "Second $letter.\n"; }
?>


However, if php.ini's auto_prepend_file now points to includeMe.php and
the include statement is removed from script2 to yield script3, script3
will error with a duplicate function definition, which is what I am
reporting as improper behaviour.  Script3:
<?php
showLine("B");
function showLine($letter) { print "Second $letter.\n"; }
?>


Thanks,
Csaba Gabor from Vienna

Expected result:
----------------
My expectation for what the auto_prepend_file does is that it either
prepends the designated file to the main script, or treats it as having
been named by an include/require function as the 1st line of the script
(the difference is effectively whether the function definitions in the
auto_prepend_file are seen before the main script's function
definitions or not).

To be specific:  Remove, the first statement from the doc and have only
(with code to match): Specifies the name of the file to be parsed as if
it were called via an include construct at the very beginning of the
main script (so include_path is used).

Actual result:
--------------
The documentation at the page above claims two contradictory things: 
It says that auto_prepend_file is parsed before the main file, and it
says that the file is included as if it were called with the include()
function.

The current situation is that the auto_prepend_file is parsed
separately (before) the main script file (as opposed to prepended or
included), but the file name is placed onto the include file list (so
that it can no longer be include_once'd - see also:
http://bugs.php.net/bug.php?id=32924)


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=35811&edit=1

Reply via email to