Index: ours/phpbb/includes/functions_messenger.php =================================================================== --- ours/phpbb/includes/functions_messenger.php (revision 231) +++ ours/phpbb/includes/functions_messenger.php (working copy) @@ -653,9 +653,15 @@ // on the assumption that the winning process created it if (!$lock_fp && $mode == 'wb') { - $lock_fp = @fopen($this->cache_file . '.lock', 'rb'); + // Assign to $mode for the check in chmod below + $mode = 'rb'; + $lock_fp = @fopen($this->cache_file . '.lock', $mode); } - @chmod($this->cache_file . '.lock', 0666); + if ($lock_fp && $mode == 'wb') + { + // Only need to set mode when the lock file is written + @chmod($this->cache_file . '.lock', 0666); + } if ($lock_fp) { @flock($lock_fp, LOCK_EX);