Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve run_cron method #937

Open
poonam279 opened this issue May 1, 2024 · 0 comments
Open

Improve run_cron method #937

poonam279 opened this issue May 1, 2024 · 0 comments
Labels
customer report Indicates the request came from a customer. new feature Request for a new feature or functionality to be added to the project.

Comments

@poonam279
Copy link

poonam279 commented May 1, 2024

What problem does this address?

A user on WordPress.org suggested to improve the run cron method in our plugin. He wrote the following message -
I have some issues with the way your plugin is handling what feeds to push to the run_job method of “Feedzy_Rss_Feeds_Import” Your code prevents hook and overwrite of this method ( run_job is private ). So I have a simple modifications to suggest, please consider it.

in the original code from https://plugins.trac.wordpress.org/browser/feedzy-rss-feeds/trunk/includes/admin/feedzy-rss-feeds-import.php

The args used in get_post imply only the first 99 published feeds added can be processed and run_job will probably timeout way before it reach 99 feeds.

in my case i have to edit your plugins in this way

public function run_cron( $max = 10 ) {
[...]
$args = [
    'post_type'   => 'feedzy_imports',
    'post_status' => 'publish',
    'meta_key'    => 'last_run_id',
    'orderby'     => 'meta_value_num',
    'order'       => 'DESC',
    'numberposts' => 10,
];
[...]

i have reduced drastically the limit to never run more than 10 feed for more than 10 article

order on last_run timestamp in order to always run the oldest feed, this way the plugin is way more stable, enable to run cron way more often et do not ignore feeds anymore.

I was enable to run the shreduled task every 15 minutes on more than 300 distinct feeds. and update all of them in the span a a day.

https://wordpress.org/support/topic/run_cron-method-is-terrible/

What is your proposed solution?

He suggests adding a simple hook on the get_post arguments and $max to enable cron behavior editing without plugin editing.

$args = apply_filters( 'feedzy_run_cron_get_posts_args', [
'post_type'   => 'feedzy_imports',
'post_status' => 'publish',
'numberposts' => 99,
] );

Will this feature require documentation? (Optional)

None

@poonam279 poonam279 added the new feature Request for a new feature or functionality to be added to the project. label May 1, 2024
@pirate-bot pirate-bot added the customer report Indicates the request came from a customer. label May 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer report Indicates the request came from a customer. new feature Request for a new feature or functionality to be added to the project.
Projects
None yet
Development

No branches or pull requests

2 participants