phpjoomlajoomla-extensions

Notice: Trying to get property of non-object in ../libraries/src/UCM/UCMType.php on line 169


When I tried to install the Joomla! extension JCH, I came up with the title message above after finished installing. I asked the developer and he replied that I don't have to worry about the extension as this is a Joomla! issue that it will not affect the way the extension works.

The line 169 of UCMType.php is the following:

$tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;

And the specific part of the UCMType.php that includes line 169:

public function getTypeByTable($tableName)
    {
        $query = $this->db->getQuery(true);
        $query->select('ct.*');
        $query->from($this->db->quoteName('#__content_types', 'ct'));

        // $query->where($this->db->quoteName('ct.type_alias') . ' = ' . (int) $typeAlias);
        $this->db->setQuery($query);

        $types = $this->db->loadObjectList();

        foreach ($types as $type)
        {
            $tableFromType = json_decode($type->table);
            $tableNameFromType = $tableFromType->special->prefix . $tableFromType->special->type;

            if ($tableNameFromType === $tableName)
            {
                return $type;
            }
        }

        return false;
    }

Solution

  • You really do not have to give too much attention for this issue, so the third party extension developer was right in this. This is more like a small bug (thus the Notice is there), not a serious Error. Your site will operate without a problem.

    As you see in this Notice, in the foreach(){} loop a variable is tried to be defined from another variable which is not an Object, so it is just getting back a NULL value or another TYPE most probably, which does not have an Object property what is expected there.

    In this particular case this whole thing happens in a relatively new Joomla core class and interface (UCM and UCMType). In this class they want to define a content type by table and this part of the code has to be modified, improved by core Joomla developers.

    What should you do?

    1. If you want to help the development of Joomla and yourself a bit then please report this issue here: https://developer.joomla.org/tracker.html , and they will check and repair this most probably.

    2. This PHP (error) Notice is usually for developers, so if your site is a live site you should not see this Notice basically. If you see this on live site, that could mean that either your Joomla error reporting is set incorrectly, or your server error reporting default is set incorrectly.

    In your Joomla admin at System->Global Configuration->Server->Error reporting has to be set to System Default or to None. Thus these not relevant notices will not appear for users, visitors of your site. Other settings only recommended if your site is not a live site and you develop that further in a staging copy for example.

    And please if you have Joomla questions, visit the Joomla Stack Exchange here: https://joomla.stackexchange.com/questions and please ask your questions regarding Joomla there.

    I hope the above cleared the issue for you.