Back to Update class

Method _endElement

public void
_endElement
(mixed $parser, mixed $name)
Callback for closing the element
Parameters
  • object $parser Parser object
  • string $name Name of element that was closed
Returns
  • void
Since
  • 1.7.0
-
  • This is public because it is called externally
Class: Update
Project: Joomla

Method _endElement - Source code

/**
 * Callback for closing the element
 *
 * @param   object  $parser  Parser object
 * @param   string  $name    Name of element that was closed
 *
 * @return  void
 *
 * @note    This is public because it is called externally
 * @since   1.7.0
 */
public function _endElement($parser, $name)
{
    array_pop($this->stack);
    switch ($name) {
        // Closing update, find the latest version and check
        case 'UPDATE':
            $product = strtolower(InputFilter::getInstance()->clean(Version::PRODUCT, 'cmd'));
            // Check that the product matches and that the version matches (optionally a regexp)
            if (isset($this->currentUpdate->targetplatform->name) && $product == $this->currentUpdate->targetplatform->name && preg_match('/^' . $this->currentUpdate->targetplatform->version . '/', $this->get('jversion.full', JVERSION))) {
                $phpMatch = false;
                // Check if PHP version supported via <php_minimum> tag, assume true if tag isn't present
                if (!isset($this->currentUpdate->php_minimum) || version_compare(PHP_VERSION, $this->currentUpdate->php_minimum->_data, '>=')) {
                    $phpMatch = true;
                }
                $dbMatch = false;
                // Check if DB & version is supported via <supported_databases> tag, assume supported if tag isn't present
                if (isset($this->currentUpdate->supported_databases)) {
                    $db = Factory::getDbo();
                    $dbType = strtolower($db->getServerType());
                    $dbVersion = $db->getVersion();
                    $supportedDbs = $this->currentUpdate->supported_databases;
                    // MySQL and MariaDB use the same database driver but not the same version numbers
                    if ($dbType === 'mysql') {
                        // Check whether we have a MariaDB version string and extract the proper version from it
                        if (stripos($dbVersion, 'mariadb') !== false) {
                            // MariaDB: Strip off any leading '5.5.5-', if present
                            $dbVersion = preg_replace('/^5\\.5\\.5-/', '', $dbVersion);
                            $dbType = 'mariadb';
                        }
                    }
                    // Do we have an entry for the database?
                    if (isset($supportedDbs->{$dbType})) {
                        $minimumVersion = $supportedDbs->{$dbType};
                        $dbMatch = version_compare($dbVersion, $minimumVersion, '>=');
                    }
                } else {
                    // Set to true if the <supported_databases> tag is not set
                    $dbMatch = true;
                }
                // Check minimum stability
                $stabilityMatch = true;
                if (isset($this->currentUpdate->stability) && $this->currentUpdate->stability < $this->minimum_stability) {
                    $stabilityMatch = false;
                }
                if ($phpMatch && $stabilityMatch && $dbMatch) {
                    if (!empty($this->currentUpdate->downloadurl) && !empty($this->currentUpdate->downloadurl->_data)) {
                        $this->compatibleVersions[] = $this->currentUpdate->version->_data;
                    }
                    if (!isset($this->latest) || version_compare($this->currentUpdate->version->_data, $this->latest->version->_data, '>')) {
                        $this->latest = $this->currentUpdate;
                    }
                }
            }
            break;
        case 'UPDATES':
            // If the latest item is set then we transfer it to where we want to
            if (isset($this->latest)) {
                foreach (get_object_vars($this->latest) as $key => $val) {
                    $this->{$key} = $val;
                }
                unset($this->latest);
                unset($this->currentUpdate);
            } elseif (isset($this->currentUpdate)) {
                // The update might be for an older version of j!
                unset($this->currentUpdate);
            }
            break;
    }
}
OSZAR »