From 55daae4773c945997cbf8dbb7c9ae35d579f4cb2 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Sun, 30 Jun 2013 18:45:05 -0400 Subject: [PATCH] Fixes issue #589: validate the scenario name. --- framework/yii/base/Model.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/yii/base/Model.php b/framework/yii/base/Model.php index 3e38442..553f2e8 100644 --- a/framework/yii/base/Model.php +++ b/framework/yii/base/Model.php @@ -583,10 +583,15 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess /** * Sets the scenario for the model. * @param string $value the scenario that this model is in. - * @see getScenario + * @throws InvalidParamException if the scenario to be set is unknown + * @see scenarios() */ public function setScenario($value) { + $scenarios = $this->scenarios(); + if (!isset($scenarios[$value])) { + throw new InvalidParamException("Setting unknown scenario: $value"); + } $this->_scenario = $value; }