News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

Main Menu
Support-Forum

Joomla 4 Error when adding a download from the site - [Not really a bug!]

Started by jononorvic, 20.12.2023 18:26:55

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jononorvic

When I try to create a download through the site, I get error message:

Save failed with the following error: Incorrect datetime value: '-0001-11-30 00:00:00' for column 'modified' at row 1

I presume this is the same error as that reported in "Joomla 5 Error when adding a download from the site" https://www.jdownloads.com/forum/index.php?topic=14136.msg50456#msg50456.

Versions are: Joomla! 4.2.6; jDownloads 4.0.36; PHP 8.1.26; MySQL 5.7.44.
Templates: standard Cassiopeia and Atum
Site: originally Joomla! 3.10.11 with jDownloads Version 3.9.8.4. Joomla updated to 4.2.6 with jDownloads disabled.  jDownloads updated later by following relevant parts of "Upgrading from jD3.9 to jD4" https://www.jdownloads.net/documentation/getting-started-v3-9/upgrading-from-jd3-9-to-jd4. Settings are default (I think).
  •  

ColinM

Hi
Yes this is the same error as that reported in "Joomla 5 Error when adding a download from the site".

Just for clarity were you adding Download from:
(1)Frontend, (2)Backend using'Check Download Area', (3)Using the Backend 'Files' or (4) directly in the Backend Downloads 'New' button ?

Colin
Colin M
  •  

jononorvic

I was adding from the frontend.

The files (I tried more than once) were uploaded and are shown by 'Check Download Area' to be in the correct jdownloads sub-folder. (They are also shown by Plesk's File Manager.) They are not shown anywhere else in the backend.

I can successfully add a file from the backend using either Backend 'Files:Upload Files' or the Backend Downloads 'New' button.

Are there any other checks I could make that would be useful?

John
  •  

Arno

Hi,
could I get access to your backend and to your database?
If so, send the data via PM.

By the way, I could not reproduce your problem here. Just like the other error report you mentioned. Perhaps the data field has not been converted correctly?
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

Florian

Hi,

I confirm same mistake: jDownloads 4.0.39 and Joomla 4.4.2

I can add Downloads from Backend. But in Frontend my Users face this error after upgrade to J4 and jD 4 . I have to ask them to send their Download to me.
Happy Coding with Joomla and jDownloads
  •  

Arno

Hi,
thanks for the info.

Did you also have this approach?

QuoteSite: originally Joomla! 3.10.11 with jDownloads Version 3.9.8.4. Joomla updated to 4.2.6 with jDownloads disabled.  jDownloads updated later by following relevant parts of "Upgrading from jD3.9 to jD4" https://www.jdownloads.net/documentation/getting-started-v3-9/upgrading-from-jd3-9-to-jd4.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

Florian

Hi Arno,

yes I disabled jDwonloads before I did the upgrade from Joomla 3.10 to 4.4. Afterwards I installed jDownloads 4.0.36 and now updated to 4.0.39 .
Happy Coding with Joomla and jDownloads
  •  

ColinM

Hi
Just for clarity, when you say you disabled jDownloads does that mean you only disabled jDownloads 3.9 System Plugin?

Colin
Colin M
  •  

Florian

Hi,

no I disabled every single jDownloads extension before Upgrade.
Happy Coding with Joomla and jDownloads
  •  

Florian

Hi,

what I understand is that jDwonloads tries to save a new Download where modified is NULL and tries to enter this nonsense date. Table __jdwnloads_files does not allow NULL nor this artificial '-0001-11-30 00:00:00' modified date. Therefore MYSQL reports this error.

My proposal: Allow NULL as modified date and use that for new downloads_files.
Happy Coding with Joomla and jDownloads
  •  

Florian

Okay Arno,

I think I found the solution. You have defined field modified as required and NOT NULL in table. Now you must also fill it with something when you create a new Download. But you only fill it on existing Downloads while editing.

Add a line in administrator/components/com_jdownloads/src/Table/DownloadTable.php to also fill modified with today's date. I listed 2lines before and after so that you can easily find it.

                // fill out created date field
                $this->created = Factory::getDate()->toSql();
$this->modified = Factory::getDate()->toSql();
                if (!$this->created_by){
                    // we use only automaticly the user ID when the user list is not listed in the form (this is selectable in the jD User Groups Settings)
Happy Coding with Joomla and jDownloads
  •  
    The following users thanked this post: rivan

rivan

Quote from: Florian on 17.01.2024 17:59:16Okay Arno,

I think I found the solution. You have defined field modified as required and NOT NULL in table. Now you must also fill it with something when you create a new Download. But you only fill it on existing Downloads while editing.

Add a line in administrator/components/com_jdownloads/src/Table/DownloadTable.php to also fill modified with today's date. I listed 2lines before and after so that you can easily find it.

                // fill out created date field
                $this->created = Factory::getDate()->toSql();
$this->modified = Factory::getDate()->toSql();
                if (!$this->created_by){
                    // we use only automaticly the user ID when the user list is not listed in the form (this is selectable in the jD User Groups Settings)


Thank you very much! It helped!
  •  

Florian

Hi Rivan,

great that I could be of help.

Arno must decide whether he wants to allow empty (NULL) modified date or wants to set it to day of creation as he does in Admin backend. That is exactly what my patch does.

I would find it more logical to allow NULL in database field "modified" and change backend tso that it also leaves modified date empty with new downloads.
Happy Coding with Joomla and jDownloads
  •  
    The following users thanked this post: Arno

Arno

Hi Florian,
sorry for the delay. Unfortunately, I have not been able to spend the time I actually needed for jDownloads and support in the last few weeks. And then I also had to migrate the website to Joomla 4. But I hope to have more time next week.

I'll probably implement your fix, but I'll have another look at it. Thank you!

[Fixed in 4.0.40, coming soon]
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

Arno

I have now tested it again here with the latest version 4.0.39 and cannot reproduce this error. Are you sure you are using the latest files (and table definitions)?

I have tested it with two different user group settings:
- with activated form field modified
- without display of form field modified

The field is checked in DownloadTable.php from line 1430 in store() function:

// Set modified to created date if not set
            if (!(int) $this->modified)
            {
                $this->modified = $this->created;
            }

            // Set modified_by to created_by user if not set
            if (empty($this->modified_by))
            {
                $this->modified_by = $this->created_by;
            }

Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •