Feature No Code Attached Yet
avatar MarkRS-UK
MarkRS-UK
21 Apr 2023

Problem identified

Some methods in \Joomla\CMS\Table\Table could return more useful values.
For example "store", "save" and "delete" simply return hard-coded values of "true".
This doesn't indicate anything useful.

Proposed solution

Return

`$this->_db->getAffectedRows() == 1`

probably via a saved value, so that any subsequent "after" events contribute rather than wipe out this result.

This confirms that the requested action did what was requested, not simply that it didn't cause a fatal error, which is already obvious.

Open questions

Are there other methods ("reorder", for example) which could valuably be similarly changed?

avatar MarkRS-UK MarkRS-UK - open - 21 Apr 2023
avatar joomla-cms-bot joomla-cms-bot - change - 21 Apr 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 21 Apr 2023
avatar richard67 richard67 - change - 21 Apr 2023
Labels Added: ?
avatar richard67 richard67 - labeled - 21 Apr 2023
avatar richard67
richard67 - comment - 24 Apr 2023

@MarkRS-UK For the store and the save method your example makes sense because we know how many records we want to save. But for the delete method it is not always clear. We might run a delete statement regardless if the records with that PK exist or not, and of some of them don't exist it is not really an error.

avatar MarkRS-UK
MarkRS-UK - comment - 24 Apr 2023

Yes, point taken.

I think I'd rather get some information that I can decide the validity of rather than no information, but I can see that this case might not be convincing enough.

avatar rdeutz rdeutz - change - 6 May 2024
Status New Closed
Closed_Date 0000-00-00 00:00:00 2024-05-06 21:04:54
Closed_By rdeutz
Labels Added: Feature
Removed: ?
avatar rdeutz rdeutz - close - 6 May 2024
avatar rdeutz
rdeutz - comment - 6 May 2024

I don't see the usecase here. We work in the direction that we throw execptions when something goes wrong. When an action goes well you get true, or an array of results or you can get the affected rows. So nothing to add if you ask me. Closing it.

Add a Comment

Login with GitHub to post a comment