Currently I\'m writing out files with php into a directory, I add that directory (works fine), then when i try and do an svn commit its not working nor returning any kind of err
Can you try throwing out the errors (read Mike's comment) status.
('cd '.$this->build_locations[$this->type].'; svn commit --username user --password pw; ls', $output, $error);
if($error){
print_r($error);
}
I would suggest to break the above into 3 separate commands for debugging purpose.
Also, if $this-type can be manipulated by the users, then your code is vulnerable as they can pass something like: .; cat /etc/passwd
, which becomes
$tmp = exec('cd .; cat /etc/passwd; svn commit --username user --password pw; ls', $output);
SVN command line errors go to stderr, not stdout, which is why you aren't able to see them. What you want to do is redirect stderr to stdout and then print_r($output)
to determine the cause of the error.
exec('svn commit <stuff> 2>&1', $output, $returnStatus);
if ( $returnStatus )
{
print_r($output);
}
Sample output:
Array
(
[0] => svn: Commit failed (details follow):
[1] => svn: '/path/to/<stuff>' is not under version control
)
This is not ideal because it mixes stderr with stdout when it would otherwise be unnecessary, but I don't know of another way to get the desired output in this case. If someone else does, please comment.
Note: The third parameter to exec(...) is the return status, not the error message, so you need to tweak your code accordingly for that as well.
If the error output after making the 2>&1
modification doesn't help solve the root cause of your problem, please post the new output here.
Edit after new information:
Did you upload this SVN working copy to your server from somewhere else? That would explain this error.
If I check out a working copy from my local repository, upload it to my remote server, and then try to commit, I get the same error.
If that's the case, you need to execute the "svn checkout" of the working copy on the server running the PHP script in order to be able to commit to it. If that server can't communicate with the repository's server, then that's a whole other problem.
AFAIK, after a svn commit
, if the -m
option is not provided, an editor opens up to type in the commit message. Try passing -m "Some commit message"
, maybe that'll help.