Please see issue posted here.
Reposting below for convenience - please read before voting, and feel free to clarify your vote and discuss here.
[quote name=‘mindplay’]CModel::setAttributes() silently ignores access violations - that is,
massive assignment of attributes which are not safe, and should not be
permitted under the current scenario, are simply ignored.
This, combined with the fact that safeAttributes() is no longer supported
in 1.1, caused us all manner of headaches while upgrading to 1.1, resulting
in countless silent malfunctions in all manner of models - very hard to
track and debug. The only way to debug these errors, is to manually go
through every single model and rebuild portions as needed.
An attempt to write an attribute that isn’t safe is the current scenario
should result in an exception, because it is essentially an access
violation.
Imagine if PHP would silently fail when you try to set a property that is
declared protected or private - debugging would be nearly impossible.
Submitting form inputs that cannot be validated, or have been explicitly
marked as unsafe, must result in an exception - otherwise, there is no way
to reliably debug forms and models.
Even with CUnsafeValidator, an access violation will be allowed to pass by
in silence. If I have specifically marked an attribute as unsafe in a given
scenario, I think we can assume that an attempt to set the attribute is a
hacking attempt, or at the very least an oversight on the developer’s part.
If somebody really does intend to use unsafe attributes as a means of
access control, perhaps CUnsafeValidator could offer an option to allow
access violations to fail in silence. Personally, I would consider such use
of this feature bad practice, but this should be the only curcumstance
under which an access violation should be acceptable and silently fail.
[/quote]
[quote name=‘qiang’]While raising exceptions may be preferable in some cases, it is not so in some other
cases. The current design basically means: please ignore those values that are not
safe. I am not sure if raising exception is the most desired behavior. I do believe
if we change this behavior, it will cause fire from many people.
One solution for you is to write the base class ActiveRecord and FormModel and
override setAttributes() to raise exception as you want. This should help you more
smoothly upgrade from 1.0 to 1.1.
[/quote]
[quote name=‘mindplay’]I don’t understand what practical reason you could have for ignoring values that are
not safe.
In practice, when (or why) would you expose an attribute, with an enabled input on a
form, during a scenario that does not allow modification of the attribute?
I can’t see any practical use for this feature.
On the other hand, I can see plenty of reasons (as listed above) why this would cause
problems for many developers - not just during upgrades, as stated, but during normal
everyday development.
I believe this behavior should be available, but making this the default behavior is
going to cause lots of silent errors, and really seems like a bad call.
[/quote]