Skip to content
Snippets Groups Projects
Verified Commit 2d3ba9d1 authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

fix: prevent infinite loop on errors

parent 8031f26f
Branches
Tags
1 merge request!5feat: remove compilation command
Pipeline #448703 passed with warnings
...@@ -92,10 +92,10 @@ final class Kernel { ...@@ -92,10 +92,10 @@ final class Kernel {
return preg_replace( '/[^\w_]/', '_', implode("_", [ $plugin->get_slug(), $plugin->get_version(), 'container' ]) ); return preg_replace( '/[^\w_]/', '_', implode("_", [ $plugin->get_slug(), $plugin->get_version(), 'container' ]) );
} }
private function initialize_container( Plugin $plugin, bool $useCache = true ): Container { private function initialize_container( Plugin $plugin, bool $use_cache = true ): Container {
$original_builder = new DiBuilder(); $original_builder = new DiBuilder();
if ( $this->is_prod() && $useCache ) { if ( $this->is_prod() && $use_cache ) {
$original_builder->enableCompilation( $original_builder->enableCompilation(
$this->get_cache_path(), $this->get_cache_path(),
$this->get_container_name( $plugin ) $this->get_container_name( $plugin )
...@@ -114,7 +114,12 @@ final class Kernel { ...@@ -114,7 +114,12 @@ final class Kernel {
try { try {
return $builder->build(); return $builder->build();
} catch ( \Exception $e ) { } catch ( \InvalidArgumentException $e ) {
if ( $use_cache === false ) {
// It means, that saving to disk was not an issue.
throw $e;
}
return $this->initialize_container( $plugin, false ); return $this->initialize_container( $plugin, false );
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment