Git Product home page Git Product logo

Comments (7)

kenjis avatar kenjis commented on September 27, 2024

This is not a bug.

Important
Using this feature when the prerequisites are not met will prevent CodeIgniter from operating properly. Do not use this feature in such cases.

Read https://codeigniter4.github.io/CodeIgniter4/concepts/factories.html#prerequisite

from codeigniter4.

kenjis avatar kenjis commented on September 27, 2024

Use new Mimes() instead of config('Mimes').
Because config() is slow., there is no benefit to use config() for Mimes.

Also, Mimes extending BaseConfig makes the instantiation of Mimes very slow.
That is not the way to go.

from codeigniter4.

gbanc avatar gbanc commented on September 27, 2024

Either way, codeigniter factories does not work out-of-the-box with Config/Mimes.php, because it does not implement __set_state()

From your link to the docs: "By default, every Config class that is cached must implement __set_state() method."
So one would expect that the default implementation of Config/Mimes.php should implement __set_state() no?

from codeigniter4.

kenjis avatar kenjis commented on September 27, 2024

Either way, codeigniter factories does not work out-of-the-box with Config/Mimes.php, because it does not implement __set_state()

True, you cannot use Config caching with Config\Mimes.
It is intentional, because we don't need to cache it.

So one would expect that the default implementation of Config/Mimes.php should implement __set_state() no?

No.
It means, if you want to cache a Config class instance, the class must implement __set_state() method. Config\Mimes does not implement it, so you cannot cache it by default.

If the explanations in the user guide are not clear, please read the source code and understand how the Config caching works, and provide suggestions for improvement.

Config cache is an additional feature for experts who need any better performance.
We recommend that users who cannot troubleshoot on their own not use it.

Also, if you use caching, we recommend that you measure whether the caching is really effective.

from codeigniter4.

gbanc avatar gbanc commented on September 27, 2024

So, if Config/Mimes doesn't need to be cached, then why is it being included by default when enabling config caching?

Its common sense that if one enables a feature in the framework, one would expect it to work with its own default system files. I did not explicitly configure it to cache Config/Mimes, it does it on its own, out-of-the-box. Which breaks.

I would simply update the user guide to say: "Enabling this will not work by default, You have to manually override Config/Mimes and add __set_state method yourself"

from codeigniter4.

kenjis avatar kenjis commented on September 27, 2024

So, if Config/Mimes doesn't need to be cached, then why is it being included by default when enabling config caching?

It is not included by default. You intentionally did it by calling config('Mimes').

Enabling this will not work by default, You have to manually override Config/Mimes and add __set_state method yourself

This is incorrect. You should not cache it. In other words, you should not call config('Mimes'). If you do not call config(), Config/Mimes has nothing to do with Config Caching.

from codeigniter4.

gbanc avatar gbanc commented on September 27, 2024

Fair enough, makes sense. Thanks for your patience

from codeigniter4.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.