? Pending

User tests: Successful: Unsuccessful:

avatar ITPrism
ITPrism
26 Apr 2016

Pull Request for Issue that leads to a problem for some developers.
Here you are more information.
https://groups.google.com/forum/#!topic/joomla-dev-general/KZFM8yKZYpg
http://forum.joomla.org/viewtopic.php?f=615&t=775779

Summary of Changes

This PR fixes an issue that causes an error when someone would like to store NULL value to table columns, using JTable.
I removed the variable $updateNulls because JTableAsset causing the error. Furthermore, the object does not need this variable because there are no columns in _#_assets where you can store NULL value.

Testing Instructions

  1. Change the default value of $updateNulls to true on line 309 in file libraries/legacy/table/content.php.
  2. Save an existing article via the content manager.
  3. That results to an error Unknown column 'alias' in 'field list', caught on line 1204 in libraries/legacy/model/admin.php.

change_update_nulls

unknown_column_alias

avatar ITPrism ITPrism - open - 26 Apr 2016
avatar ITPrism ITPrism - change - 26 Apr 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Apr 2016
Labels Added: ?
avatar brianteeman brianteeman - change - 26 Apr 2016
Category Libraries
avatar wilsonge
wilsonge - comment - 7 May 2016

I don't understand what you are doing here. First you say it can't be null. But then you say this fix allows people to store nulls. This code just feels very very wrong to me.

avatar ITPrism
ITPrism - comment - 7 May 2016

I will try to explain it better. :)
If I would like to store data using JTable, and I would like to store NULL in my columns, I will use $row->store(true).
Some developers do not use JModelAdmin->save() and JTable->save(). They use JTable->store for that reason.
Here you are an example how I only use store(), not save().

There is no problem with JModelAdmin. I just gave it as example where you can test what will happen when perform $table->store with TRUE as parameter.

If you perform $table->store(true) on line 1181 it will catch the error on line 1196. Look at the second screenshot.

To prevent this error, I will have to put $table->store(true) in try-catch.
The problem is the object $asset on line 846.
The object $asset has property 'alias'.
If the parameter $updateNulls is TRUE ($asset->store(true)), the object tries to store NULL value of its property 'alias' in table '#__assets'.
However, there is no column 'alias' in '#__assets'. Furthermore, there are no columns where you will be able to store NULL values in '#__assets'. So, the property $updateNulls on line 846 is redundant.
If you remove it, that will fix this issue and developers will be able to use $table->store(true) without try-catch. :)

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 Jan 2017

should this PR be tested?

avatar ITPrism
ITPrism - comment - 6 Jan 2017

It should be tested and merged.
That will be a solution for the mentioned problem.
https://groups.google.com/forum/#!topic/joomla-dev-general/KZFM8yKZYpg
http://forum.joomla.org/viewtopic.php?f=615&t=775779

You can test it easy. Just add "true" as parameter of $table->store() on line 1181.

That will occur the error that you can see on the second screenshot above.
That happens when we use $table->store(true) to store entities by our extensions. It only happens when we use ACL roles in our extensions. It seems, JTable creates asset records when we use roles for our entities.

That is really strange bug, difficult for detecting because it only occurs when someone use $table->store(true) in extensions with implemented ACL roles. :)

However, it is easy for fixing. You have to remove the redundant $updateNulls on line 846 .

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 7 Jan 2017

I have tested this item ? unsuccessfully on e8d62b2

avatar franz-wohlkoenig franz-wohlkoenig - test_item - 7 Jan 2017 - Tested unsuccessfully
avatar ITPrism
ITPrism - comment - 7 Jan 2017

I told you, it is hard to catch the error. :) You can save an article but the error still exists.

I did a video that shows you how to test with an article.
The second video shows the result when we use $table->store(true) with assets in our extensions.

My arguments for removing $updateNulls on line 846 in file libraries/joomla/table/table.php are:

  1. There is no reason to give $updateNulls to $asset->store() on line 846, because the table #__assets does not contain any columns where you can store NULL values.
  2. That will be a solution for our problems and we will be able to use $table->store(true) in our projects.

Test with an article
https://www.youtube.com/watch?v=86mlgxa4CxY

Result in our extensions when we use $table->store(true) with assets.
https://www.youtube.com/watch?v=dLtXo9UBsro

avatar brianteeman
brianteeman - comment - 9 Sep 2017

@wilsonge does this last explanation answer your question Or should this be closed.

avatar brianteeman
brianteeman - comment - 10 Apr 2018

Closing this as it is going nowhere

avatar brianteeman brianteeman - change - 10 Apr 2018
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2018-04-10 12:43:06
Closed_By brianteeman
avatar brianteeman brianteeman - close - 10 Apr 2018

Add a Comment

Login with GitHub to post a comment