Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.4.1

Bug #240 mkdir() with $recursive===true doesn't support "single" directories
Submitted: 2003-11-13 19:30 UTC
From: me at mkone dot net Assigned: toby
Status: Closed Package: Net_FTP
PHP Version: 4.3.3 OS: Suse Linux
Roadmaps: (Not assigned)    
Subscription  


 [2003-11-13 19:30 UTC] me at mkone dot net
Description: ------------ If mkdir() is set up with recursive directory creation and only a simple directory is given, this directory is not be created. The problem seems to be here: [Line 290 FTP.php] while (false !== ($pos = strpos($dir, '/', $pos + 1))){ $elements[] = substr($dir, 0, $pos); } $elements is empty after that, instead of having one element. Reproduce code: --------------- $chk = $test->mkdir('path', true); var_dump($chk); Expected result: ---------------- bool(true) and directory 'path' existing on host Actual result: -------------- bool(true) directory 'path' does NOT exist

Comments

 [2003-12-31 10:48 UTC] chip at php dot net
Patch should Fix this bug. Also will now properly return an error if a subfolder in a recursive mkdir failed. --- FTP.php.dist 2003-12-31 10:42:16.000000000 +0000 +++ FTP.php 2003-12-31 10:50:56.000000000 +0000 @@ -283,13 +283,17 @@ return true; } } else { - $pos = 0; + if(strpos($dir, '/') === false) + return $this->mkdir($dir,false); + $pos = 0; $elements = array(); while (false !== ($pos = strpos($dir, '/', $pos + 1))){ $elements[] = substr($dir, 0, $pos); } foreach ($elements as $element){ - $this->mkdir($element, false); + $res = $this->mkdir($element, false); + if($res !== true) + return $res; } return true; }
 [2004-03-14 12:57 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!