File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -523,11 +523,16 @@ public function getAttribute($name)
523
523
* Sets the named attribute value.
524
524
* @param string $name the attribute name
525
525
* @param mixed $value the attribute value.
526
+ * @throws InvalidParamException if the named attribute does not exist.
526
527
* @see hasAttribute
527
528
*/
528
529
public function setAttribute ($ name , $ value )
529
530
{
530
- $ this ->_attributes [$ name ] = $ value ;
531
+ if (isset ($ this ->_attributes [$ name ]) || isset ($ this ->getTableSchema ()->columns [$ name ])) {
532
+ $ this ->_attributes [$ name ] = $ value ;
533
+ } else {
534
+ throw new InvalidParamException (get_class ($ this ) . ' has no attribute named " ' . $ name . '". ' );
535
+ }
531
536
}
532
537
533
538
/**
@@ -567,11 +572,16 @@ public function getOldAttribute($name)
567
572
* Sets the old value of the named attribute.
568
573
* @param string $name the attribute name
569
574
* @param mixed $value the old attribute value.
575
+ * @throws InvalidParamException if the named attribute does not exist.
570
576
* @see hasAttribute
571
577
*/
572
578
public function setOldAttribute ($ name , $ value )
573
579
{
574
- $ this ->_oldAttributes [$ name ] = $ value ;
580
+ if (isset ($ this ->_oldAttributes [$ name ]) || isset ($ this ->getTableSchema ()->columns [$ name ])) {
581
+ $ this ->_oldAttributes [$ name ] = $ value ;
582
+ } else {
583
+ throw new InvalidParamException (get_class ($ this ) . ' has no attribute named " ' . $ name . '". ' );
584
+ }
575
585
}
576
586
577
587
/**
You can’t perform that action at this time.
0 commit comments