Skip to content

Commit

Permalink
Use script.php to delete the obsolete tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
richard67 committed Jun 16, 2023
1 parent a85201c commit e68037d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
27 changes: 26 additions & 1 deletion administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ protected function uninstallExtensions()
* 'pre_function' => Name of an optional migration function to be called before
* uninstalling, `null` if not used.
*/
['type' => 'plugin', 'element' => 'demotasks', 'folder' => 'task', 'client_id' => 0, 'pre_function' => null],
['type' => 'plugin', 'element' => 'demotasks', 'folder' => 'task', 'client_id' => 0, 'pre_function' => 'deleteDemoTasks'],
];

$db = Factory::getDbo();
Expand Down Expand Up @@ -284,6 +284,31 @@ protected function uninstallExtensions()
}
}

/**
* This method deletes demo tasks of the obsolete demo task plugin.
*
* @param \stdClass $data Object with `extension_id`, `enabled` and `params` of the extension
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
private function deleteDemoTasks($data)
{
$db = Factory::getDbo();

try {
$db->setQuery(
$db->getQuery(true)
->delete($db->quoteName('#__scheduler_tasks'))
->where($db->quoteName('type') . ' = ' . $db->quote('demoTask_r1.sleep'))
)->execute();
} catch (\Exception $e) {
echo Text::sprintf('JLIB_DATABASE_ERROR_FUNCTION_FAILED', $e->getCode(), $e->getMessage()) . '<br>';
throw $e;
}
}

/**
* Update the manifest caches
*
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit e68037d

Please sign in to comment.