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

replaced deprecated function cron_trace_time_and_memory() for Moodle 4.2+ #568

Open
wants to merge 4 commits into
base: MOODLE_310_STABLE
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions classes/task/delete_local_empty_directories.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@

use coding_exception;
use tool_objectfs\local\manager;
use core\cron;

defined('MOODLE_INTERNAL') || die();

require_once($CFG->libdir.'/cronlib.php');

class delete_local_empty_directories extends task {

/** @var string $stringname */
Expand All @@ -51,7 +50,7 @@ public function execute() {
return;
}
$filesystem = new $this->config->filesystem();
cron_trace_time_and_memory();
cron::trace_time_and_memory();
$filesystem->delete_empty_dirs();
}
}
16 changes: 0 additions & 16 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,6 @@
define('TOOL_OBJECTFS_DELETE_EXTERNAL_TRASH', 1);
define('TOOL_OBJECTFS_DELETE_EXTERNAL_FULL', 2);

// Legacy cron function.
function tool_objectfs_cron() {
mtrace('RUNNING legacy cron objectfs');
global $CFG;
if ($CFG->branch <= 26) {
// Unlike the task system, we do not get fine grained control over
// when tasks/manipulators run. Every cron we just run all the manipulators.
(new manipulator_builder())->execute_all();

\tool_objectfs\local\report\objectfs_report::cleanup_reports();
\tool_objectfs\local\report\objectfs_report::generate_status_report();
}

return true;
}

/**
* Sends a plugin file to the browser.
* @param $course
Expand Down
7 changes: 0 additions & 7 deletions tests/local/tasks_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,6 @@ protected function tearDown(): void {
ob_end_clean();
}

public function test_run_legacy_cron() {
$config = manager::get_objectfs_config();
$config->enabletasks = true;
manager::set_objectfs_config($config);
$this->assertTrue(tool_objectfs_cron());
}

public function test_run_scheduled_tasks() {
global $CFG;
// If tasks not implemented.
Expand Down