php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33901 RecursiveDirectoryIterator gives different response depending on CLI or ISAPI
Submitted: 2005-07-28 13:04 UTC Modified: 2005-07-28 16:43 UTC
From: richard dot quadling at bandvulc dot co dot uk Assigned:
Status: Closed Package: SPL related
PHP Version: 5.0.4 OS: Windows XP SP2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
44 + 28 = ?
Subscribe to this entry?

 
 [2005-07-28 13:04 UTC] richard dot quadling at bandvulc dot co dot uk
Description:
------------
I have a script which is using the nice new SPL RecursiveDirectoryIterator.

The iterator is being asked to look at files which reside on another computer which is accessed via a drive mapping.

In terms of permissions, I have full access to the mapping.

The webserver is running with my credentials. I am using Sambar Server with php V5.0.4 ISAPI.

The script below gives a different response when using CLI and web (See results below).

I do have 2 different php.ini files - php-cli.ini and php-isapi.ini

The only difference between them is html_errors is On for the ISAPI version and Off for the CLI version and the phpmanual is NOT shown for the CLI version.

I've tried using the full UNC path to the directory and this works in both CLI and ISPAI mode. The line below works in both CLI and ISAPI modes.

$objRDI = new RecursiveIteratorIterator(new filterAutomatedEarnieIQBackup(new RecursiveDirectoryIterator("\\\\BANDACCESS\\IQ Backup")));


Reproduce code:
---------------
<?php
abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator
	{
	private $ref;

	function __construct(RecursiveIterator $it)
		{
		$this->ref = new ReflectionClass($this);
		parent::__construct($it);
		}

	function hasChildren()
		{
		return $this->getInnerIterator()->hasChildren();
		}

	function getChildren()
		{
		return $this->ref->newInstance($this->getInnerIterator()->getChildren());
		}
	}

class filterAutomatedEarnieIQBackup extends RecursiveFilterIterator
	{
	function accept()
		{
		return $this->getInnerIterator()->isFile() && (strpos($this->getInnerIterator()->getFilename(), 'AutomatedEarnieIQBackup') !== False);
		}
	}

$objRDI = new RecursiveIteratorIterator(new filterAutomatedEarnieIQBackup(new RecursiveDirectoryIterator("K:\\IQ Backup")));
foreach($objRDI as $sPath => $sFile)
	{
	echo number_format(filesize($sPath)) . " {$sPath}<br />\n";
	}
?>

Expected result:
----------------
249,648,640 K:/IQ Backup/AutomatedEarnieIQBackup20050728101148<br />


Actual result:
--------------
Fatal error: Uncaught exception 'Exception' with message 'DirectoryIterator::__construct(K:/IQ Backup) [function.--construct.html]: failed to open dir: Invalid argument' in D:\Data\Web Sites\Quick Scripts\public_html\Test_SPL_Iterator.php:31 Stack trace: #0 D:\Data\Web Sites\Quick Scripts\public_html\Test_SPL_Iterator.php(31): RecursiveDirectoryIterator->__construct('K:/IQ Backup') #1 {main} thrown in D:\Data\Web Sites\Quick Scripts\public_html\Test_SPL_Iterator.php on line 31

Fatal error: Unknown: The inner constructor wasn't initialized with an iterator instance in Unknown on line 0


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-07-28 16:30 UTC] sniper@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 [2005-07-28 16:43 UTC] richard dot quadling at bandvulc dot co dot uk
What was fixed? CVS for the ext/spl shows no changes.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 16:01:29 2024 UTC