jemproject / JEM-Project

JEM - an Event Manager for Joomla
https://www.joomlaeventmanager.net
GNU General Public License v3.0
25 stars 37 forks source link

2.3.9: Frontend : Saving edited event not possible when not in english --> Date problem #1410

Closed jobrusche closed 1 year ago

jobrusche commented 1 year ago

Frontend>Edit event changing anything (e.g. "Allow annulation" from no to yes) Save event -> Save-modified-event

Environment: Wampserver 3.3.0 64b - Joomla 4.2.7 - PHP 8.0.13

Heklaterriol commented 1 year ago

[if language dateformat is english:] cannot reproduce. According to the call stack, it looks as if it isn't a joomla error, right?

jojo12 commented 1 year ago

[ with german language:]

Call stack

| Function | Location

1 | () | JROOT/libraries/src/Form/Field/CalendarField.php:401 2 | Joomla\CMS\Form\Field\CalendarField->filter() | JROOT/libraries/src/Form/Form.php:1047 3 | Joomla\CMS\Form\Form->filter() | JROOT/libraries/src/Form/Form.php:991 4 | Joomla\CMS\Form\Form->process() | JROOT/libraries/src/MVC/Model/FormModel.php:213 5 | Joomla\CMS\MVC\Model\FormModel->validate() | JROOT/libraries/src/MVC/Controller/FormController.php:623 6 | Joomla\CMS\MVC\Controller\FormController->save() | JROOT/components/com_jem/controllers/event.php:283 7 | JemControllerEvent->save() | JROOT/libraries/src/MVC/Controller/BaseController.php:672 8 | Joomla\CMS\MVC\Controller\BaseController->execute() | JROOT/components/com_jem/jem.php:48 9 | require_once() | JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71 10 | Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher{closure}() | JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73 11 | Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() | JROOT/libraries/src/Component/ComponentHelper.php:355 12 | Joomla\CMS\Component\ComponentHelper::renderComponent() | JROOT/libraries/src/Application/SiteApplication.php:200 13 | Joomla\CMS\Application\SiteApplication->dispatch() | JROOT/libraries/src/Application/SiteApplication.php:241 14 | Joomla\CMS\Application\SiteApplication->doExecute() | JROOT/libraries/src/Application/CMSApplication.php:294 15 | Joomla\CMS\Application\CMSApplication->execute() | JROOT/includes/app.php:61 16 | require_once() | JROOT/index.php:32

jojo12 commented 1 year ago

I edited an event on your JEM4, I changed featured from yes to no, then save: I got: danger Save failed with the following error: Incorrect integer value: '' for column d03b475f.jem4_jem_events.locid at row 1

jojo12 commented 1 year ago

I try the same "edit an existing event in frontend" in my installation: when JEM smart search is activated, then I get:

0 Call to a member function format() on bool

when JEM smart search ist deactivated, then I get:

Save failed with the following error: Incorrect integer value: '' for column d03b475f.jem4_jem_events.locid at row 1

jojo12 commented 1 year ago

Logs: 2023-02-22T12:42:12+00:00 INFO 127.0.0.1 controller Releasing edit ID com_jem.edit.event.24 Array ( ) 2023-02-22T12:43:56+00:00 INFO 127.0.0.1 controller Holding edit ID com_jem.edit.event.24 Array ( [0] => 24 ) 2023-02-22T12:43:57+00:00 INFO 127.0.0.1 controller Checking edit ID com_jem.edit.event.24: 1 Array ( [0] => 24 )

jojo12 commented 1 year ago

error

jojo12 commented 1 year ago

I think, in JEM4 you are on the right way: the input date must be yyyy-mm-dd. This is a common joomla problem! Wow!!!

jobrusche commented 1 year ago

Frontend : create new event -> save ->OK Edit same event (changed start + end time) -> save -> 0 - Call to a member function format() on bool Log:

<?php die('Forbidden.'); ?>

Date: 2023-02-22 16:08:20 UTC

Software: Joomla! 4.2.8 Stable [ Uaminifu ] 16-February-2023 15:00 GMT

2023-02-22T16:17:16+00:00 CRITICAL 2a02:a03f:8b9f:f900:ccb3:1a37:941b:fdb9 error Uncaught Throwable of type Error thrown with message "Call to a member function format() on bool". Stack trace: #0 [ROOT]/libraries/src/Form/Form.php(1047): Joomla\CMS\Form\Field\CalendarField->filter('30-11--0001', NULL, Object(Joomla\Registry\Registry))

1 [ROOT]/libraries/src/Form/Form.php(991): Joomla\CMS\Form\Form->filter(Array, NULL)

jemproject/JEM-Project#1343 [ROOT]/libraries/src/MVC/Model/FormModel.php(213): Joomla\CMS\Form\Form->process(Array, NULL) jemproject/JEM-Project#1344 [ROOT]/libraries/src/MVC/Controller/FormController.php(623): Joomla\CMS\MVC\Model\FormModel->validate(Object(Joomla\CMS\Form\Form), Array) jemproject/JEM-Project#1345 [ROOT]/components/com_jem/controllers/event.php(283): Joomla\CMS\MVC\Controller\FormController->save('id', 'a_id') jemproject/JEM-Project#1346 [ROOT]/libraries/src/MVC/Controller/BaseController.php(672): JemControllerEvent->save() jemproject/JEM-Project#1347 [ROOT]/components/com_jem/jem.php(48): Joomla\CMS\MVC\Controller\BaseController->execute('save') jemproject/JEM-Project#1348 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(71): require_once('/var/www/client...') jemproject/JEM-Project#1349 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(73): Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher{closure}('/var/www/client...') jemproject/JEM-Project#1350 [ROOT]/libraries/src/Component/ComponentHelper.php(355): Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() jemproject/JEM-Project#1351 [ROOT]/libraries/src/Application/SiteApplication.php(200): Joomla\CMS\Component\ComponentHelper::renderComponent('com_jem') jemproject/JEM-Project#1352 [ROOT]/libraries/src/Application/SiteApplication.php(241): Joomla\CMS\Application\SiteApplication->dispatch() jemproject/JEM-Project#1353 [ROOT]/libraries/src/Application/CMSApplication.php(294): Joomla\CMS\Application\SiteApplication->doExecute() jemproject/JEM-Project#1354 [ROOT]/includes/app.php(61): Joomla\CMS\Application\CMSApplication->execute() jemproject/JEM-Project#1355 [ROOT]/index.php(32): require_once('/var/www/client...') jemproject/JEM-Project#1356 {main}

Joomla 4.2.8 / PHP 8.0.32 / JEM beta4 2.3.8 https://wega.brusche.be

jojo12 commented 1 year ago

for me this is the releaseblocker! (is it in models/fields/calendarjem.php?)

jojo12 commented 1 year ago

In a clean Joomla! language set for site: english, I don't have this problem! I think it's the Calendar field problem! But how! perhaps this: site/models/fields/calendarjem.php

jobrusche commented 1 year ago

Still a problem with beta4-2.39 on wega.brusche.be

jojo12 commented 1 year ago

quick solution, when nothing changed: change joomla language to english!

jobrusche commented 1 year ago

Checked this on fresh installed Joomla 4.2.8 not other components than JEM beta4 2.39 Changed language from Dutch to English ->> success Also on wega.brusche.be, changed frontend language from Dutch to English ->> success

jojo12 commented 1 year ago

@mckillo: Hi, I wrote it here earlier one possibility of notification is: I got this with: legacy stile: frontend>editevent (existing event)>save Save failed with the following error: Incorrect integer value: '' for column d03b475f.jem4_jem_events.locid at row 1

but most of the time with debug, it shows:

0 Call to a member function format() on bool and then the call stack, you see above!

jojo12 commented 1 year ago

When languages>site set is english, then frontend>editevent has dateformat 2023-03-02 and saving is ok! when languages>site set in german, then frontend>editevent has dateformat 02.03.2023 and saving gets error! changing languages>admin doesn't gives problems!

jojo12 commented 1 year ago

When I remember right, this was a big problem too in times of new Joomla! 3.6. And I think perhaps because of this there is calendarjem.php.

mckillo commented 1 year ago

I have debugged the cause.

JEM for JL4 - recurrence_limit_date generate errorin other languages when this filed value in db is 0000-00-00

When you create the first event (title, date and category), save, don't have any error. This event was save with _jem_events.recurrence_limit_date to '0000-00-00', and it should be 'null', because this field wasn't define in the event edit page (Extended tab). If edit this event and save, you have the error. If you change en DB _jem_events.recurrence_limit_date= null for this event (this field can be null, see structure table). It works. If JEM validate date and format, the validate process is made by Joomla 4 and the date format = '0000-00-00' isn't valid, because its value="30-11--0001". This is the value of this field when the event edit and when save the event has the error.

If you create a new event with recurrence, don't have any error. In this case recurrence_limit_date has a valid value, it isn't 0000-00-00.

One commit of import process, it's migrate this data from JEM2.3.5 '0000-00-00' to null (see 70faf5c4c255e232bbdc27b71e9f991acf9e0b04) So, when the admin edits old event, don't have any error when save.

Today, I don't have time more. The solution is easy, when this field "Recurrence counter" isn't defined (not used), it muest save its value as null in the DB. I suppose with this hint, hekla can easily fix it :-)

jojo12 commented 1 year ago

For the first view: Gracias!

mckillo commented 1 year ago

@jojo12: Here you are the fix When a new event is saved and recurrence setting isn't used (defined), the recurrence_limit_date field of event must be null. recurrence_limit_date field is defined into event table structure as null instead of 0000-00-00

In the administrator\components\com_jem\models\event.php line290, change this line: $data['recurrence_limit_date'] = '0000-00-00'; for this one: $data['recurrence_limit_date'] = null;

Review and testing. See commit abcb4f4105cdf6915c119d79f2a411898e24d041

jojo12 commented 1 year ago

I tested with mckillos commit, works best! Thanks

jojo12 commented 1 year ago

see mckillos commit

Heklaterriol commented 1 year ago

I applied the changes:

_In the administrator\components\com_jem\models\event.php line290, change this line: $data['recurrence_limit_date'] = '0000-00-00'; for this one: $data['recurrence_limit_date'] = null;_

The error still exits at my site …

Heklaterriol commented 1 year ago

In /com_jem/media/js/unlimited.js line 18-24 I found:

function submit_unlimited() {
    var $value = document.getElementById("recurrence_limit_date").value;
    var $date_array = $value.split("-");
    if ($date_array.length < 3) {
        document.getElementById("recurrence_limit_date").value = "0000-00-00";
    }
}

This should be changed too I guess.

to document.getElementById("recurrence_limit_date").value = ""; or what is best?

mckillo commented 1 year ago

@Heklaterriol The error exits in the event created, in the new event doesn't exist. In the eventcreated, you must change this field into database (_jem_events.recurrence_limit_date to '0000-00-00', and it should be 'null'). It's important too, to change this data into import process (see https://github.com/Heklaterriol/JEM-Project/commit/70faf5c4c255e232bbdc27b71e9f991acf9e0b04), because in JEM 2.3.5, _jem_events.recurrence_limit_date to '0000-00-00' (by default), in all event don't use recurrence.

mckillo commented 1 year ago

Respect /com_jem/media/js/unlimited.js, If recurrence_limit_date value is null, don't have to do any split. And you are right, if <3 value must be "". Onen details: I don't found in code the call to function submit_unlimited. I think, that it doesn't used. Check it.