Closed ppalex7 closed 10 years ago
The answer is the "unique" rule. Example (at actionInstall):
$plugin->status = !$plugin->canDisable()
?SBPlugin::STATUS_ENABLED
:SBPlugin::STATUS_INSTALLED;
Yii::log(CVarDumper::dumpAsString($plugin));
$plugin->validate();
Yii::log(CVarDumper::dumpAsString($plugin));
Before Validate plugin model is:
CommunityBansPlugin#1
(
[allowDisable] => true
[CActiveRecord:_new] => false
[CActiveRecord:_attributes] => array
(
'class' => 'CommunityBans.CommunityBansPlugin'
'status' => 1
)
[CActiveRecord:_related] => array()
[CActiveRecord:_c] => null
[CActiveRecord:_pk] => 'CommunityBans.CommunityBansPlugin'
[CActiveRecord:_alias] => 't'
[CModel:_errors] => array()
[CModel:_validators] => null
[CModel:_scenario] => 'update'
[CComponent:_e] => null
[CComponent:_m] => null
)
And after validate:
CommunityBansPlugin#1
(
[allowDisable] => true
[CActiveRecord:_new] => false
[CActiveRecord:_attributes] => array
(
'class' => 'CommunityBans.CommunityBansPlugin'
'status' => '0'
)
[CActiveRecord:_related] => array()
[CActiveRecord:_c] => null
[CActiveRecord:_pk] => 'CommunityBans.CommunityBansPlugin'
[CActiveRecord:_alias] => 't'
[CModel:_errors] => array()
...
Hmm, good catch. That's indeed an issue.
Quick solution - using $plugin->update instead of $plugin->save
After commit bcdf0c5bf617984bb41cfd0fea992fe50f89ac4b when i'm pressing "install" link, plugin is successfully installed, but his status doesn't changes to "installed" into db;
Something strange happens during
$plugin->save();
: Before it, $plugin is:but mysql receives this query (from bin log):
Did you have any ideas?