Skip to content
Snippets Groups Projects
Commit 3e0c7aa3 authored by Adrian Lang's avatar Adrian Lang
Browse files

Add locking for indexer-based notifications

parent 6b8f02cf
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@
* - subscription_set
* - get_info_subscribed
* - subscription_addresslist
* - subscription_lock
* - subscription_unlock
*
* @author Adrian Lang <lang@cosmocode.de>
* @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 <lang@cosmocode.de>
*/
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 <lang@cosmocode.de>
*/
function subscription_unlock($id) {
$lockf = subscription_filename($id) . '.lock';
return file_exists($lockf) && unlink($lockf);
}
/**
* Set subscription information
*
......
......@@ -353,6 +353,9 @@ function sendDigest() {
$olduser = $_SERVER['REMOTE_USER'];
foreach($subscriptions as $id => $users) {
if (!subscription_lock($id)) {
continue;
}
foreach($users as $data) {
list($user, $style, $lastupdate) = $data;
$lastupdate = (int) $lastupdate;
......@@ -399,6 +402,7 @@ function sendDigest() {
// Update notification time.
subscription_set($user, $id, $style, time(), true);
}
subscription_unlock($id);
}
// restore current user info
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment