No Code Attached Yet
avatar skurvish
skurvish
6 Dec 2022

Steps to reproduce the issue

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.

Expected result

The column in the table is updated to null.

Actual result

The column in the table is not updated.

System information (as much as possible)

Joomla 4.2.5 stable version.

Additional comments

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.

avatar skurvish skurvish - open - 6 Dec 2022
avatar skurvish skurvish - change - 6 Dec 2022
Labels Removed: ?
avatar joomla-cms-bot joomla-cms-bot - change - 6 Dec 2022
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 6 Dec 2022
avatar skurvish skurvish - change - 6 Dec 2022
The description was changed
avatar skurvish skurvish - edited - 6 Dec 2022
avatar skurvish
skurvish - comment - 6 Dec 2022

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.

avatar Kaushik1216
Kaushik1216 - comment - 21 Dec 2022

Hey @skurvish I'm intrested in solving this isssue please assign it to me

avatar chmst
chmst - comment - 22 Dec 2022

@Kaushik1216 just do it, no assignment needed :)

avatar Kaushik1216
Kaushik1216 - comment - 24 Dec 2022

@skurvish which table or where are you talking I am not getting it.

avatar joomdonation
joomdonation - comment - 24 Dec 2022
avatar Kaushik1216
Kaushik1216 - comment - 24 Dec 2022

@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

avatar joomdonation
joomdonation - comment - 24 Dec 2022

@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.

avatar richard67 richard67 - change - 11 Jan 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-01-11 19:34:11
Closed_By richard67
avatar richard67 richard67 - close - 11 Jan 2023
avatar richard67
richard67 - comment - 11 Jan 2023

Closing as having a pull request. Please test #39607 . Thanks in advance.

Add a Comment

Login with GitHub to post a comment