ZF-5024: Symlink function fail causes Zend_OpenId_Consumer to fail


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);

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.


What operating system do you use?

Im running CentOS5 with PHP5.2.6

Maybe important to know: im running suPHP and I've patched PHP with the wellknown Suhosin patch.

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

Patch that removes the symlink logic from storage class

Applying patch causes unit test failures:

1) Zend_OpenId_ConsumerTest::testGetAssociation
Failed asserting that  is true.


2) Zend_OpenId_ConsumerTest::testAssociate
Failed asserting that  is true.


3) Zend_OpenId_ConsumerTest::testVerifyDumb
Failed asserting that  is false.


4) Zend_OpenId_Consumer_Storage_FileTest::testGetAssociation
Failed asserting that  is true.


5) Zend_OpenId_Consumer_Storage_FileTest::testGetAssociationByHandle
Failed asserting that  is true.


Tests: 54, Assertions: 796, Failures: 5, Errors: 2.

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 :(