-
Notifications
You must be signed in to change notification settings - Fork 297
JTable doesn't update a field with a null value #364
Comments
Wow I think this is happening for me as well when trying to save a blanked out article. ... Actually I think this is because $updateNulls is set to false in the content table Also #1077 although that has to do with a different table. |
Actually this is feature (or issue) in bind() function itself, which prevents updating values that do not exist. In PHP isset() returns false either if the value doesn't exist or is null. It's very useful for example when you may have optional input fields, which do not always come from GET or POST (are set but not defined). Changing this undocumented feature could potentially slightly break many extensions (and core) which rely on this feature. If table needs some other behavior, I'd rather override the function with a version that works better for that table. Forcing bind() change to all tables may have catastrophic consequences on many extensions as it's breaking the current API. |
Okay I found the problem in JTableContent which is that it was using !empty rather than isset for a condition and that was leading to other consequences |
So, has this been fixed in the CMS or a previous iteration of the Platform then? |
I'm sorry but we aren't accepting issues for this repository any more. Please see http://developer.joomla.org/cms/report-an-issue.html for how to report and issue for the CMS Platform. |
Hi
It is impossible for me to update a table with JTable and assign a null value for a field.
I think the problem is the processing of data in the bind () function of Table.php, more precisely in the foreach loop, at:
if (isset ($ src [$ k])) {
$ this-> $ k = $ src [$ k];
}
If the value is null, the assignment will never happen.
I need to put a null on a foreign key without any error FOREIGN_KEY_CHECKS
I tried replacing
if (isset ($ src [$ k]))
by
if (isset ($ src [$ k]) | | (is_null ($ src [$ k]) & & array_key_exists ($ k, $ src)))
and it works for now.
The text was updated successfully, but these errors were encountered: