? Error

User tests: Successful: Unsuccessful:

avatar nikosdion
nikosdion
12 Oct 2013

This PR fixes the tracker item 32258 "FOFModel::getTmpInstance() clears input before getItemList() is run".

The problem was in the PostinstallModelMessages. It should use getState to read the eid and published state variables, not try to read them directly from the input object. Reading directly from the input is discouraged. The models act on their state, not the global application input. This is a fundamental tenant of the MVC architecture. My bad! I wrote some very bad code in that model.

This PR fixes the PostinstallModelMessages model and also modifies the call to it from CpanelViewCpanel to correctly set the state variable, exactly as proper MVC prescribes.

avatar nikosdion nikosdion - open - 12 Oct 2013
avatar Bakual
Bakual - comment - 12 Oct 2013

Tested and works fine, thanks.

A question about the code mainly out of curiosity. I would have used

$messages_model = FOFModel::getTmpInstance('Messages', 'PostinstallModel');
$messages_model->setState('eid', 700);

instead of

$messages_model = FOFModel::getTmpInstance('Messages', 'PostinstallModel')->eid(700);

Is there a difference to it?

avatar nikosdion
nikosdion - comment - 12 Oct 2013

Not really. I just used the fluid syntax which makes use of the magic __set method to run setState and return $this. It's convenient when setting multiple state variables, I find it easier to read and I am used to using it. Both methods are valid and equivalent.

avatar Bakual
Bakual - comment - 12 Oct 2013

It's indeed nice as long as you know what the magic method does :)

Add a Comment

Login with GitHub to post a comment