]> granicus.if.org Git - php/commitdiff
Fix a problem when list-installed is called in a new installation
authorTomas V.V.Cox <cox@php.net>
Tue, 9 Apr 2002 13:11:51 +0000 (13:11 +0000)
committerTomas V.V.Cox <cox@php.net>
Tue, 9 Apr 2002 13:11:51 +0000 (13:11 +0000)
pear/PEAR/Registry.php

index 5dd24037b1408e2df7ba90c631f41195d2a8ee52..a6c2373baa80f04ae7a6508734549c9fadea7ff9 100644 (file)
@@ -215,8 +215,14 @@ class PEAR_Registry extends PEAR
         if (PEAR::isError($err = $this->_assertStateDir())) {
             return $err;
         }
+        $open_mode = 'w';
         // XXX People reported problems with LOCK_SH and 'w'
-        $open_mode = ($mode === LOCK_SH) ? 'r' : 'w';
+        if ($mode === LOCK_SH) {
+            if (@!is_file($this->lockfile)) {
+                touch($this->lockfile);
+            }
+            $open_mode = 'r';
+        }
         $this->lock_fp = @fopen($this->lockfile, $open_mode);
         if (!is_resource($this->lock_fp)) {
             return $this->raiseError("could not create lock file: $php_errormsg");