I have an issue updating SVN from within PHP. It was working fine then suddenly stopped working a few days ago.
I am running PHP-FPM 5.5 through Nginx. SVN version is 1.8.8.
The code:
exec("svn cleanup $path");
exec("svn revert $path -R");
exec("svn update $path --accept theirs-full --non-interactive", $output, $return);
echo "Return: $return\nOutput: ".print_r($output, true)
Output:
Return: 1
Output: Array
(
)
When I run this in terminal (under the same user as PHP-FPM and Nginx), I get the expected output:
Updating '/path/to/app':
At revision 100
PHP CLI also works with the correct output (under same user as PHP-FPM and Nginx):
php5 /path/to/app/svnupdate.php
Based on this it seems to be specifically an issue with PHP5-FPM exec on svn. But how can I debug this and figure out what is wrong?
Thanks.
Updates from comments to keep everything together: Tried the proc_open approach, running only "svn cleanup $path" via that failed and caused all files to lock. running same command under same user in terminal worked fine and unlocked all files again.
Tried full path to svn bin, no difference
Running "svn info $path" seems to work fine, no files were locked. The following commands all fail in php exec/proc_open (without any error message or output) and lock the app files:
- svn cleanup $path
- svn revert $path -R
"svn update $path" returns "Updating '$path'" but stops there, previously the current build number would be returned on a second line.
I have a 2nd setup with a different app and svn server but running the same version OS and all software, this one is working fine. I think that rules out software.
i tried rolling the issue server back to a version from 2 months ago when it was working, the server automatically updates software and app on launch but should not have touched config files or cache. After it was available it was still showing the same issue. Fairly sure that rules out software config files/cache.
Which leaves only app codebase and svn server as a possible cause. I'll try resetting the svn server next and redoing the svn project.
Update 2: Recreated the project on the SVN server, remove application from app server and all svn config directories, checked out the new project from SVN server (build 1). Still the same error. !_!
Update 3: After doing all of the above i concluded that left only the file base that could be causing the issue. And it was, there was a "Can't convert string from native encoding to 'UTF-8':" error being thrown by SVN because of a few files with special characters in the filename. Interestingly the error only stopped the process when running from php-fpm and not in terminal. NO IDEA WHY. I added export LC_CTYPE=en_US.UTF-8; to the exec command and now it is working fine.
exec("export LC_CTYPE=en_US.UTF-8; svn update $path",$output);
svnisn't in the path, try using the full path to the executable.$pathis correct?$pathvariable itself is populated correctly. Maybe it's not being passed through? Can you log it -echo $path;?