From 37e51a5daafa52bb7a6d4b79d46e20c7cd08c5e7 Mon Sep 17 00:00:00 2001 From: Simey Lameze Date: Thu, 22 Oct 2015 10:59:23 +0800 Subject: [PATCH] MDL-51824 core: initial deprecation of auth sync CLI scripts This commit does the initial deprecation of the CLI scripts of CAS and LDAP authentication plugins. --- auth/cas/cli/sync_users.php | 14 ++++++++++---- auth/ldap/cli/sync_users.php | 14 ++++++++++---- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/auth/cas/cli/sync_users.php b/auth/cas/cli/sync_users.php index a02c32f16c3..3498f8fbff3 100644 --- a/auth/cas/cli/sync_users.php +++ b/auth/cas/cli/sync_users.php @@ -20,10 +20,6 @@ * This script is meant to be called from a cronjob to sync moodle with the CAS * backend in those setups where the CAS backend acts as 'master'. * - * Sample cron entry: - * # 5 minutes past 4am - * 5 4 * * * $sudo -u www-data /usr/bin/php /var/www/moodle/auth/cas/cli/sync_users.php - * * Notes: * - it is required to use the web server account when executing PHP CLI scripts * - you need to change the "www-data" to match the apache user account @@ -40,6 +36,8 @@ * @package auth_cas * @copyright 2007 Jerome Gutierrez - based on code by Martin Langhoff * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @deprecated since Moodle 3.0 MDL-51824 - please do not use this CLI script any more, use scheduled task instead. + * @todo MDL-50264 This will be deleted in Moodle 3.2. */ define('CLI_SCRIPT', true); @@ -55,6 +53,14 @@ if (!is_enabled_auth('cas')) { die; } +cli_problem('[AUTH CAS] The sync users cron has been deprecated. Please use the scheduled task instead.'); + +// Abort execution of the CLI script if the auth_cas\task\sync_task is enabled. +$task = \core\task\manager::get_scheduled_task('auth_cas\task\sync_task'); +if (!$task->get_disabled()) { + cli_error('[AUTH CAS] The scheduled task sync_task is enabled, the cron execution has been aborted.'); +} + $casauth = get_auth_plugin('cas'); $casauth->sync_users(true); diff --git a/auth/ldap/cli/sync_users.php b/auth/ldap/cli/sync_users.php index 6898293a2e9..5de52e0e08d 100644 --- a/auth/ldap/cli/sync_users.php +++ b/auth/ldap/cli/sync_users.php @@ -20,10 +20,6 @@ * This script is meant to be called from a cronjob to sync moodle with the LDAP * backend in those setups where the LDAP backend acts as 'master'. * - * Sample cron entry: - * # 5 minutes past 4am - * 5 4 * * * $sudo -u www-data /usr/bin/php /var/www/moodle/auth/ldap/cli/sync_users.php - * * Notes: * - it is required to use the web server account when executing PHP CLI scripts * - you need to change the "www-data" to match the apache user account @@ -44,6 +40,8 @@ * @package auth_ldap * @copyright 2004 Martin Langhoff * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @deprecated since Moodle 3.0 MDL-51824 - please do not use this CLI script any more, use scheduled task instead. + * @todo MDL-50264 This will be deleted in Moodle 3.2. */ define('CLI_SCRIPT', true); @@ -59,6 +57,14 @@ if (!is_enabled_auth('ldap')) { die; } +cli_problem('[AUTH LDAP] The users sync cron has been deprecated. Please use the scheduled task instead.'); + +// Abort execution of the CLI script if the auth_ldap\task\sync_task is enabled. +$taskdisabled = \core\task\manager::get_scheduled_task('auth_ldap\task\sync_task'); +if (!$taskdisabled->get_disabled()) { + cli_error('[AUTH LDAP] The scheduled task sync_task is enabled, the cron execution has been aborted.'); +} + $ldapauth = get_auth_plugin('ldap'); $ldapauth->sync_users(true); -- 2.43.0