Comments (5)
Hi,
I'm currently facing this issue right now. After some debug, it turns out that this only occurs while working with Tinker.
It appears that the closure's body isn't saved correctly.
I'm using this library to store closures as models attributes, using a "Closure" cast.
No problem encountered handling those SerializableClosure during database seeding, we can clearly see this function section inside the serialized object :
"function";s:60:"function ($arg) { return $arg; }"
But when I manipulate an instance of this model inside Tinker :
>>> $m = MyModel::first();
=> App\Models\MyModel {...}
>>> $m->closure = function (int $a, string $b) { return "$a: $b"; };
<warning>PHP Warning: file_get_contents(eval()'d code): Failed to open stream: No such file or directory in /var/www/html/vendor/laravel/serializable-closure/src/Support/ReflectionClosure.php on line 805</warning>
=> Closure(int $a, string $b) {#4617 …2}
>>> $m->save();
=> true
the function field of the stored SerializableClosure is empty : "function";s:0:"";
, and cause the error message of this thread issue.
I've retried to update this model inside a test command, and everything works fine.
As mentionned by suhaboncukcu, it is probably due to the way Psy Shell terminal treat or cache these fields, so it is probably a missing feature rather than a bug.
from serializable-closure.
@suhaboncukcu The code example you gave, does not contain any code that would cause that issue. Are you able to clone this serialisable project locally, and try to reproduce your issue in test?
from serializable-closure.
I will re-open the issue once you answer.
from serializable-closure.
Sorry for the late reply. After further investigation, I found out the reason. For the future searchers; if you're using job_batches, loading a corrupted row on your batch table can fill your logs up with this error due to horizon requests for instance.
What I find strange is that whenever I run the above example on tinker
, I'm ending up in the same state. It basically adds a row which can't be unserialized correctly. This could also just about my terminal or zsh so I'm not sure if psy/psysh is causing this problem or not. In any case, package -indeed- doesn't seem to have any problems in regular usage.
from serializable-closure.
Hi,
I'm experiencing this error, too, although the only way I was able to replicate it was via tinker
as @suhaboncukcu mentioned.
bash-5.0$ php artisan tinker
Psy Shell v0.11.1 (PHP 7.4.12 — cli) by Justin Hileman
>>> dispatch(function(){info('yay');})->onQueue('yay');
=> Illuminate\Foundation\Bus\PendingClosureDispatch {#5635}
>>> dispatch(function(){info('yay');})->onQueue('yay');
<warning>ErrorException with message 'file_get_contents(eval()'d code): failed to open stream: No such file or directory'</warning>
>>> dispatch(function(){info('yay');})->onQueue('yay');
=> Illuminate\Foundation\Bus\PendingClosureDispatch {#5674}
>>> dispatch(function(){info('yay');})->onQueue('yay');
<warning>ErrorException with message 'file_get_contents(eval()'d code): failed to open stream: No such file or directory'</warning>
it is weird to me that there is no closer trace
from serializable-closure.
Related Issues (20)
- Error: File name too long[36] HOT 6
- Class not found when type-hint is defined for closure created from method HOT 4
- Memory leak in anonymous function HOT 1
- Save filename when serializing closures
- PHP 7.3 is not supported. HOT 1
- Support for PHP 8.1 enums HOT 4
- serialization crashes on typed properties HOT 1
- Unserialize from opis/closure serialization? HOT 2
- Serialization of 'Closure' is not allowed HOT 1
- Call to a member function `bindTo()` on `null` HOT 3
- I am not able to send serialized closure in queue job. HOT 2
- Laravel\SerializableClosure\Exceptions\InvalidSignatureException HOT 1
- Namespace resolution missing for named parameter during serialization HOT 6
- Unable to find the called function HOT 2
- When I used `php_strip_whitespace` to compress my PHP code, this library didn't work as expected. HOT 2
- Serialization of an Exception is not possible inside the closure HOT 1
- Serializable closure breaks the Symfony var-dumper HOT 5
- Syntax errors caused by namespace resolution HOT 3
- Memory leak in job queue delivery HOT 1
- syntax error, unexpected token "list", expecting "(" HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from serializable-closure.