What is the scope of R::freeze(true)?

17 views
Skip to first unread message

Aaron Cooper

unread,
Feb 21, 2024, 3:51:52 AMFeb 21
to redbeanphp
I have inherited a system that is using chilled mode (or so I thought). It currently has two tables passed in an array:

R::freeze(['question','user']);

I am trying to freeze the whole system, one table at a time. And extending that array seems to work in most cases. It sits inside the bootstrap file of the site that all web traffic hits.

The issue is, unit tests don't respect it. Even when debugging the test, I see the test execution pass over this code, but for some reason the test will still create an absent field as if it is fluid. I tested this out a bit by freezing all and trying to add a absent field right after the freeze:

R::freeze(true);

$user = R::findOne('user');
$user->idontexist = 'blah';
R::store($user);

This results in an SQL error as expected. But if I remove that test been and let the test follow it's path to the file actually storing data for the user bean it still acts as if it's fluid, and creates `idontexist` in the table.

So what is the scope of R::freeze()? Just that request? Depends? Seems to me there is no actual global way to freeze redbean and there is execution nuance involved.

Dario Marotta

unread,
Feb 21, 2024, 6:29:42 AMFeb 21
to redbe...@googlegroups.com
I think R::freeze(...) 
can only freeze existing beans, otherwise there would be nothing to "freeze"... :)

--
You received this message because you are subscribed to the Google Groups "redbeanphp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to redbeanorm+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redbeanorm/63b15cd9-1df6-4a80-83dc-712486707949n%40googlegroups.com.

Aaron Cooper

unread,
Feb 21, 2024, 2:40:34 PMFeb 21
to redbe...@googlegroups.com
Sure. The bean exists. That's not the issue as my test code confirms.

To be clear, I remove the marked lines from the test code below:

R::freeze(true);

// Remove the following three lines

$user R::findOne('user');
$user->idontexist 'blah';
R::store($user);

So the entire DB should be frozen. But despite that test code working as expected right after the freeze, other R::store($user); commands elsewhere in code ignore the freeze. And there is no R::freeze(false) anywhere in the codebase.

This is why I ask what the scope of the freeze is. Where is it stored? What could make the freeze respected one line after the freeze, but completely ignored in another area of code (in the same request)?

Reply all
Reply to author
Forward
0 new messages