Skip to content

Conversation

@alikon
Copy link
Contributor

@alikon alikon commented May 24, 2022

Summary of Changes

Added a new task to start the scheduler on a friend site via Webcron

Testing Instructions

apply pr (on site A)
discover extension and install the new task plugin
enable the plugin

(on site B) site suppose that doesn't have crontab
enable the webcron
image
copy the link
enable some task ie (sleep) for example

on site (A)
create a new task WebCronStarter
image
and paste the URL copied before from (site B)
run the scheduler from cli for example
php cli/joomla.php scheduler:run

(on site B)
check that the task have been executed

Actual result BEFORE applying this Pull Request

N/A

Expected result AFTER applying this Pull Request

you can schedule a task to start the scheduler on a friend site via webcron

Documentation Changes Required

@joomla-cms-bot joomla-cms-bot added Language Change This is for Translators PR-4.2-dev labels May 24, 2022
@alikon alikon marked this pull request as ready for review May 24, 2022 14:27
@richard67
Copy link
Member

I can not see any SQL script changes in this PR to add the new plugin to the extensions table, neither in base.sql for new installation nor in a new update SQL script for updates.

@alikon
Copy link
Contributor Author

alikon commented May 24, 2022

i'll add...
but as it is , is testable, just discover

@richard67
Copy link
Member

i'll add...
but as it is , is testable, just discover

Yes, it is testable in this state … but not mergeable ;-)

@richard67
Copy link
Member

richard67 commented May 24, 2022

@alikon Regarding the update SQL scripts please look up in other update SQL scripts of the 4.2-dev branch how we add extensions, especially regarding the new INSERT IGNORE (MySQL) or ON CONFLICT DO NOTHING (PostgreSQL) which was introduced with PR #37156 , and also regarding columns which we do not use in update SQL scripts when inserting extensions.

Update: Silly me, that’s not needed here.

@richard67
Copy link
Member

@alikon In addition, make sure to use the right “ordering” values in the I sent statements in the update SQL script. The values should be the same as in base.sql, but currently they are different in your PR (16 in the update SQL versus 5 in base.sql).

@alikon
Copy link
Contributor Author

alikon commented May 24, 2022

@richard67 frankly speaking i don't think... those are "strictly" needed.
anyway feel free to enhance it, this pr is open

p.s
for the ordering field what I should do ?

@richard67
Copy link
Member

richard67 commented May 24, 2022

@richard67 frankly speaking i don't think... those are "strictly" needed. anyway feel free to enhance it, this pr is open

In my PR to which I referred to it is explained in detail why they were added, and it should not be a big thing for you to add that here, too. I am off my desk today and limited to mobile so I won’t be able to make a PR.

Update: Sorry for the confusion. I just see we don’t need that here in this case.

p.s for the ordering field what I should do ?

Use value 5 and not 16 in the update SQL script.

@richard67
Copy link
Member

@richard67 frankly speaking i don't think... those are "strictly" needed. anyway feel free to enhance it, this pr is open

@alikon I just see I was wrong, we do not need INSERT IGNORE here, it was for other cases where we used IDs. Sorry for the confusion.

@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
(0, 'plg_task_webcronstart', 'plugin', 'webcronstart', 'task', 0, 1, 1, 0, 0, '', '{}', '', 16, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(0, 'plg_task_webcronstart', 'plugin', 'webcronstart', 'task', 0, 1, 1, 0, 0, '', '{}', '', 16, 0);
(0, 'plg_task_webcronstart', 'plugin', 'webcronstart', 'task', 0, 1, 1, 0, 0, '', '{}', '', 5, 0);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why 5 ??
https://github.com/joomla/joomla-cms/blob/4.2-dev/administrator/components/com_admin/sql/updates/postgresql/4.1.0-2021-11-20.sql#L47-L53

-- Add plugins to "#__extensions"
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'plg_system_schedulerunner', 'plugin', 'schedulerunner', 'system', 0, 1, 1, 0, 0, '', '{}', '', 15, 0),
(0, 'plg_system_tasknotification', 'plugin', 'tasknotification', 'system', 0, 1, 1, 0, 1, '', '', '', 22, 0),
(0, 'plg_task_checkfiles', 'plugin', 'checkfiles', 'task', 0, 1, 1, 0, 0, '', '{}', '', 15, 0),
(0, 'plg_task_demotasks', 'plugin', 'demotasks', 'task', 0, 1, 1, 0, 0, '', '{}', '', 15, 0),
(0, 'plg_task_requests', 'plugin', 'requests', 'task', 0, 1, 1, 0, 0, '', '{}', '', 15, 0),
(0, 'plg_task_sitestatus', 'plugin', 'sitestatus', 'task', 0, 1, 1, 0, 0, '', '{}', '', 15, 0);

i've choosed 16 cause is bigger than 15

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm ... in base.sql all task scheduler plugins seem to have values 0 to 5. No idea why it was done differently in that update SQL script. Maybe someone else has an idea.

@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'plg_task_webcronstart', 'plugin', 'webcronstart', 'task', 0, 1, 1, 0, 0, '', '{}', '', 16, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(0, 'plg_task_webcronstart', 'plugin', 'webcronstart', 'task', 0, 1, 1, 0, 0, '', '{}', '', 16, 0);
(0, 'plg_task_webcronstart', 'plugin', 'webcronstart', 'task', 0, 1, 1, 0, 0, '', '{}', '', 5, 0);

@toivo
Copy link
Contributor

toivo commented May 25, 2022

After site A has the PR applied and the New Task plugin enabled the site crashes - JROOT\plugins\task\webcronstart\services\provider.php:49
An error has occurred.
0 syntax error, unexpected end of file, expecting ";"
#Fields: datetime priority clientip category message
2022-05-25T06:35:59+00:00 CRITICAL 127.0.0.1 error Uncaught Throwable of type ParseError thrown with message "syntax error, unexpected end of file, expecting ";"". Stack trace: #0 [ROOT]\libraries\src\Extension\ExtensionManagerTrait.php(94): Joomla\CMS\Application\CMSApplication->loadExtension('Joomla\CMS\Exte...', 'webcronstart:ta...', '[ROOT]...')

Did the following to get back to the back end:

@alikon
Copy link
Contributor Author

alikon commented May 25, 2022

good spot fixed

@toivo
Copy link
Contributor

toivo commented May 25, 2022

I have tested this item ✅ successfully on f9a26af

Tested successfully on two 4.2.0-beta1-dev of 25 May. The PR#37868] - [4.1] Fix generate web cron key was applied first in site B. Added to the CLI command the following arguments: --id 1 --verbose and received a normal response to the command prompt. Without --id 1 received the message "No tasks due!"


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/37878.

Comment on lines +6 to +10
name="url"
type="text"
label="PLG_TASK_WEBCRONSTART_URL_LABEL"
description="PLG_TASK_WEBCRONSTART_URL_DESC"
required="true"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
name="url"
type="text"
label="PLG_TASK_WEBCRONSTART_URL_LABEL"
description="PLG_TASK_WEBCRONSTART_URL_DESC"
required="true"
name="url"
type="text"
label="PLG_TASK_WEBCRONSTART_URL_LABEL"
description="PLG_TASK_WEBCRONSTART_URL_DESC"
required="true"

<language tag="en-GB">language/en-GB/plg_task_webcronstart.ini</language>
<language tag="en-GB">language/en-GB/plg_task_webcronstart.sys.ini</language>
</languages>
</extension> No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add EOF

Comment on lines +7 to +11
PLG_TASK_WEBCRONSTART_XML_DESCRIPTION="Start the webcron service for the friend site."
PLG_TASK_WEBCRONSTART_URL_LABEL="Site URL"
PLG_TASK_WEBCRONSTART_URL_DESC="The URL of the site to start the webcron service for."
PLG_TASK_WEBCRONSTART_TITLE="WebCron Starter"
PLG_TASK_WEBCRONSTART_DESC="Starts the WebCron service for the friend site." No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please alphasort and add EOF

; Note : All ini files need to be saved as UTF-8

PLG_TASK_WEBCRONSTART="Task - Start WebCron"
PLG_TASK_WEBCRONSTART_XML_DESCRIPTION="Start the webcron service for the friend site." No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add EOF

// Let the request take longer than 300 seconds to avoid timeout issues
try
{
$response = HttpFactory::getHttp($options)->get($params->url, [], 300);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout parameter is not used here

@laoneo
Copy link
Member

laoneo commented May 25, 2022

I can't imagine a use case for a CMS where a remote web cron task should be executed on a regular basis. It is a CMS and not an administration panel. If it would be some kind of web hock feature for actions like an article save or user create, then ok. This plugin would be a perfect fit for the JED, but not for the core.

@richard67
Copy link
Member

@alikon Currently api and system tests are failing with loging in to backend after having made a new installation. The screenshot made from the failed login shows a syntax error, unexpected ')', unfortunately not with file and line number: https://ci.joomla.org/artifacts/joomla/joomla-cms/4.2-dev/37878/system-tests/54571/InstallCest.configureJoomla.mysql.fail.png . I suggest you test that, make a new installation with your branch and then login to backend.

@bembelimen
Copy link
Contributor

Just wondering, where is the difference to the "Get-Request" Task, which is already in the system?

@alikon alikon closed this May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language Change This is for Translators

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants