Skip to content

Instantly share code, notes, and snippets.

@renekreijveld
Last active September 26, 2020 19:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save renekreijveld/978523c79183b615917c03130505aad1 to your computer and use it in GitHub Desktop.
Save renekreijveld/978523c79183b615917c03130505aad1 to your computer and use it in GitHub Desktop.
List extension updates
<?php
/**
* @package Joomla.Cli
*
* @copyright Copyright (C) 2016 Rene Kreijveld, All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
/**
* This is a script which should be called from the command-line, not the web.
*/
// Set flag that this is a parent file.
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';
// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';
/**
* This script lists all extensionupdates for you Joomla website.
* Put this scrpt in the cli folder of your Joomla website.
*/
class Listupdates extends JApplicationCli
{
/**
* Entry point for the script
*
* @return void
*
* @since 2.5
*/
public function doExecute()
{
// Get the update cache time
$db = JFactory::getDBO();
$component = JComponentHelper::getComponent('com_installer');
$params = $component->params;
$cache_timeout = $params->get('cachetimeout', 6, 'int');
$cache_timeout = 3600 * $cache_timeout;
// Find all updates
$updater = JUpdater::getInstance();
$updater->findUpdates(0, $cache_timeout);
$query = $db->getQuery(true)
->select($db->quoteName(array('name','version')))
->from($db->quoteName('#__updates'))
->where($db->quoteName('extension_id') . ' > 0');
$db->setQuery($query);
$updates = $db->loadObjectList();
if ($updates)
{
$this->out("The following updates were found:");
foreach ($updates as $update)
{
$this->out("Extension: $update->name, version: $update->version");
}
}
}
}
JApplicationCli::getInstance('Listupdates')->execute();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment