News:

Support for jDownloads 3 has been ended
Since 17 August 2023 Joomla.org has discontinued support for Joomla 3.x. Therefore, we will no longer offer official support for our Joomla 3 jDownloads version 3.9.x from January 2024.
Please update your website to the latest Joomla version (Joomla 4 or Joomla 5) as soon as possible. Afterwards, please update jDownloads to the latest published version. The longer you delay, the more difficult the upgrade process for your website is likely to be.

Main Menu
Support-Forum

jD3.2.63 PHP Warning: Creating default object from empty value

Started by LUCiD, 19.01.2019 20:58:25

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LUCiD

Hi there,
I got a PHP warning message in my server logs related to jDownloader, if someone attempt to access a category wich does not (longer) exist.
I think it is related to the PHP Version 7 - I use PHP V7.1.25 with the latest Joomla V3.9.2

The Warning:
Got error 'PHP message: PHP Warning:  Creating default object from empty value in /components/com_jdownloads/models/category.php on line 472

Here is the line 472 from that category.php file:$this->_children[$i]->tags->getItemTags('com_jdownloads.category',  $this->_children[$i]->id);

The whole if block from line 468 to 474 is this:
if (count($this->_children)){
                for ($i = 0; $i < count($this->_children); $i++) {
                        // Get the tags
                        $this->_children[$i]->tags = new JHelperTags;
                        $this->_children[$i]->tags->getItemTags('com_jdownloads.category',  $this->_children[$i]->id);
                }
            }


I have made changes as a workaround to get rid of that warning:
if (count($this->_children)){
                for ($i = 0; $i < count($this->_children); $i++) {
                    if(isset($this->_children[$i]))
                    {
                        // Get the tags
                        $this->_children[$i]->tags = new JHelperTags;
                        $this->_children[$i]->tags->getItemTags('com_jdownloads.category',  $this->_children[$i]->id);
                    }
                }
            }


Because "count($this->_children)" returns 1 the block is entered, but "$this->_children[$i]" is NULL and therefore the warning occours, so I've made an extra check if the "$this->_children[$i]" is set or not.

I hope that will help.
Greetings!
Best regards / Beste Grüße
  •  

Arno

Many thanks for your helpful post. ;)
I will add your fix in the next version.
Best Regards / Gruß
Arno
Please make a Donation for jDownloads and/or write a review on the Joomla! Extensions directory!
  •  

LUCiD

Hi Arno :)

You're welcome!
Keep up the great work!

And have a good time!

Cheers!
Best regards / Beste Grüße
  •