K-Phoen / rulerz

Powerful implementation of the Specification pattern in PHP
MIT License
872 stars 96 forks source link

Issue with Compiler when deploying code #113

Closed jdeniau closed 5 years ago

jdeniau commented 5 years ago

Hi,

Sometime, when we deploy our code, we have the following error:

Uncaught PHP Exception Symfony\Component\Debug\Exception\ClassNotFoundException: 
"Attempted to load class "Executor_e54f2a89" from namespace "\RulerZ\Compiled\Executor". 
Did you forget a "use" statement for another namespace?"
 at /.../vendor/kphoen/rulerz/src/Compiler/Compiler.php line 47

If I read correctly, the compiled class is generated at runtime and is not written to disk (in fact, the bundle cache directory seems to be always empty).

Do you have any idea where it could come from ?

Thanks !

K-Phoen commented 5 years ago

Depending on your configuration, compiled rules are either evaluated on the fly or written on disk and required.

Assuming that you configured your application to write these classes on disk, I would bet on a bug in the NativeFilesystem class. Maybe, for some reason, the cache couldn't be written? I see that errors aren't handled... https://github.com/K-Phoen/rulerz/blob/5c26c4f99636e4e7e464f1b28c8054b059347534/src/Compiler/NativeFilesystem.php

Do you have a way to test that? (I guess that the NativeFilesystem class should throw errors)

jdeniau commented 5 years ago

Thanks for the hint, I investigate and on our servers the files are generated, but the "bug" do occur when we switch from one server to another.

The bug is ours apparently, I will investigate further though. Thanks for your answer !

Closing as it's not related to rulerz.

Leizhengzi commented 3 years ago

@jdeniau I have the same error, have you solved.

jdeniau commented 3 years ago

@Leizhengzi It's been a while now, I do not remember exactly where it did come from. It did probably came from our build system. Possibly the order of the cache warmup and deploy, but I do not remember more, sorry

Leizhengzi commented 3 years ago

@Leizhengzi It's been a while now, I do not remember exactly where it did come from. It did probably came from our build system. Possibly the order of the cache warmup and deploy, but I do not remember more, sorry

It's okay. Thanks for your answer!

fmartin-lafourchette commented 2 years ago

@Leizhengzi I have the same error sometimes (not during the deployment), have you solved your issue? Thanks a lot for your help.