|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58704 svn_mkdir does not work
Submitted: 2009-05-25 12:56 UTC Modified: 2010-03-01 01:41 UTC
From: nirav at mehtanirav dot com Assigned:
Status: Closed Package: svn (PECL)
PHP Version: 5.2.6 OS: Mac OS X 10.5.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: nirav at mehtanirav dot com
New email:
PHP Version: OS:


 [2009-05-25 12:56 UTC] nirav at mehtanirav dot com
svn_mkdir returns true, but does not create a directory in the local repository. 

Tested only with local repository using file:/// on Mac OS X. Command line SVN client works without a problem. 

Pasting an excerpt below. Essentially, I try and see if my target directory exists. If it does not, it means it's not even in repository (in my case). So I create a new directory for it. Right after that, I try to checkout the newly created directory. 

These steps work fine if done from command line.

Doing them from PHP returns true on svn_mkdir, but gives warning and fails.

I recompiled the PECL extension with svn_client_mkdir3 (based on, since I have SVN 1.5, but that too did not work.

Reproduce code:
if (!is_dir($this->docFolder))
  $newFile = true;
  //TODO: Does svn_mkdir require a commit? What to commit then?
  if (true !== svn_mkdir($this->svnDocFolder))
  echo "Error creating SVN Folder";
  return false;
if (!is_dir($this->docFolder. '/.svn'))
  $newFile = true;
  svn_checkout($this->svnDocFolder, $this->docFolder);

Expected result:
Expected that svn_checkout will work, and "svn list file:///repo/location" would show the newly created folder.

Actual result:
Warning: svn_checkout() [function.svn-checkout]: svn error(s) occured 170000 (Bad URL passed to RA layer) URL 'file:///Users/niravmehta/Projects/revisionTracking/docsrepo/1381' doesn't exist in /Users/niravmehta/Projects/Name/classes/SVNDocument.php on line 120


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-05-25 13:01 UTC] nirav at mehtanirav dot com
While they work on fixing this, here's an alternate that could get your job done. This function requires svn command line executable, and permission to exec().

function svn_mkdir2($url)
  $out = array();
  $ret_var = null;
  $cmd = '/usr/bin/svn mkdir --non-interactive -m \'Creating new directory\' '.$url.' 2>&1';
  exec($cmd, $out, $ret_var);
  if($ret_var > 0)
    echo 'Error creating new directory '.$url.': '.join(' ', $out);
    return false;
  return true;
 [2009-06-07 01:31 UTC] jeff at clarkmania dot com
2cents here, but I believe the function is working as intended.  You need to create the directory on the filesystem, then call svn_mkdir.

Also, nothing ever shows up in the repository until you issue a commit.  That said, the methods you use in your "reproduce code" are incorrect.
 [2009-06-08 00:26 UTC] nirav at mehtanirav dot com
Thanks for your comments Jeff.

svn_mkdir manual ( says that it can create a directory in working copy or the repository. What I am trying to do is create a directory in the repository.

My situation requires that I create a directory in the repository first and then check it out to a working copy. In my case, I only checkout parts of a repository, not the full repository. Hence I can't create a directory in working copy, add it to svn and then commit.

SVN command line utility can create a directory in the repository directly. And that is the expected behavior from the PHP extension.

So this is still a bug!
 [2010-02-27 22:34 UTC] darwin_duck at yahoo dot com
You can't create a directory on repository because the svn_mkdir function do not set a log message, but this message is required. If you apply my patch ( the svn_mkdir function will works fine. Probably this same problem will occours in svn_delete function when you try delete a directory on a repository.
 [2010-03-01 01:41 UTC] alan at akbkhome dot com
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Mon Nov 29 03:03:16 2021 UTC