Re: factory broken
| From: | Cynic | Date: | Sat, 04 Aug 2001 13:56:00 +0000 |
| Subject: | Re: factory broken | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-1290@lists.php.net to get a copy of this message | ||
Zeev committed a fix, so that include_once() and require_once()
will return true in cases when the file isn't included because
it was included earlier. So I guess this is void.
zeev Thu Aug 2 20:27:19 2001 EDT
Modified files:
/Zend zend_execute.c
Log:
require_once()/include_once will return true in case a file was not included
because it was already included earlier.
Changed the default return value type of the include() family from long to
boolean
At 20:24 8/1/2001, mailling@bigfoot.com wrote the following:
--------------------------------------------------------------
>I already sent this message to this list, but I got no answers/comments, so I decided to send it
>again.
>Either I am wrong, or every factories are broken. So comments would be appreciated.
>
>--
>I am using php 4.0.6, so this issue may be recent.
>
>Let's say I do that
>$a=include_once 'HTML/menu.php';
>$b=include_once 'HTML/menu.php';
>Then $a=true but $b=null/false
>
>That means that every code that has a method factory is not working rigth
>Indeed, we have that:
>
>function factory ($log_type, $log_name = '', $ident = '', $conf = array()) {
> $log_type = strtolower($log_type);
> $classfile = 'Log/' . $log_type . '.php';
> if (@include_once $classfile) {
> $class = 'Log_' . $log_type;
> return new $class($log_name, $ident, $conf);
> } else {
> return false;
>...
>
>The problem is that the first factory will work fine, but the other will fail: (return false,
>instead of the new instance)
>We will get a false for the include_once, so a false from the factory.
>I think we have to replace everywhere
>
>if (@include_once $classfile) {
> $class = 'Log_' . $log_type;
>...
>By:
>@include_once $classfile;
>$class = 'Log_' . $log_type;
>if (class_exists($class)) {
>...
cynic@mail.cz
-------------
And the eyes of them both were opened and they saw that their files
were world readable and writable, so they chmoded 600 their files.
- Book of Installation chapt 3 sec 7