jDownloadsownloads.com


Author Topic: jD3.2.63 PHP Warning: Creating default object from empty value  (Read 1088 times)

0 Members and 1 Guest are viewing this topic.

Offline LUCiD

  • Newbie
  • *
  • Posts: 15
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:
Code: [Select]
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:
Code: [Select]
$this->_children[$i]->tags->getItemTags('com_jdownloads.category',  $this->_children[$i]->id);
The whole if block from line 468 to 474 is this:
Code: [Select]
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:
Code: [Select]
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!
« Last Edit: 19.01.2019 21:14:55 by LUCiD »
Best regards / Beste Grüße

Offline Arno

  • Administrator
  • ***
  • Posts: 12.312
    • jDownloads.com
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!

Offline LUCiD

  • Newbie
  • *
  • Posts: 15
Hi Arno :)

You're welcome!
Keep up the great work!

And have a good time!

Cheers!
Best regards / Beste Grüße