Re: testing pear part one
| From: | robert janeczek | Date: | Sat, 01 Jun 2002 14:00:50 +0000 |
| Subject: | Re: testing pear part one | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-6697@lists.php.net to get a copy of this message | ||
> Hey guy, start to learn - I know what I'm talking about :).
failed :] np-completness, it is 3rd year i try to pass it, i think i`ll
finish my studies and it still won`t be passed ;)
> Good point. I did not know until now that it's necessary (/me has no
> Windows PHP).
i`m to lazy to switch to linux ]:)
> It's still in php4/pear/File/.
yes, no i see it :)
> It looks like isLocked() has been added by Mika Tuupola in revision
> 1.10, which apparently didn't make it's way into PHP 4.2.1 :(.
>
> Yup, it should be actually :). Please get the latest version of
> File/Passwd.php from CVS and try again.
so i tried :)
file: i downloaded latest file/passwd.php from cvs [Passwd.php,v 1.10
2002/04/17 14:41:37] and there are some serious problems:
Auth_Container_File::Auth_Container_File() constructs new file_passwd object
with lock set to 0 (no lock file is created), then 'locked' variable is set
from code, but it doesn`t work as it seems to - someone surely wanted to
crate lock file, but only by setting variable he gets nothing except file
access errors. line 65 should be changed to '$this->pwfile->lock();' - this
CREATES file and locks it. constructors end lines changed to this:
$this->pwfile->lock();//primary locking
$this->pwfile->close();//this saves file and UNLOCKS!
$this->pwfile->lock();//this lock is needed to operate properly on data
(adding users etc)
my point is that Auth/Container/file.php has many more places like this
where lock isn`t being made where it is needed. code reanalyzing is needed -
for now it doesn`r seem to work without changes in code, i fixed some
methods by myself - i can commit them, i just wanted to know if someone has
an explanation on this locking mess :)
file_passwd has some errors too: if we are working on empty passwd file than
its users variable isn`t array and this causes errors in foreach (in close
method). so:
- file_passwd constructor - lines somewhere after 100 (it may be not quite
exact ;]):
$this->users = array();//added this line
while(!feof($fp)) {
$line = fgets($fp, 128);
- close() method - i needed to change a little bit order of function calls
here to avoid file i/o error messages:
unlink($this->filename);//everything seems to be in internal $users
array - isn`t it there?
flock($this->fplock, LOCK_UN);//unlock is needed to rename file, it seems
so on w2k... am i wrong?
$this->locked = false;
fclose($this->fplock);
rename($this->lockfile, $this->filename);
of corse - there is a moment (larger than in cvs version) where no file has
passwords - is it dangerous already?
rash