Skip to content

Commit

Permalink
Bugfix: concurrent write of bootstrap/cache/packages.php (laravel#25012)
Browse files Browse the repository at this point in the history
When there is no bootstrap/cache/*.php, the php process will attemp to
build bootstrap/cache/packages.php, bootstrap/cache/services.php and
etc. If there are two or more php process doing the same thing, it is
possible for one of the process to read a *dirty*
bootstrap/cache/packages.php (not yet finish writing by another
process).

The solution add write and read lock to prevent read an *dirty*
packages.php and write a wrong services.php file.
  • Loading branch information
bbiao authored and taylorotwell committed Jul 30, 2018
1 parent 1d7163c commit 683637a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Illuminate/Foundation/PackageManifest.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ protected function getManifest()
$this->build();
}

$this->files->get($this->manifestPath, true);

return $this->manifest = file_exists($this->manifestPath) ?
$this->files->getRequire($this->manifestPath) : [];
}
Expand Down Expand Up @@ -166,7 +168,8 @@ protected function write(array $manifest)
}

$this->files->put(
$this->manifestPath, '<?php return '.var_export($manifest, true).';'
$this->manifestPath, '<?php return '.var_export($manifest, true).';',
true
);
}
}

0 comments on commit 683637a

Please sign in to comment.