Task Schedule

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
every task has a run period(interval) based on seconds where we can setup how frequent we want to run a task, and we set them based on seconds, now in nop.services.Tasks.TaskThread.cs line 125

        public int Interval
        {
            get
            {
                return this.Seconds * 1000;
            }
        }

now int has a max of 2,147,483,647 so if we multiply the seconds by 1000 we have a limit for seconds to be not more than 2147483 seconds which comes down to about 24 days, if someone puts a value more than 2147483 the whole application crash, without any trap to catch the error.

to replicate it try the following.

1) under admin/ScheduleTask/List edit any task and put 21474839 in the seconds column, make sure task is enabled.
2) restart application.


now where exactly does it fail?
at line number 74  
this._timer = new Timer(new TimerCallback(this.TimerHandler), null, this.Interval, this.Interval);

since this.Interval is being multiplied by 1000 it exceeds the max limit, and it goes into negative number, and you cant pass a negative number as an argument in that line.


Solution.

1) validation on server to reject seconds that exceed 2147483 and notify user about the limit.
2) change interval to a long, so the limit is about few months, so admin users can set tasks for monthly basis.
7 years ago
Thanks a lot for reporting. I've created a work item
7 years ago
i see its on milestone 3.90, i am just wondering why not have bug fixes into patches like Magento does?

i recommend we should do the following for bug fixes.

1) Create a patch which can be downloaded for all existing stores that dont want to upgrade now to newer versions.
2) place it in the latest stable version, so when ppl download now the source they will get it and dont need to patch it.

3) make a nop notification in admin, and notify admin users for new versions as soon they become available, and for bug patches (like magento does).
7 years ago
Hi,

Thanks a lot for suggession! For such purposes we have release-3.80-bug-fixes branch
6 years ago
Where did the solution go ? .. Page not opened.
3 years ago
Hi!

We've released a new plugin that allows to schedule NopCommerce tasks using a CRON expression. Using this, you will be able to run your tasks even every New Year's Eve.
Checkout the demo here https://ellasoftware.com/cron-tasks-nopcommerce
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.