diff --git a/lib/backgroundjob/scheduledtask.php b/lib/backgroundjob/scheduledtask.php index 47f332a204..da5d4ddc69 100644 --- a/lib/backgroundjob/scheduledtask.php +++ b/lib/backgroundjob/scheduledtask.php @@ -21,22 +21,22 @@ */ /** - * This class manages our scheduled tasks. + * This class manages our queued tasks. */ -class OC_BackgroundJob_ScheduledTask{ +class OC_BackgroundJob_QueuedTask{ /** - * @brief Gets one scheduled task + * @brief Gets one queued task * @param $id ID of the task * @return associative array */ public static function find( $id ){ - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*scheduledtasks WHERE id = ?' ); + $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*queuedtasks WHERE id = ?' ); $result = $stmt->execute(array($id)); return $result->fetchRow(); } /** - * @brief Gets all scheduled tasks + * @brief Gets all queued tasks * @return array with associative arrays */ public static function all(){ @@ -44,18 +44,17 @@ class OC_BackgroundJob_ScheduledTask{ $return = array(); // Get Data - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*scheduledtasks' ); + $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*queuedtasks' ); $result = $stmt->execute(array()); while( $row = $result->fetchRow()){ $return[] = $row; } - // Und weg damit return $return; } /** - * @brief Gets all scheduled tasks of a specific app + * @brief Gets all queued tasks of a specific app * @param $app app name * @return array with associative arrays */ @@ -64,7 +63,7 @@ class OC_BackgroundJob_ScheduledTask{ $return = array(); // Get Data - $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*scheduledtasks WHERE app = ?' ); + $stmt = OC_DB::prepare( 'SELECT * FROM *PREFIX*queuedtasks WHERE app = ?' ); $result = $stmt->execute(array($app)); while( $row = $result->fetchRow()){ $return[] = $row; @@ -75,7 +74,7 @@ class OC_BackgroundJob_ScheduledTask{ } /** - * @brief schedules a task + * @brief queues a task * @param $app app name * @param $klass class name * @param $method method name @@ -83,21 +82,21 @@ class OC_BackgroundJob_ScheduledTask{ * @return id of task */ public static function add( $task, $klass, $method, $parameters ){ - $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*scheduledtasks (app, klass, method, parameters) VALUES(?,?,?,?)' ); + $stmt = OC_DB::prepare( 'INSERT INTO *PREFIX*queuedtasks (app, klass, method, parameters) VALUES(?,?,?,?)' ); $result = $stmt->execute(array($app, $klass, $method, $parameters, time)); return OC_DB::insertid(); } /** - * @brief deletes a scheduled task + * @brief deletes a queued task * @param $id id of task * @return true/false * * Deletes a report */ public static function delete( $id ){ - $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*scheduledtasks WHERE id = ?' ); + $stmt = OC_DB::prepare( 'DELETE FROM *PREFIX*queuedtasks WHERE id = ?' ); $result = $stmt->execute(array($id)); return true; diff --git a/lib/backgroundjob/worker.php b/lib/backgroundjob/worker.php index 799fa5306c..0acbb9d321 100644 --- a/lib/backgroundjob/worker.php +++ b/lib/backgroundjob/worker.php @@ -30,7 +30,7 @@ class OC_BackgroundJob_Worker{ * @brief executes all tasks * @return boolean * - * This method executes all regular tasks and then all scheduled tasks. + * This method executes all regular tasks and then all queued tasks. * This method should be called by cli scripts that do not let the user * wait. */ @@ -41,11 +41,11 @@ class OC_BackgroundJob_Worker{ call_user_func( $value ); } - // Do our scheduled tasks - $scheduled_tasks = OC_BackgroundJob_ScheduledTask::all(); - foreach( $scheduled_tasks as $task ){ + // Do our queued tasks + $queued_tasks = OC_BackgroundJob_QueuedTask::all(); + foreach( $queued_tasks as $task ){ call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] ); - OC_BackgroundJob_ScheduledTask::delete( $task['id'] ); + OC_BackgroundJob_QueuedTask::delete( $task['id'] ); } return true; @@ -82,23 +82,23 @@ class OC_BackgroundJob_Worker{ } if( $done == false ){ - // Next time load scheduled tasks - OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'scheduled_tasks' ); + // Next time load queued tasks + OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'queued_tasks' ); } } else{ - $tasks = OC_BackgroundJob_ScheduledTask::all(); + $tasks = OC_BackgroundJob_QueuedTask::all(); if( count( $tasks )){ $task = $tasks[0]; // delete job before we execute it. This prevents endless loops // of failing jobs. - OC_BackgroundJob_ScheduledTask::delete($task['id']); + OC_BackgroundJob_QueuedTask::delete($task['id']); // execute job call_user_func( array( $task['klass'], $task['method'] ), $task['parameters'] ); } else{ - // Next time load scheduled tasks + // Next time load queued tasks OC_Appconfig::setValue( 'core', 'backgroundjobs_step', 'regular_tasks' ); OC_Appconfig::setValue( 'core', 'backgroundjobs_task', '' ); } diff --git a/lib/public/backgroundjob.php b/lib/public/backgroundjob.php index ac86363454..72f4557eb1 100644 --- a/lib/public/backgroundjob.php +++ b/lib/public/backgroundjob.php @@ -32,19 +32,20 @@ namespace OCP; * This class provides functions to manage backgroundjobs in ownCloud * * There are two kind of background jobs in ownCloud: regular tasks and - * scheduled tasks. + * queued tasks. * * Regular tasks have to be registered in appinfo.php and * will run on a regular base. Fetching news could be a task that should run * frequently. * - * Scheduled tasks have to be registered each time you want to execute them. - * An example of the scheduled task would be the creation of the thumbnail. As - * soon as the user uploads a picture the gallery app registers the scheduled - * task "create thumbnail" and saves the path in the parameter. As soon as the - * task is done it will be deleted from the list. + * Queued tasks have to be registered each time you want to execute them. + * An example of the queued task would be the creation of the thumbnail. As + * soon as the user uploads a picture the gallery app registers the queued + * task "create thumbnail" and saves the path in the parameter instead of doing + * the work right away. This makes the app more responsive. As soon as the task + * is done it will be deleted from the list. */ -class Backgroundjob { +class BackgroundJob { /** * @brief creates a regular task * @param $klass class name @@ -66,51 +67,51 @@ class Backgroundjob { } /** - * @brief Gets one scheduled task + * @brief Gets one queued task * @param $id ID of the task * @return associative array */ - public static function findScheduledTask( $id ){ - return \OC_BackgroundJob_ScheduledTask::find( $id ); + public static function findQueuedTask( $id ){ + return \OC_BackgroundJob_QueuedTask::find( $id ); } /** - * @brief Gets all scheduled tasks + * @brief Gets all queued tasks * @return array with associative arrays */ - public static function allScheduledTasks(){ - return \OC_BackgroundJob_ScheduledTask::all(); + public static function allQueuedTasks(){ + return \OC_BackgroundJob_QueuedTask::all(); } /** - * @brief Gets all scheduled tasks of a specific app + * @brief Gets all queued tasks of a specific app * @param $app app name * @return array with associative arrays */ - public static function scheduledTaskWhereAppIs( $app ){ - return \OC_BackgroundJob_ScheduledTask::whereAppIs( $app ); + public static function queuedTaskWhereAppIs( $app ){ + return \OC_BackgroundJob_QueuedTask::whereAppIs( $app ); } /** - * @brief schedules a task + * @brief queues a task * @param $app app name * @param $klass class name * @param $method method name * @param $parameters all useful data as text * @return id of task */ - public static function addScheduledTask( $task, $klass, $method, $parameters ){ - return \OC_BackgroundJob_ScheduledTask::add( $task, $klass, $method, $parameters ); + public static function addQueuedTask( $task, $klass, $method, $parameters ){ + return \OC_BackgroundJob_QueuedTask::add( $task, $klass, $method, $parameters ); } /** - * @brief deletes a scheduled task + * @brief deletes a queued task * @param $id id of task * @return true/false * * Deletes a report */ - public static function deleteScheduledTask( $id ){ - return \OC_BackgroundJob_ScheduledTask::delete( $id ); + public static function deleteQueuedTask( $id ){ + return \OC_BackgroundJob_QueuedTask::delete( $id ); } }