[pmwiki-users] UserAuth2 - flock does not release lock?

ThomasP pmwikidev at sigproc.de
Tue May 29 23:30:36 CDT 2007


On Mon, May 28, 2007 23:42, Frank wrote:
> ...
>
> YEAH, that's it
> Now the user1 file contains the below things
> a:3:{s:6:"parent";s:5:"admin";s:16:"loginFromIpsOnly";a:0:{}s:5:"perms";a:1:{s:5:"admin";a:0:{}}}
>
> The error message is gone when adding a user. But if I call the
> Edit-field in the admin dialog, it is empty.
> I had a look to the error.log of Apache, that says:
> -> PHP Warning:  join() [<a href='function.join'>function.join</a>]: Bad
> arguments. in ApachePath\\cookbook\\userauth2\\userauth2-admintool.php
>
> ...
>
> I also removed the flock() in loadPermRecord_, now also the stored data
> are shown in the admin tool after clicking on Edit.
>

Thanks for the detailed information - that helped a lot. I have thougt
about it again, and it is definitely the flock() that makes the bug here.
Though the question from my last mail ("why are the flocks not released?")
remains (can you find out why? (*)), I can see that they are not
absolutely necessary - so I might remove them in a later version. (Both in
save_ and load_ have to be removed.)

The array warning shows that I still have to built in some error catching.

> btw I also tried to change the slashes, I changed the slashes into \ and
> \\. The first version showed some funny behaviour, the second worked the
> same wrong way as before.
> I think people familiar to PHP on windows can explain, I've not
> knowledge of PHP.
> I also moved the directory from cookbook to wiki.d, where definitely
> files can be written, but that had no effect.
>

Slashes and permissions were obviously not the actual cause - this would
anyway not produce empty files in the dirs.

Thomas

----
(*) Can you try a test code along the lines:

<?php
  $fp = fopen("test.txt", "r");
  if (flock($fp, LOCK_SH))
    echo "Could acquire lock.\n";
  else
    echo "Could not acquire lock.\n";
  if (flock($fp, LOCK_UN))
    echo "Could release lock.\n";
  else
    echo "Could not release lock.\n";
  $fp2 = fopen("test.txt", "r");
  if (flock($fp2, LOCK_SH))
    echo "Could acquire lock.\n";
  else
    echo "Could not acquire lock.\n";
  fclose($fp);
  fclose($fp2);
?>

Should result in that both times the lock can be acquired and in between
it can released. Same should happen if one replaces read operations by
write operations and (correspondingly) replaces LOCK_SH by LOCK_EX.

If this doesn't work, then configuration error or PHP bug.

Anyway, just experiment - not important for pmwiki.





More information about the pmwiki-users mailing list