Jefferson49 / Joomla_plugin_sexypolling_reloaded

Migration of the joomla plugin "Sexy Polling" to joomla 4.x
GNU General Public License v3.0
2 stars 3 forks source link

Installation Issue with Sexy Polling Reloaded v5.1.1 on Joomla 4.1.1 #78

Closed 4creator closed 6 months ago

4creator commented 7 months ago

Hello,

I attempted to install the joomla_plugin_sexypolling_reloaded_v5.1.1.zip on Joomla 4.1.1, but encountered the following error and was unable to complete the installation: Invalid default value for 'date_start'

Upon inspecting the install.sql file, I found these lines:

`date_start` date NOT NULL DEFAULT NOW(),
`date_end` date NOT NULL DEFAULT '2040-12-31',

Changing them to the following resolved the issue and allowed the installation to proceed:

`date_start` date NOT NULL DEFAULT '2024-01-01',
`date_end` date NOT NULL DEFAULT '2070-12-31',

According to ChatGPT, the use of the NOW() function is inappropriate for a DATE type column because it returns both date and time. A DATE type column should only have a date set as its default value.

I wanted to report this so that it can be addressed in future updates of the plugin.

Best regards

Jefferson49 commented 7 months ago

Thank you very much for reporting the issue!

Indeed, this looks wrong. Seemingly, MySQL is tolerant in a lot of installations and I never got an error for myself.

You can try substituting NOW() by UTC_DATE(). That should provide a date instead of a datetime.

I will also check in my own installations in the next days. If it works, I will publish a bugfix release.

Jefferson49 commented 6 months ago

After diving deeper into this issue, I found out that MySQL does not accept dynamic default values for the date datatype if the rules are strictly applied. However, most of the installations seem to accept NOW() or CURRENT_TIMESTAMP() as default values and also convert datetimes into date. That is the reason why usually no errors occur.

To be on the save side, I changed the default value for date_start to '2020-01-01'. I will publish a new release soon.