getQuery(true) ->select($db->qn('manifest_cache')) ->from($db->qn('#__extensions')) ->where($db->qn('element') . ' = ' . $db->q($component)) ->where($db->qn('type') . ' = ' . $db->q('component')); try { $json = $db->setQuery($query)->loadResult(); } catch (Exception $e) { return null; } if (empty($json)) { return null; } $options = json_decode($json, true); if (empty($options)) { return null; } if (!isset($options['version'])) { return null; } return $options['version']; } /** * Get a component's version from the manifest file on disk. IMPORTANT! The manifest for com_something must be named * something.xml. * * @param string $component The component's bname * * @return string The component version or null if none is defined * * @since 1.2.0 */ private static function getVersionFromManifest(string $component): ?string { $bareComponent = str_replace('com_', '', $component); $file = JPATH_ADMINISTRATOR . '/components/' . $component . '/' . $bareComponent . '.xml'; if (!is_file($file) || !is_readable($file)) { return null; } $data = @file_get_contents($file); if (empty($data)) { return null; } try { $xml = new SimpleXMLElement($data, LIBXML_COMPACT | LIBXML_NONET | LIBXML_ERR_NONE); } catch (Exception $e) { return null; } $versionNode = $xml->xpath('/extension/version'); if (empty($versionNode)) { return null; } return (string)($versionNode[0]); } }