JoomlaPolska / jezyk-J4

Język polski dla Joomla 4
GNU General Public License v2.0
3 stars 5 forks source link

[5.0] Delete demo plugin #365

Closed joomlapl-bot closed 5 months ago

joomlapl-bot commented 1 year ago

PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/40147 Poniżej zmiany w oryginale:

Click to expand the diff! ```diff diff --git a/administrator/components/com_admin/script.php b/administrator/components/com_admin/script.php index b10c24775b739..4958a2109643c 100644 --- a/administrator/components/com_admin/script.php +++ b/administrator/components/com_admin/script.php @@ -229,6 +229,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], ]; $db = Factory::getDbo(); diff --git a/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-03-17.sql b/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-03-17.sql new file mode 100644 index 0000000000000..4f6aa1f79b567 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/mysql/5.0.0-2023-03-17.sql @@ -0,0 +1 @@ +DELETE FROM `#__scheduler_tasks` WHERE `type` = 'demoTask_r1.sleep'; diff --git a/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-03-17.sql b/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-03-17.sql new file mode 100644 index 0000000000000..c3bb4daede595 --- /dev/null +++ b/administrator/components/com_admin/sql/updates/postgresql/5.0.0-2023-03-17.sql @@ -0,0 +1 @@ +DELETE FROM "#__scheduler_tasks" WHERE "type" = 'demoTask_r1.sleep'; diff --git a/administrator/language/en-GB/plg_task_demotasks.ini b/administrator/language/en-GB/plg_task_demotasks.ini deleted file mode 100644 index b2d276c78a974..0000000000000 --- a/administrator/language/en-GB/plg_task_demotasks.ini +++ /dev/null @@ -1,19 +0,0 @@ -; Joomla! Project -; (C) 2021 Open Source Matters, Inc. -; License GNU General Public License version 2 or later; see LICENSE.txt -; Note : All ini files need to be saved as UTF-8 - -PLG_TASK_DEMO_TASKS="Task - Demo Tasks!" -PLG_TASK_DEMO_TASKS_SLEEP_TIMEOUT_LABEL="Sleep Timeout (seconds)" -PLG_TASK_DEMO_TASKS_STRESS_MEMORY_DESC="What happens to a task when the PHP memory limit is exhausted?" -PLG_TASK_DEMO_TASKS_STRESS_MEMORY_OVERRIDE_DESC="What happens to a task when the system memory is exhausted?" -PLG_TASK_DEMO_TASKS_STRESS_MEMORY_OVERRIDE_TITLE="Stress Memory, Override Limit" -PLG_TASK_DEMO_TASKS_STRESS_MEMORY_TITLE="Stress Memory" -PLG_TASK_DEMO_TASKS_RESUMABLE_TITLE="Resumable Task" -PLG_TASK_DEMO_TASKS_RESUMABLE_DESC="A simple task to demonstrate resumable task behaviour." -PLG_TASK_DEMO_TASKS_RESUMABLE_STEPS_LABEL="Total number of steps" -PLG_TASK_DEMO_TASKS_RESUMABLE_TIMEOUT_LABEL="Delay per step (seconds)" -PLG_TASK_DEMO_TASKS_TASK_SLEEP_DESC="Sleep, do nothing for x seconds." -PLG_TASK_DEMO_TASKS_TASK_SLEEP_ROUTINE_END_LOG_MESSAGE="TestTask1 return code is: %1$d. Processing Time: %2$.2f seconds" -PLG_TASK_DEMO_TASKS_TASK_SLEEP_TITLE="Demo Task - Sleep" -PLG_TASK_DEMO_TASKS_XML_DESCRIPTION="This is a demo plugin for the development of Joomla! Scheduled Tasks." diff --git a/administrator/language/en-GB/plg_task_demotasks.sys.ini b/administrator/language/en-GB/plg_task_demotasks.sys.ini deleted file mode 100644 index 6e691072a04ba..0000000000000 --- a/administrator/language/en-GB/plg_task_demotasks.sys.ini +++ /dev/null @@ -1,7 +0,0 @@ -; Joomla! Project -; (C) 2021 Open Source Matters, Inc. -; License GNU General Public License version 2 or later; see LICENSE.txt -; Note : All ini files need to be saved as UTF-8 - -PLG_TASK_DEMO_TASKS="Task - Demo Tasks!" -PLG_TASK_DEMO_TASKS_XML_DESCRIPTION="This is a demo plugin for the development of Joomla! Scheduled Tasks." diff --git a/installation/sql/mysql/base.sql b/installation/sql/mysql/base.sql index d181db1fbcfe4..fb0e213ec8e83 100644 --- a/installation/sql/mysql/base.sql +++ b/installation/sql/mysql/base.sql @@ -357,7 +357,6 @@ INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, (0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0), (0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 24, 0), (0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 1, '', '{}', '', 1, 0), -(0, 'plg_task_demotasks', 'plugin', 'demotasks', 'task', 0, 1, 1, 0, 1, '', '{}', '', 2, 0), (0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 1, '', '{}', '', 3, 0), (0, 'plg_task_sitestatus', 'plugin', 'sitestatus', 'task', 0, 1, 1, 0, 1, '', '{}', '', 4, 0), (0, 'plg_multifactorauth_totp', 'plugin', 'totp', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 1, 0), diff --git a/installation/sql/postgresql/base.sql b/installation/sql/postgresql/base.sql index 9bf300f290b23..4938db2808431 100644 --- a/installation/sql/postgresql/base.sql +++ b/installation/sql/postgresql/base.sql @@ -363,7 +363,6 @@ INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", (0, 'plg_system_updatenotification', 'plugin', 'updatenotification', 'system', 0, 1, 1, 0, 1, '', '', '', 23, 0), (0, 'plg_system_webauthn', 'plugin', 'webauthn', 'system', 0, 1, 1, 0, 1, '', '{}', '', 24, 0), (0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 1, '', '{}', '', 1, 0), -(0, 'plg_task_demotasks', 'plugin', 'demotasks', 'task', 0, 1, 1, 0, 1, '', '{}', '', 2, 0), (0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 1, '', '{}', '', 3, 0), (0, 'plg_task_sitestatus', 'plugin', 'sitestatus', 'task', 0, 1, 1, 0, 1, '', '{}', '', 4, 0), (0, 'plg_multifactorauth_totp', 'plugin', 'totp', 'multifactorauth', 0, 1, 1, 0, 1, '', '', '', 1, 0), diff --git a/libraries/src/Extension/ExtensionHelper.php b/libraries/src/Extension/ExtensionHelper.php index 9677624181e2c..fd0ae4d019bc2 100644 --- a/libraries/src/Extension/ExtensionHelper.php +++ b/libraries/src/Extension/ExtensionHelper.php @@ -309,7 +309,6 @@ class ExtensionHelper // Core plugin extensions - task scheduler ['plugin', 'checkfiles', 'task', 0], - ['plugin', 'demotasks', 'task', 0], ['plugin', 'requests', 'task', 0], ['plugin', 'sitestatus', 'task', 0], diff --git a/plugins/task/demotasks/demotasks.xml b/plugins/task/demotasks/demotasks.xml deleted file mode 100644 index 2ea1425e3bc9e..0000000000000 --- a/plugins/task/demotasks/demotasks.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - plg_task_demo_tasks - Joomla! Project - 2021-07 - (C) 2021 Open Source Matters, Inc. - GNU General Public License version 2 or later; see LICENSE.txt - admin@joomla.org - www.joomla.org - 4.1 - PLG_TASK_DEMO_TASKS_XML_DESCRIPTION - Joomla\Plugin\Task\DemoTasks - - services - src - forms - - - language/en-GB/plg_task_demotasks.ini - language/en-GB/plg_task_demotasks.sys.ini - - diff --git a/plugins/task/demotasks/forms/testTaskForm.xml b/plugins/task/demotasks/forms/testTaskForm.xml deleted file mode 100644 index bddef6c79395f..0000000000000 --- a/plugins/task/demotasks/forms/testTaskForm.xml +++ /dev/null @@ -1,18 +0,0 @@ - -
- -
- -
-
-
diff --git a/plugins/task/demotasks/services/provider.php b/plugins/task/demotasks/services/provider.php deleted file mode 100644 index 42c908c9835c3..0000000000000 --- a/plugins/task/demotasks/services/provider.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -defined('_JEXEC') or die; - -use Joomla\CMS\Extension\PluginInterface; -use Joomla\CMS\Factory; -use Joomla\CMS\Plugin\PluginHelper; -use Joomla\DI\Container; -use Joomla\DI\ServiceProviderInterface; -use Joomla\Event\DispatcherInterface; -use Joomla\Plugin\Task\DemoTasks\Extension\DemoTasks; - -return new class () implements ServiceProviderInterface { - /** - * Registers the service provider with a DI container. - * - * @param Container $container The DI container. - * - * @return void - * - * @since 4.2.0 - */ - public function register(Container $container) - { - $container->set( - PluginInterface::class, - function (Container $container) { - $dispatcher = $container->get(DispatcherInterface::class); - - $plugin = new DemoTasks( - $dispatcher, - (array) PluginHelper::getPlugin('task', 'demotasks') - ); - $plugin->setApplication(Factory::getApplication()); - - return $plugin; - } - ); - } -}; diff --git a/plugins/task/demotasks/src/Extension/DemoTasks.php b/plugins/task/demotasks/src/Extension/DemoTasks.php deleted file mode 100644 index 8a1f6d557b432..0000000000000 --- a/plugins/task/demotasks/src/Extension/DemoTasks.php +++ /dev/null @@ -1,223 +0,0 @@ - - * @license GNU General Public License version 2 or later; see LICENSE.txt - */ - -namespace Joomla\Plugin\Task\DemoTasks\Extension; - -use Joomla\CMS\Plugin\CMSPlugin; -use Joomla\Component\Scheduler\Administrator\Event\ExecuteTaskEvent; -use Joomla\Component\Scheduler\Administrator\Task\Status; -use Joomla\Component\Scheduler\Administrator\Task\Task; -use Joomla\Component\Scheduler\Administrator\Traits\TaskPluginTrait; -use Joomla\Event\SubscriberInterface; - -// phpcs:disable PSR1.Files.SideEffects -\defined('_JEXEC') or die; -// phpcs:enable PSR1.Files.SideEffects - -/** - * A demo task plugin. Offers 3 task routines and demonstrates the use of {@see TaskPluginTrait}, - * {@see ExecuteTaskEvent}. - * - * @since 4.1.0 - */ -final class DemoTasks extends CMSPlugin implements SubscriberInterface -{ - use TaskPluginTrait; - - /** - * @var string[] - * @since 4.1.0 - */ - private const TASKS_MAP = [ - 'demoTask_r1.sleep' => [ - 'langConstPrefix' => 'PLG_TASK_DEMO_TASKS_TASK_SLEEP', - 'method' => 'sleep', - 'form' => 'testTaskForm', - ], - 'demoTask_r2.memoryStressTest' => [ - 'langConstPrefix' => 'PLG_TASK_DEMO_TASKS_STRESS_MEMORY', - 'method' => 'stressMemory', - ], - 'demoTask_r3.memoryStressTestOverride' => [ - 'langConstPrefix' => 'PLG_TASK_DEMO_TASKS_STRESS_MEMORY_OVERRIDE', - 'method' => 'stressMemoryRemoveLimit', - ], - 'demoTask_r4.resumable' => [ - 'langConstPrefix' => 'PLG_TASK_DEMO_TASKS_RESUMABLE', - 'method' => 'resumable', - 'form' => 'testTaskForm', - ], - ]; - - /** - * @var boolean - * @since 4.1.0 - */ - protected $autoloadLanguage = true; - - /** - * @inheritDoc - * - * @return string[] - * - * @since 4.1.0 - */ - public static function getSubscribedEvents(): array - { - return [ - 'onTaskOptionsList' => 'advertiseRoutines', - 'onExecuteTask' => 'standardRoutineHandler', - 'onContentPrepareForm' => 'enhanceTaskItemForm', - ]; - } - - /** - * Sample resumable task. - * - * Whether the task will resume is random. There's a 40% chance of finishing every time it runs. - * - * You can use this as a template to create long running tasks which can detect an impending - * timeout condition, return Status::WILL_RESUME and resume execution next time they are called. - * - * @param ExecuteTaskEvent $event The event we are handling - * - * @return integer - * - * @since 4.1.0 - * @throws \Exception - */ - private function resumable(ExecuteTaskEvent $event): int - { - /** @var Task $task */ - $task = $event->getArgument('subject'); - $timeout = (int) $event->getArgument('params')->timeout ?? 1; - - $lastStatus = $task->get('last_exit_code', Status::OK); - - // This is how you detect if you are resuming a task or starting it afresh - if ($lastStatus === Status::WILL_RESUME) { - $this->logTask(sprintf('Resuming task %d', $task->get('id'))); - } else { - $this->logTask(sprintf('Starting new task %d', $task->get('id'))); - } - - // Sample task body; we are simply sleeping for some time. - $this->logTask(sprintf('Starting %ds timeout', $timeout)); - sleep($timeout); - $this->logTask(sprintf('%ds timeout over!', $timeout)); - - // Should I resume the task in the next step (randomly decided)? - $willResume = random_int(0, 5) < 4; - - // Log our intention to resume or not and return the appropriate exit code. - if ($willResume) { - $this->logTask(sprintf('Task %d will resume', $task->get('id'))); - } else { - $this->logTask(sprintf('Task %d is now complete', $task->get('id'))); - } - - return $willResume ? Status::WILL_RESUME : Status::OK; - } - - /** - * @param ExecuteTaskEvent $event The `onExecuteTask` event. - * - * @return integer The routine exit code. - * - * @since 4.1.0 - * @throws \Exception - */ - private function sleep(ExecuteTaskEvent $event): int - { - $timeout = (int) $event->getArgument('params')->timeout ?? 1; - - $this->logTask(sprintf('Starting %d timeout', $timeout)); - sleep($timeout); - $this->logTask(sprintf('%d timeout over!', $timeout)); - - return Status::OK; - } - - /** - * Standard routine method for the memory test routine. - * - * @param ExecuteTaskEvent $event The `onExecuteTask` event. - * - * @return integer The routine exit code. - * - * @since 4.1.0 - * @throws \Exception - */ - private function stressMemory(ExecuteTaskEvent $event): int - { - $mLimit = $this->getMemoryLimit(); - $this->logTask(sprintf('Memory Limit: %d KB', $mLimit)); - - $iMem = $cMem = memory_get_usage(); - $i = 0; - - while ($cMem + ($cMem - $iMem) / ++$i <= $mLimit) { - $this->logTask(sprintf('Current memory usage: %d KB', $cMem)); - ${"array" . $i} = array_fill(0, 100000, 1); - } - - return Status::OK; - } - - /** - * Standard routine method for the memory test routine, also attempts to override the memory limit set by the PHP - * INI. - * - * @param ExecuteTaskEvent $event The `onExecuteTask` event. - * - * @return integer The routine exit code. - * - * @since 4.1.0 - * @throws \Exception - */ - private function stressMemoryRemoveLimit(ExecuteTaskEvent $event): int - { - $success = false; - - if (function_exists('ini_set')) { - $success = ini_set('memory_limit', -1) !== false; - } - - $this->logTask('Memory limit override ' . $success ? 'successful' : 'failed'); - - return $this->stressMemory($event); - } - - /** - * Processes the PHP ini memory_limit setting, returning the memory limit in KB - * - * @return float - * - * @since 4.1.0 - */ - private function getMemoryLimit(): float - { - $memoryLimit = ini_get('memory_limit'); - - if (preg_match('/^(\d+)(.)$/', $memoryLimit, $matches)) { - if ($matches[2] == 'M') { - // * nnnM -> nnn MB - $memoryLimit = $matches[1] * 1024 * 1024; - } else { - if ($matches[2] == 'K') { - // * nnnK -> nnn KB - $memoryLimit = $matches[1] * 1024; - } - } - } - - return (float) $memoryLimit; - } -} ```