News:

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

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
  •