Skip to content

Commit

Permalink
Merge branch 'w13_MDL-44639_m27_taskdocs' of git://github.com/skodak/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
marinaglancy committed Mar 24, 2014
2 parents 0b536b3 + 5a1e6e3 commit 66cb56a
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 27 deletions.
2 changes: 1 addition & 1 deletion admin/tool/task/renderer.php
Expand Up @@ -35,7 +35,7 @@ class tool_task_renderer extends plugin_renderer_base {
/**
* This function will render one beautiful table with all the scheduled tasks.
*
* @param array(scheduled_task) - list of all scheduled tasks.
* @param \core\task\scheduled_task[] $tasks - list of all scheduled tasks.
* @return string HTML to output.
*/
public function scheduled_tasks_table($tasks) {
Expand Down
4 changes: 2 additions & 2 deletions lib/classes/task/adhoc_task.php
Expand Up @@ -58,15 +58,15 @@ public function get_id() {

/**
* Setter for $customdata.
* @param object $customdata (anything that can be handled by json_encode)
* @param mixed $customdata (anything that can be handled by json_encode)
*/
public function set_custom_data($customdata) {
$this->customdata = json_encode($customdata);
}

/**
* Getter for $customdata.
* @return object (anything that can be handled by json_decode).
* @return mixed (anything that can be handled by json_decode).
*/
public function get_custom_data() {
return json_decode($this->customdata);
Expand Down
46 changes: 25 additions & 21 deletions lib/classes/task/manager.php
Expand Up @@ -40,7 +40,7 @@ class manager {
* Given a component name, will load the list of tasks in the db/tasks.php file for that component.
*
* @param string $componentname - The name of the component to fetch the tasks for.
* @return array(core\task\scheduled_task) - List of scheduled tasks for this component.
* @return \core\task\scheduled_task[] - List of scheduled tasks for this component.
*/
public static function load_default_scheduled_tasks_for_component($componentname) {
$dir = \core_component::get_component_directory($componentname);
Expand Down Expand Up @@ -179,7 +179,7 @@ public static function configure_scheduled_task(scheduled_task $task) {
* Utility method to create a DB record from a scheduled task.
*
* @param \core\task\scheduled_task $task
* @return stdClass
* @return \stdClass
*/
public static function record_from_scheduled_task($task) {
$record = new \stdClass();
Expand All @@ -206,7 +206,7 @@ public static function record_from_scheduled_task($task) {
* Utility method to create a DB record from an adhoc task.
*
* @param \core\task\adhoc_task $task
* @return stdClass
* @return \stdClass
*/
public static function record_from_adhoc_task($task) {
$record = new \stdClass();
Expand All @@ -227,7 +227,7 @@ public static function record_from_adhoc_task($task) {
/**
* Utility method to create an adhoc task from a DB record.
*
* @param stdClass $record
* @param \stdClass $record
* @return \core\task\adhoc_task
*/
public static function adhoc_task_from_record($record) {
Expand Down Expand Up @@ -262,7 +262,7 @@ public static function adhoc_task_from_record($record) {
/**
* Utility method to create a task from a DB record.
*
* @param stdClass $record
* @param \stdClass $record
* @return \core\task\scheduled_task
*/
public static function scheduled_task_from_record($record) {
Expand All @@ -273,6 +273,7 @@ public static function scheduled_task_from_record($record) {
if (!class_exists($classname)) {
return false;
}
/** @var \core\task\scheduled_task $task */
$task = new $classname;
if (isset($record->lastruntime)) {
$task->set_last_run_time($record->lastruntime);
Expand Down Expand Up @@ -313,7 +314,7 @@ public static function scheduled_task_from_record($record) {
* Given a component name, will load the list of tasks from the scheduled_tasks table for that component.
* Do not execute tasks loaded from this function - they have not been locked.
* @param string $componentname - The name of the component to load the tasks for.
* @return array(core\task\scheduled_task)
* @return \core\task\scheduled_task[]
*/
public static function load_scheduled_tasks_for_component($componentname) {
global $DB;
Expand All @@ -332,7 +333,8 @@ public static function load_scheduled_tasks_for_component($componentname) {
/**
* This function load the scheduled task details for a given classname.
*
* @return core\task\scheduled_task or false
* @param string $classname
* @return \core\task\scheduled_task or false
*/
public static function get_scheduled_task($classname) {
global $DB;
Expand All @@ -351,7 +353,8 @@ public static function get_scheduled_task($classname) {
/**
* This function load the default scheduled task details for a given classname.
*
* @return core\task\scheduled_task or false
* @param string $classname
* @return \core\task\scheduled_task or false
*/
public static function get_default_scheduled_task($classname) {
$task = self::get_scheduled_task($classname);
Expand All @@ -370,7 +373,7 @@ public static function get_default_scheduled_task($classname) {
/**
* This function will return a list of all the scheduled tasks that exist in the database.
*
* @return array(core\task\scheduled_task) or null
* @return \core\task\scheduled_task[]
*/
public static function get_all_scheduled_tasks() {
global $DB;
Expand All @@ -391,7 +394,8 @@ public static function get_all_scheduled_tasks() {
* with an open lock - possibly on the entire cron process. Make sure you call either
* {@link adhoc_task_failed} or {@link adhoc_task_complete} to release the lock and reschedule the task.
*
* @return core\task\adhoc_task or null
* @param int $timestart
* @return \core\task\adhoc_task or null if not found
*/
public static function get_next_adhoc_task($timestart) {
global $DB;
Expand Down Expand Up @@ -432,7 +436,7 @@ public static function get_next_adhoc_task($timestart) {
* {@link scheduled_task_failed} or {@link scheduled_task_complete} to release the lock and reschedule the task.
*
* @param int $timestart - The start of the cron process - do not repeat any tasks that have been run more recently than this.
* @return core\task\scheduled_task or null
* @return \core\task\scheduled_task or null
*/
public static function get_next_scheduled_task($timestart) {
global $DB;
Expand Down Expand Up @@ -468,9 +472,9 @@ public static function get_next_scheduled_task($timestart) {
}

/**
* This function indicates that an adhoc task was not completed succesfully and should be retried.
* This function indicates that an adhoc task was not completed successfully and should be retried.
*
* @param core\task\adhoc_task $task
* @param \core\task\adhoc_task $task
*/
public static function adhoc_task_failed(adhoc_task $task) {
global $DB;
Expand Down Expand Up @@ -505,9 +509,9 @@ public static function adhoc_task_failed(adhoc_task $task) {
}

/**
* This function indicates that an adhoc task was completed succesfully.
* This function indicates that an adhoc task was completed successfully.
*
* @param core\task\adhoc_task $task
* @param \core\task\adhoc_task $task
*/
public static function adhoc_task_complete(adhoc_task $task) {
global $DB;
Expand All @@ -523,9 +527,9 @@ public static function adhoc_task_complete(adhoc_task $task) {
}

/**
* This function indicates that a scheduled task was not completed succesfully and should be retried.
* This function indicates that a scheduled task was not completed successfully and should be retried.
*
* @param core\task\scheduled_task $task
* @param \core\task\scheduled_task $task
*/
public static function scheduled_task_failed(scheduled_task $task) {
global $DB;
Expand Down Expand Up @@ -561,9 +565,9 @@ public static function scheduled_task_failed(scheduled_task $task) {
}

/**
* This function indicates that a scheduled task was completed succesfully and should be rescheduled.
* This function indicates that a scheduled task was completed successfully and should be rescheduled.
*
* @param core\task\scheduled_task $task
* @param \core\task\scheduled_task $task
*/
public static function scheduled_task_complete(scheduled_task $task) {
global $DB;
Expand Down Expand Up @@ -611,11 +615,11 @@ public static function clear_static_caches() {
/**
* Return true if the static caches have been cleared since $starttime.
* @param int $starttime The time this process started.
* @return boolean True if static caches need reseting.
* @return boolean True if static caches need resetting.
*/
public static function static_caches_cleared_since($starttime) {
global $DB;
$record = $DB->get_record('config', array('name'=>'scheduledtaskreset'));
return $record && intval($record->value) > $starttime;
return $record && (intval($record->value) > $starttime);
}
}
4 changes: 2 additions & 2 deletions lib/classes/task/scheduled_task.php
Expand Up @@ -62,7 +62,7 @@ public function get_last_run_time() {

/**
* Set the last run time for this scheduled task.
* @return int
* @param int $lastruntime
*/
public function set_last_run_time($lastruntime) {
$this->lastruntime = $lastruntime;
Expand Down Expand Up @@ -251,7 +251,7 @@ public function eval_cron_field($field, $min, $max) {
* If list is empty, this function will return 0.
*
* @param int $current The current value
* @param array(int) $list The list of valid items.
* @param int[] $list The list of valid items.
* @return int $next.
*/
private function next_in_list($current, $list) {
Expand Down
2 changes: 1 addition & 1 deletion lib/classes/task/task_base.php
Expand Up @@ -84,7 +84,7 @@ public function get_next_run_time() {

/**
* Set the next run time for this task.
* @return int
* @param int $nextruntime
*/
public function set_next_run_time($nextruntime) {
$this->nextruntime = $nextruntime;
Expand Down

0 comments on commit 66cb56a

Please sign in to comment.