Take any table and a column that accepts null as a value. Set that value to null and then bind the row to the table.
The column in the table is updated to null.
The column in the table is not updated.
Joomla 4.2.5 stable version.
In the file libraries/src/Table/Table.php in the bind function at line 652 there is an isset function to test if the property exist in the incoming data and that the property has a value. A PHP null value is considered null and therefore the isset returns false and the table property is not replaced. Whatever was in the column remains.
I think the bind function needs to get passed the $updateNulls option in the same way as the store function, and when set to true then bind will update columns to null when passed the PHP null value.
Labels |
Removed:
?
|
Labels |
Added:
No Code Attached Yet
|
@Kaushik1216 just do it, no assignment needed :)
@Kaushik1216 It is Joomla\CMS\Table
class, bind
method https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Table/Table.php#L606
Here is the block of code which he mentioned in the issue https://github.com/joomla/joomla-cms/blob/4.2-dev/libraries/src/Table/Table.php#L649-L656
@joomdonation ,@skurvish and other joomlers can anyone tell me in which table and column this issues come ? As I understand why this issue come but unable to create this issue on any coloum of table ! I try in columns having property NULL accepted and default value NULL that are text type values
@Kaushik1216 To solve this issue, you need to understand how bind
method in Table
class works. You can run the code below somewhere:
$row = \Joomla\CMS\Table\Table::getInstance('Content', '\\Joomla\\CMS\\Table\\');
$row->load(1); // Replace 1 width ID of real Joomla article
$row->bind(['title' => null]);
var_dump($row->title);
After above code, we expect that $row->title
set to null
, but it is not. $row->title
still keep Title of the loaded article and that's the issue reported here
Hope you understand it now. If not, I'm afraid of you are not the right person to work on this issue.
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2023-01-11 19:34:11 |
Closed_By | ⇒ | richard67 |
And as a side question, why doesn't insertObject come with a Nulls options. At this point the insert function ignores any null columns and if the column does not have a default mysql is throwing an exception.
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39363.