From 3e0c7aa328ac721b3bcf17822f9ed3659ad93d14 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 4 May 2010 12:07:35 +0200 Subject: Add locking for indexer-based notifications --- inc/subscription.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'inc/subscription.php') diff --git a/inc/subscription.php b/inc/subscription.php index e5938d9bd..ce5da4cd4 100644 --- a/inc/subscription.php +++ b/inc/subscription.php @@ -9,6 +9,8 @@ * - subscription_set * - get_info_subscribed * - subscription_addresslist + * - subscription_lock + * - subscription_unlock * * @author Adrian Lang * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) @@ -36,6 +38,32 @@ function subscription_filename($id) { return metaFN($meta_froot, $meta_fname); } +/** + * Lock subscription info for an ID + * + * @param string $id The target page or namespace, specified by id; Namespaces + * are identified by appending a colon. + * + * @author Adrian Lang + */ +function subscription_lock($id) { + $lockf = subscription_filename($id) . '.lock'; + return !file_exists($lockf) && touch($lockf); +} + +/** + * Unlock subscription info for an ID + * + * @param string $id The target page or namespace, specified by id; Namespaces + * are identified by appending a colon. + * + * @author Adrian Lang + */ +function subscription_unlock($id) { + $lockf = subscription_filename($id) . '.lock'; + return file_exists($lockf) && unlink($lockf); +} + /** * Set subscription information * -- cgit v1.2.3