#3826 - Move stats CSV download to a background task
| Identifier | #3826 |
|---|---|
| Issue type | Feature request or suggestion |
| Title | Move stats CSV download to a background task |
| Status | Closed (no changes needed) |
| Tags |
Roadmap: v11 (custom) Type: Performance (custom) |
| Handling member | Chris Graham |
| Addon | stats |
| Description | Currently the stats download runs in real-time, but this may timeout, so should be done in a background task. |
| Steps to reproduce | |
| Funded? | No |
The system will post a comment when this issue is modified (e.g., status changes). To be notified of this, click "Enable comment notifications".

Comments
Tasks allow items to be queued for execution via Cron, not subject to timeouts, and run in an orderly manner so as to not over-stress the server.
A task is initiated using code like (code from cms_blogs.php)...
require_code('tasks');
return call_user_func_array__long_task(do_lang('IMPORT_WORDPRESS'), $this->title, 'import_wordpress', array($is_validated, $download_images, $to_own_account, $import_blog_comments, $import_to_blog, $import_wordpress_users));
Where the array is whatever options need to be passed to the task.
By default a task will run immediately. That's fine for testing them.
admin_stats.php is very old code and not ideal in how it is structured. You may choose to move a lot of it out to new functions that can serve data both for the task hook and for the admin_stats module.