f3-factory / fatfree-core

Fat-Free Framework core library
GNU General Public License v3.0
207 stars 88 forks source link

Base magic get doesn't check cached variable #228

Open ikkez opened 7 years ago

ikkez commented 7 years ago

There's a different between $f3->get('foo') and $f3->foo.

https://github.com/bcosca/fatfree-core/blob/b2e66eb1f27c61187c9608cc994673f9e501ed2c/base.php#L2097-L2099

Since offsetget uses the ref method instead get, it does not check the Cache here. I'm not sure if that's an issue or maybe just something to note in the docs 🤔 Thoughts?

xfra35 commented 7 years ago

Interesting!

I would say that since offsetset ignores the Cache instance (no ttl argument passed), then it makes sense that offsetget ignores it too.

So I vote for updating the docs.

ikkez commented 7 years ago

alright.. adding this to the docs sounds fine.

Another thing: cached variables are not accessable within the template by default. That's somehow logical, because the sandbox receives a copy of the current HIVE by default, and cached variables are lazy-loaded on demand, which is great...so if you have not accessed / requested this variable from cache before, it's not present in template and cannot be fetched from there... worth a note in the docs as well.