-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Cache Driver - Serialize/Unserialize Objects #2111
Comments
maybe something like this library https://github.com/nilportugues/php-serializer provided by Nil Portugués Calderó would solve that problem. |
The current problem in the cache library, is the missing option parameter for the unserialize method inside the |
@lonnieezell @MGatner what do you think? |
Object serialization is not a guarantee, the object has to implement a serializable and I don't know that it is on the Cache library to check on that. I think the error you noted "__PHP_Incomplete_Class_Name" is actually an indication of the attempt to serialize something that can't be serialized. I'll leave policy decisions to the admins but I think it's probably up to the developer to ensure they are caching serializables. |
It looks like it should be able to handle that (though not with an anonymous class like your example implies, since PHP will balk at that). See: https://repl.it/@lonnieezell/FoolishSlateblueInvocation In general, I agree that it's up to the dev to ensure that whatever they pass in can be serialized and unserialized successfully. However, this example looks valid, so we need to check what's going on for sure. @tada5hi what cache driver did you discover this on? |
@lonnieezell, at the Filehandler. But the Problem causes on all drivers, because they all use the php internal serialize and unserialize functions. To prevent the unserialize method to properly create objects which are maybe malformed by a third party tool or sth. else, we should use encryption. |
Rhis should be discussed/resolved on the forum before showing up here. |
This is optional, and while it does add a layer of security we should be able to trust our input values. If some source has hijacked the filesystem (or whatever source of cache info) then nothing the framework would do could be of greater concern. From PHP.net:
In other words, "as is" any class is acceptable which is I think where we want to be. |
Direction
Describe the bug
Cant serialize/unserialize Objects. Receive " __PHP_Incomplete_Class_Name"
$class = new Class() {
public function test() {
var_dump(123);
}
};
cache()->save('test',$class);
$cache = cache()->get('test');
$cache->test(); // this wont work
CodeIgniter 4 version
codeigniter4/framework: "dev-master"
Affected module(s)
Which package or class is the bug in, if known.
Expected behavior, and steps to reproduce if appropriate
Context
The text was updated successfully, but these errors were encountered: