ZF-6687: Zend_Tool_Framework_Loader_Abstract class is raised lots of warnings in load method. (Zend_Tool_Framework_Loader_Abstract::load)
Description
To reproduce this bug install the zf from zfcampus.org by using pear installer.
Then just run a zf command which is the cause of tons of warnings.
Warnings is generated by include_once function in Zend_Tool_Framework_Loader_Abstract::load method when it tries to include all the files it find in include_path.
To avoid this problems: just set @ before the include_once function, but probably framework developers should pay more attention to this problems.
Affected code fragment with fixed error:
// loop through files and find the classes declared by loading the file
foreach ($this->_retrievedFiles as $file) {
$classesLoadedBefore = get_declared_classes();
$oldLevel = error_reporting(E_ALL | ~E_STRICT); // remove strict so that other packages wont throw warnings
// should we lint the files here? i think so
@ include_once $file;
error_reporting($oldLevel); // restore old error level
$classesLoadedAfter = get_declared_classes();
$loadedClasses = array_merge($loadedClasses, array_diff($classesLoadedAfter, $classesLoadedBefore));
}
Comments
Posted by Ralph Schindler (ralph) on 2009-06-28T16:19:56.000+0000
Can you provide the warnings produced in a comment here?
Thanks, Ralph
Posted by Giorgio Sironi (giorgiosironi) on 2009-07-22T00:32:20.000+0000
I get the same type of error repeated many times. I am on php 5.3.0 however.
Warning: include_once(): Failed opening '/usr/local/lib/php/PHPUnit/TextUI' for inclusion (include_path='/media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/library:.:/usr/local/lib/php') in /media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/library/Zend/Tool/Framework/Loader/Abstract.php on line 90
Call Stack: 0.0005 335828 1. {main}() /media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/bin/zf.php:0 0.0169 829996 2. Zend_Tool_Framework_Client_Console::main() /media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/bin/zf.php:77 0.0170 830600 3. Zend_Tool_Framework_Client_Abstract->dispatch() /media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/library/Zend/Tool/Framework/Client/Console.php:86 0.0170 830600 4. Zend_Tool_Framework_Client_Abstract->initialize() /media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/library/Zend/Tool/Framework/Client/Abstract.php:192 0.0198 944160 5. Zend_Tool_Framework_Loader_Abstract->load() /media/sdb1/giorgio/vendor/ZendFramework-1.8.4PL1/library/Zend/Tool/Framework/Client/Abstract.php:101
This stack trace is repeated for every subdirectory in my include_path, /usr/local/lib/php. It seems that the IncludePathLoader/RecursiveFilterIterator class is correctly filtering out phpunit files but not directories.
Posted by Giorgio Sironi (giorgiosironi) on 2009-07-22T01:04:08.000+0000
Quick fix.
Posted by Giorgio Sironi (giorgiosironi) on 2009-07-22T01:06:09.000+0000
IncludePathLoader::_getFiles() returns the directories from the Pear installation. I attached a quick fix to exclude all directories not filtered since it is not possible to include_once a directory.
Posted by Gordon Forsythe (baohx) on 2009-07-30T14:34:36.000+0000
Having this issue as well. PHP5.3. The patch works. Hopefully this will go into 1.9 soon.
Posted by Grover Manuel Campos Ancajima (gmanuel) on 2009-09-02T14:59:20.000+0000
I think the solution is other, in load method:
Change this line:
For this:
In order get the error_reporting of php.ini and don't setup an arbitrary error_reporting code.
Posted by Ralph Schindler (ralph) on 2009-10-16T22:25:38.000+0000
Marking as not an issue. In 1.10, the behavior will be to NOT use the includePathLoader which has been causing all sorts of issues.
IN this issue, the problem is that the current user does not have the correct permissions to traverse directories, and as such, directories are being returned to be incldued (which is bad behavior).
In 1.10, we willl default to what is called the "BasicLoader" (this is already in incubator and working). This is a better approach as it will only load what it is told to load. Developers will be able to extend Zend_Tool via the config (ini) file for Zend_Tool, another featuer that is part of 1.10.