ZF-5024: Symlink function fail causes Zend_OpenId_Consumer to fail
Description
This really took me hours to figure out. I tried to verify myself with OpenId and it was working fine on server A but not on server B while the script is the same, including PHP version (5.2.6). I debugged my *ss of to find out why the verify function was failing me and it all came down to 1 small function: symlink.
This is the piece of code in Zend_OpenId_Consumer_Storage_File in the function addAssociation:
if (function_exists('symlink')) {
symlink($name1, $name2);
} else {
$f2 = @fopen($name2, 'w+');
if ($f2) {
fwrite($f2, $data);
fclose($f2);
}
}
The symlink function does exist but it returns false and thus the assoc_handle_{hash} file isnt written to the filesystem which causes the getAssociationByHandle function to fail during the verification process. After removing the symlink part (so it would always use the fopen/frwite/fclose functions) everything was working like a charm. So, maybe its a good thing to add an extra check if the symlink function really worked.
Comments
Posted by Dmitry Stogov (dmitry) on 2008-12-01T02:27:22.000+0000
What operating system do you use?
Posted by R Slootjes (rslootjes) on 2008-12-01T03:57:32.000+0000
Im running CentOS5 with PHP5.2.6
Maybe important to know: im running suPHP and I've patched PHP with the wellknown Suhosin patch.
Posted by Tomáš Fejfar (tomas.fejfar@gmail.com) on 2012-05-10T19:31:27.000+0000
Same problem occurs on Windows (PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20)), because you need superuser priviledges to create symlinks.
```
Removing the symlink part fixes it for me. It looks like the symlink is only improvement, not requirement. I suggest removing it. It's not fatal error, but it emits a warning
Posted by Tomáš Fejfar (tomas.fejfar@gmail.com) on 2012-05-10T19:31:56.000+0000
Patch that removes the symlink logic from storage class
Posted by Rob Allen (rob) on 2012-05-17T21:08:39.000+0000
Applying patch causes unit test failures:
Posted by Tomáš Fejfar (tomas.fejfar@gmail.com) on 2012-05-19T11:39:51.000+0000
I'll try to look at it and compare OSX vs. Win but I'm not sure it will be ready for 1.12. as I'm pretty busy now :(