Version 4.7.23
This commit is contained in:
1 parent
7124a02564
commit
25ddeb65d6
1791 files changed
+76990
-44452
No files matched your search
@@ -26,11 +26,6 @@ class _updatecheck extends \IPS\Task
|
||||
* @brief Type to send to update server
|
||||
*/
|
||||
public $type = 'task';
|
||||
|
||||
/**
|
||||
* @brief Cache marketplace controller
|
||||
*/
|
||||
protected $_marketplaceController = null;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
@@ -145,19 +140,18 @@ class _updatecheck extends \IPS\Task
|
||||
catch( \RuntimeException $e ){ }
|
||||
|
||||
$updateChecked = [];
|
||||
$marketplaceUpdates = [];
|
||||
$fails = [];
|
||||
$fiveMinutesAgo = time() - 300;
|
||||
|
||||
$this->runUntilTimeout( function() use ( &$updateChecked, &$marketplaceUpdates, &$fails, $version, $fiveMinutesAgo ) {
|
||||
$this->runUntilTimeout( function() use ( &$updateChecked, &$fails, $version, $fiveMinutesAgo ) {
|
||||
try
|
||||
{
|
||||
$row = \IPS\Db::i()->union(
|
||||
array(
|
||||
\IPS\Db::i()->select( "'core_applications' AS `table`, app_directory AS `id`, app_update_check AS `url`, app_update_last_check AS `last`, app_long_version AS `current`, app_marketplace_id as `marketplace_id`", 'core_applications', "app_update_last_check<{$fiveMinutesAgo} AND ( ( app_update_check<>'' AND app_update_check IS NOT NULL ) OR app_marketplace_id IS NOT NULL )" ),
|
||||
\IPS\Db::i()->select( "'core_plugins' AS `table`, plugin_id AS id, plugin_update_check as url, plugin_update_check_last AS last, plugin_version_long AS `current`, plugin_marketplace_id as `marketplace_id`", 'core_plugins', "plugin_update_check_last<{$fiveMinutesAgo} AND ( (plugin_update_check<>'' AND plugin_update_check IS NOT NULL ) OR plugin_marketplace_id IS NOT NULL )" ),
|
||||
\IPS\Db::i()->select( "'core_themes' AS `table`, set_id AS `id`, set_update_check AS `url`, set_update_last_check AS `last`, set_long_version AS `current`, set_marketplace_id as `marketplace_id`", 'core_themes', "set_update_last_check<{$fiveMinutesAgo} AND ( (set_update_check<>'' AND set_update_check IS NOT NULL ) OR set_marketplace_id IS NOT NULL )" ),
|
||||
\IPS\Db::i()->select( "'core_sys_lang' AS `table`, lang_id AS `id`, `lang_update_url` AS `url`, `lang_update_check` AS `last`, `lang_version_long` AS `current`, `lang_marketplace_id` as `marketplace_id`", "core_sys_lang", "lang_update_check<{$fiveMinutesAgo} AND ( (lang_update_url<>'' AND lang_update_url IS NOT NULL ) OR lang_marketplace_id IS NOT NULL )" )
|
||||
\IPS\Db::i()->select( "'core_applications' AS `table`, app_directory AS `id`, app_update_check AS `url`, app_update_last_check AS `last`, app_long_version AS `current`", 'core_applications', "app_update_last_check<{$fiveMinutesAgo} AND ( app_update_check<>'' AND app_update_check IS NOT NULL )" ),
|
||||
\IPS\Db::i()->select( "'core_plugins' AS `table`, plugin_id AS id, plugin_update_check as url, plugin_update_check_last AS last, plugin_version_long AS `current`", 'core_plugins', "plugin_update_check_last<{$fiveMinutesAgo} AND ( plugin_update_check<>'' AND plugin_update_check IS NOT NULL )" ),
|
||||
\IPS\Db::i()->select( "'core_themes' AS `table`, set_id AS `id`, set_update_check AS `url`, set_update_last_check AS `last`, set_long_version AS `current`", 'core_themes', "set_update_last_check<{$fiveMinutesAgo} AND ( set_update_check<>'' AND set_update_check IS NOT NULL )" ),
|
||||
\IPS\Db::i()->select( "'core_sys_lang' AS `table`, lang_id AS `id`, `lang_update_url` AS `url`, `lang_update_check` AS `last`, `lang_version_long` AS `current`", "core_sys_lang", "lang_update_check<{$fiveMinutesAgo} AND ( lang_update_url<>'' AND lang_update_url IS NOT NULL )" )
|
||||
),
|
||||
'last ASC',
|
||||
1
|
||||
@@ -216,32 +210,8 @@ class _updatecheck extends \IPS\Task
|
||||
|
||||
try
|
||||
{
|
||||
/* Query the marketplace */
|
||||
if( $row['marketplace_id'] )
|
||||
{
|
||||
$marketplaceUpdates[ $row['marketplace_id'] ] = [
|
||||
'table' => $row['table'],
|
||||
'current' => $row['current'],
|
||||
'dataColumn' => $dataColumn,
|
||||
'timeColumn' => $timeColumn,
|
||||
'idColumn' => $idColumn,
|
||||
'id' => $row['id'],
|
||||
'marketplace_id'=> $row['marketplace_id']
|
||||
];
|
||||
|
||||
/* Update the timestamp so we can deal with other resources */
|
||||
\IPS\Db::i()->update( $row['table'], array(
|
||||
$timeColumn => time()
|
||||
), array( "{$idColumn}=?", $row['id'] ) );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
/* Query the applications update URL */
|
||||
else
|
||||
{
|
||||
$url = \IPS\Http\Url::external( $row['url'] )->setQueryString( array( 'version' => $row['current'], 'ips_version' => $version ) );
|
||||
$response = $url->request()->get()->decodeJson();
|
||||
}
|
||||
$url = \IPS\Http\Url::external( $row['url'] )->setQueryString( array( 'version' => $row['current'], 'ips_version' => $version ) );
|
||||
$response = $url->request()->get()->decodeJson();
|
||||
|
||||
/* Unset the object so it isn't present for next update check. */
|
||||
unset( $object );
|
||||
@@ -278,50 +248,6 @@ class _updatecheck extends \IPS\Task
|
||||
return TRUE;
|
||||
});
|
||||
|
||||
/* Check Marketplace updates in bulk */
|
||||
if( \count( $marketplaceUpdates ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$marketplaceController = new \IPS\core\modules\admin\marketplace\marketplace;
|
||||
$response = $marketplaceController->_updateCheck( array_column( $marketplaceUpdates, 'current', 'marketplace_id' ) );
|
||||
|
||||
foreach( $marketplaceUpdates as $resourceId => $resourceData )
|
||||
{
|
||||
$releaseData = $response[ $resourceId ] ?? NULL;
|
||||
|
||||
if( $releaseData !== NULL )
|
||||
{
|
||||
if( $resourceData['table'] == 'core_applications' )
|
||||
{
|
||||
$object = \IPS\Application::load( $resourceData['id'] );
|
||||
}
|
||||
elseif( $resourceData['table'] == 'core_plugins' )
|
||||
{
|
||||
$object = \IPS\Plugin::load( $resourceData['id'] );
|
||||
}
|
||||
|
||||
/* Use a local update URL */
|
||||
$releaseData['updateurl'] = (string) \IPS\Http\Url::internal("app=core&module=marketplace&controller=marketplace&do=viewFile&id={$resourceId}", 'admin' );
|
||||
if( isset( $object ) AND isset( $releaseData['disableresource'] ) AND $releaseData['disableresource'] === TRUE )
|
||||
{
|
||||
$object->_enabled = FALSE;
|
||||
$object->save();
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( $resourceData['table'], array(
|
||||
$resourceData['dataColumn'] => json_encode( $releaseData ),
|
||||
$resourceData['timeColumn'] => time()
|
||||
), array( "{$resourceData['idColumn']}=?", $resourceData['id'] ) );
|
||||
}
|
||||
}
|
||||
catch( \RuntimeException | \UnexpectedValueException $e )
|
||||
{
|
||||
$fails[] = '';
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset Menu Cache */
|
||||
foreach( $updateChecked as $type )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user