File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change 1515use function count ;
1616use function error_reporting ;
1717use function explode ;
18+ use function fclose ;
19+ use function flock ;
20+ use function fopen ;
1821use function implode ;
1922use function in_array ;
2023use function is_dir ;
2932use function trim ;
3033use function unlink ;
3134use const E_USER_DEPRECATED ;
35+ use const LOCK_EX ;
36+ use const LOCK_UN ;
3237use const PHP_RELEASE_VERSION ;
3338use const PHP_VERSION_ID ;
3439
@@ -74,6 +79,15 @@ public function getContainerCacheDirectory(): string
7479 #[Override]
7580 public function loadContainer (): string
7681 {
82+ $ directory = $ this ->getContainerCacheDirectory ();
83+ $ locked = false ;
84+ if ($ this ->journalContainer && is_dir ($ directory )) {
85+ $ lockFile = $ directory . '/container.lock ' ;
86+ $ handle = fopen ($ lockFile , 'c ' ); // @ is escalated to exception
87+ flock ($ handle , LOCK_EX );
88+ $ locked = true ;
89+ }
90+
7791 $ loader = new ContainerLoader (
7892 $ this ->getContainerCacheDirectory (),
7993 $ this ->staticParameters ['debugMode ' ],
@@ -95,6 +109,10 @@ public function loadContainer(): string
95109
96110 if ($ this ->journalContainer ) {
97111 $ this ->journal ($ className );
112+ if ($ locked ) {
113+ flock ($ handle , LOCK_UN );
114+ fclose ($ handle );
115+ }
98116 }
99117
100118 return $ className ;
You can’t perform that action at this time.
0 commit comments