You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装Joomla扩展JCH后出现非对象属性获取通知的技术问询

Fixing the "Trying to get property of non-object" Notice in Joomla's UCMType.php Line 169

What's the Issue?

After installing the JCH extension, you're seeing this PHP notice pop up:

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

The Good News First

Per the JCH extension developer, this is not a problem with the JCH extension itself—it's a small quirk in Joomla's core code. Even better: it won't affect how the JCH extension functions at all.

Why This Happens

Let's break down the problematic code. The error hits on line 169 of UCMType.php:

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

Here's the full surrounding function context:

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;
}

The bug stems from this: json_decode($type->table) might return null or a non-object (if the table field in the #__content_types database table has invalid JSON, or is empty). When that happens, trying to access $tableFromType->special throws the notice because $tableFromType isn't the object the code expects.

How to Handle It

Since this doesn't break your JCH extension, you have two straightforward options:

  • Hide the notice (easiest fix): Head to your Joomla backend's Global Configuration, find the "Error Reporting" setting, and set it to "System Default" or "None". This will suppress non-critical PHP notices like this one without affecting functionality.
  • Patch the core code (advanced): If you want to fix the root cause, add a validation check right after the json_decode line to skip invalid entries:
    // Insert this after $tableFromType = json_decode($type->table);
    if (!is_object($tableFromType) || !isset($tableFromType->special)) {
        continue;
    }
    
    Note: Modifying Joomla core code means your change will get overwritten when you update Joomla, so the first option is usually the safer choice for most users.

内容的提问来源于stack exchange,提问作者GalanopD

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:12:04