?
avatar obuisard
obuisard
8 Aug 2021

Steps to reproduce the issue

Use the new Mail Template API to create a mail template (using MailTemplate::createTemplate())

Expected result

New entry in the mail_templates table.

Actual result

Error: Field 'attachments' doesn't have a default value

System information (as much as possible)

Joomla 4 RC5 MySQL 5.7.14

Additional comments

It looks like the API does not take into account the attachments database column.
Since there is no way to add an attachment or a default value in createTemplate(), inserting a template in the database fails.
The database table should have a default value for the 'attachments' column in this case, since attachments are omitted.

avatar obuisard obuisard - open - 8 Aug 2021
avatar joomla-cms-bot joomla-cms-bot - change - 8 Aug 2021
Labels Added: ?
avatar joomla-cms-bot joomla-cms-bot - labeled - 8 Aug 2021
avatar richard67
richard67 - comment - 8 Aug 2021

The database table should have a default value for the 'attachments' column in this case

@obuisard No, this is wrong. As a column with data type TEXT, it should not have a default value, see PR #27937 and PR #17860 and also https://stackoverflow.com/questions/3466872/why-cant-a-text-column-have-a-default-value-in-mysql for the reasons. Insteasd of this, the API should properly initialize that column value and use it in the insert statement.

avatar richard67
richard67 - comment - 8 Aug 2021

@obuisard Please report back which version of Joomla 4 you have used, e.g. "RC 5" or a previous RC, or a nightly build.

avatar obuisard obuisard - change - 8 Aug 2021
The description was changed
avatar obuisard obuisard - edited - 8 Aug 2021
avatar obuisard
obuisard - comment - 8 Aug 2021

I have updated the bug report to show RC 5 as the version tested.
Thanks @richard67 for the info about the default values in the database :-)

avatar richard67
richard67 - comment - 8 Aug 2021

I think it could be fixed here in this function by adding the attachments property to that standard class and set it’s value to an empty string (or json?): https://github.com/joomla/joomla-cms/blob/4.0-dev/libraries/src/Mail/MailTemplate.php#L411 .

I’ll have a look tomorrow if that’s the right fix if nobody is faster.

avatar richard67
richard67 - comment - 9 Aug 2021

Will work on it today.

avatar obuisard
obuisard - comment - 9 Aug 2021

Thank you @richard67, I was not able to propose a PR myself (traveling). I appreciate your help.

avatar richard67 richard67 - change - 9 Aug 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-08-09 08:57:58
Closed_By richard67
Labels Added: ?
Removed: ?
avatar richard67 richard67 - close - 9 Aug 2021
avatar richard67
richard67 - comment - 9 Aug 2021

Closing as having a pull request. Please test #35074 and then mark the test result in the issue tracker here https://issues.joomla.org/tracker/joomla-cms/35074 by using the "Test this" button at the top left corner, selecting the right test result (I hope "success") and submit. Thanks in advance.

Add a Comment

Login with GitHub to post a comment