MDL-69653 cache: final removal of deprecated lock methods.

This commit is contained in:
Paul Holden 2023-01-06 09:14:58 +00:00
parent 71c36d2de1
commit c21a4aebeb
No known key found for this signature in database
GPG key ID: A81A96D6045F6164
9 changed files with 35 additions and 204 deletions

7
cache/upgrade.txt vendored
View file

@ -1,5 +1,12 @@
This files describes API changes in /cache/stores/* - cache store plugins.
Information provided here is intended especially for developers.
=== 4.3 ===
* Implementations of the following methods, deprecated since 3.10, have been removed and can no longer be used:
- `\core\lock\lock::extend`
- `\core\lock\lock_factory::extend_lock`
- `\core\lock\lock_factory::supports_recursion`
=== 4.2 ===
* The memcached cachestore has been removed.
* The mongodb cachestore has been removed.

View file

@ -14,18 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This is a db record locking factory.
*
* @package core
* @category lock
* @copyright Damyon Wiese 2013
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\lock;
defined('MOODLE_INTERNAL') || die();
use coding_exception;
/**
* This is a db record locking factory.
@ -90,15 +81,10 @@ class db_record_lock_factory implements lock_factory {
}
/**
* Multiple locks for the same resource can be held by a single process.
*
* @deprecated since Moodle 3.10.
* @return boolean - False - not process specific.
*/
public function supports_recursion() {
debugging('The function supports_recursion() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
return false;
throw new coding_exception('The function supports_recursion() has been removed, please do not use it anymore.');
}
/**
@ -190,33 +176,10 @@ class db_record_lock_factory implements lock_factory {
}
/**
* Extend a lock that was previously obtained with @lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock - a lock obtained from this factory.
* @param int $maxlifetime - the new lifetime for the lock (in seconds).
* @return boolean - true if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400) {
debugging('The function extend_lock() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
$now = time();
$expires = $now + $maxlifetime;
$params = array('expires' => $expires,
'token' => $lock->get_key());
$sql = 'UPDATE {lock_db}
SET
expires = :expires,
WHERE
owner = :token';
$this->db->execute($sql, $params);
$countparams = array('owner' => $lock->get_key());
$result = $this->count_records('lock_db', $countparams);
return $result === 0;
public function extend_lock() {
throw new coding_exception('The function extend_lock() has been removed, please do not use it anymore.');
}
/**

View file

@ -14,22 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Flock based file locking factory.
*
* The file lock factory returns file locks locked with the flock function. Works OK, except on some
* NFS, exotic shared storage and exotic server OSes (like windows). On windows, a second attempt to get a
* lock will block indefinitely instead of timing out.
*
* @package core
* @category lock
* @copyright Damyon Wiese 2013
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\lock;
defined('MOODLE_INTERNAL') || die();
use coding_exception;
/**
* Flock based file locking factory.
@ -110,15 +97,10 @@ class file_lock_factory implements lock_factory {
}
/**
* Multiple locks for the same resource cannot be held from a single process.
*
* @deprecated since Moodle 3.10.
* @return boolean - False
*/
public function supports_recursion() {
debugging('The function supports_recursion() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
return false;
throw new coding_exception('The function supports_recursion() has been removed, please do not use it anymore.');
}
/**
@ -194,18 +176,10 @@ class file_lock_factory implements lock_factory {
}
/**
* Extend a lock that was previously obtained with @lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock - not used
* @param int $maxlifetime - not used
* @return boolean - true if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400) {
debugging('The function extend_lock() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
// Not supported by this factory.
return false;
public function extend_lock() {
throw new coding_exception('The function extend_lock() has been removed, please do not use it anymore.');
}
}

View file

@ -14,18 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Lock factory for use during installation.
*
* @package core
* @category lock
* @copyright Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\lock;
defined('MOODLE_INTERNAL') || die();
use coding_exception;
/**
* Lock factory for use during installation.
@ -74,15 +65,10 @@ class installation_lock_factory implements lock_factory {
}
/**
* Multiple locks for the same resource cannot be held from a single process.
*
* @deprecated since Moodle 3.10.
* @return boolean - False
*/
public function supports_recursion() {
debugging('The function supports_recursion() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
return false;
throw new coding_exception('The function supports_recursion() has been removed, please do not use it anymore.');
}
/**
@ -116,18 +102,10 @@ class installation_lock_factory implements lock_factory {
}
/**
* Extend a lock that was previously obtained with @lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock - not used
* @param int $maxlifetime - not used
* @return boolean - true if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400) {
debugging('The function extend_lock() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
// Not supported by this factory.
return false;
public function extend_lock() {
throw new coding_exception('The function extend_lock() has been removed, please do not use it anymore.');
}
}

View file

@ -14,19 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Class representing a lock
*
* The methods available for a specific lock type are only known by it's factory.
*
* @package core
* @copyright Damyon Wiese 2013
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\lock;
defined('MOODLE_INTERNAL') || die();
use coding_exception;
/**
* Class representing a lock
@ -92,20 +82,10 @@ class lock {
}
/**
* Extend the lifetime of this lock. Not supported by all factories.
*
* @deprecated since Moodle 3.10.
* @param int $maxlifetime - the new lifetime for the lock (in seconds).
* @return bool
*/
public function extend($maxlifetime = 86400) {
debugging('The function extend() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
if ($this->factory) {
return $this->factory->extend_lock($this, $maxlifetime);
}
return false;
public function extend() {
throw new coding_exception('The function extend() has been removed, please do not use it anymore.');
}
/**

View file

@ -60,14 +60,6 @@ interface lock_factory {
*/
public function supports_auto_release();
/**
* Supports recursion.
*
* @deprecated since Moodle 3.10.
* @return boolean - True if attempting to get 2 locks on the same resource will "stack"
*/
public function supports_recursion();
/**
* Is available.
*
@ -95,14 +87,4 @@ interface lock_factory {
* @return boolean - True if the lock is no longer held (including if it was never held).
*/
public function release_lock(lock $lock);
/**
* Extend the timeout on a held lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock - lock obtained from this factory
* @param int $maxlifetime - new max time to hold the lock
* @return boolean - True if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400);
}

View file

@ -14,18 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* MySQL / MariaDB locking factory.
*
* @package core
* @category lock
* @copyright Brendan Heywood <brendan@catalyst-au.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\lock;
defined('MOODLE_INTERNAL') || die();
use coding_exception;
/**
* MySQL / MariaDB locking factory.
@ -101,18 +92,10 @@ class mysql_lock_factory implements lock_factory {
}
/**
* Multiple locks for the same resource can NOT be held by a single process.
*
* Hard coded to false and workaround inconsistent support in different
* versions of MySQL / MariaDB.
*
* @deprecated since Moodle 3.10.
* @return boolean - false
*/
public function supports_recursion() {
debugging('The function supports_recursion() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
return false;
throw new coding_exception('The function supports_recursion() has been removed, please do not use it anymore.');
}
/**
@ -167,18 +150,10 @@ class mysql_lock_factory implements lock_factory {
}
/**
* Extend a lock that was previously obtained with @lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock - a lock obtained from this factory.
* @param int $maxlifetime - the new lifetime for the lock (in seconds).
* @return boolean - true if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400) {
debugging('The function extend_lock() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
// Not supported by this factory.
return false;
public function extend_lock() {
throw new coding_exception('The function extend_lock() has been removed, please do not use it anymore.');
}
/**

View file

@ -14,18 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Postgres advisory locking factory.
*
* @package core
* @category lock
* @copyright Damyon Wiese 2013
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core\lock;
defined('MOODLE_INTERNAL') || die();
use coding_exception;
/**
* Postgres advisory locking factory.
@ -118,15 +109,10 @@ class postgres_lock_factory implements lock_factory {
}
/**
* Multiple locks for the same resource can NOT be held by a single process.
*
* @deprecated since Moodle 3.10.
* @return boolean - false.
*/
public function supports_recursion() {
debugging('The function supports_recursion() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
return false;
throw new coding_exception('The function supports_recursion() has been removed, please do not use it anymore.');
}
/**
@ -204,18 +190,10 @@ class postgres_lock_factory implements lock_factory {
}
/**
* Extend a lock that was previously obtained with @lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock - a lock obtained from this factory.
* @param int $maxlifetime - the new lifetime for the lock (in seconds).
* @return boolean - true if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400) {
debugging('The function extend_lock() is deprecated, please do not use it anymore.',
DEBUG_DEVELOPER);
// Not supported by this factory.
return false;
public function extend_lock() {
throw new coding_exception('The function extend_lock() has been removed, please do not use it anymore.');
}
/**

View file

@ -16,6 +16,8 @@
namespace core\lock;
use coding_exception;
/**
* Timing wrapper around a lock factory.
*
@ -165,13 +167,10 @@ class timing_wrapper_lock_factory implements lock_factory {
}
/**
* Calls parent factory to check if it supports recursion.
*
* @deprecated since Moodle 3.10.
* @return boolean True if attempting to get 2 locks on the same resource will "stack"
*/
public function supports_recursion() {
return $this->factory->supports_recursion();
throw new coding_exception('The function supports_recursion() has been removed, please do not use it anymore.');
}
/**
@ -184,14 +183,9 @@ class timing_wrapper_lock_factory implements lock_factory {
}
/**
* Calls parent factory to try to extend the lock.
*
* @deprecated since Moodle 3.10.
* @param lock $lock Lock obtained from this factory
* @param int $maxlifetime New max time to hold the lock
* @return boolean True if the lock was extended.
*/
public function extend_lock(lock $lock, $maxlifetime = 86400) {
return $this->factory->extend_lock($lock, $maxlifetime);
public function extend_lock() {
throw new coding_exception('The function extend_lock() has been removed, please do not use it anymore.');
}
}