<?php
function actions_loop_test_trigger_info() {
return array(
'actions_loop_test' => array(
'watchdog' => array(
'label' => t('When a message is logged'),
),
),
);
}
function actions_loop_test_watchdog(array $log_entry) {
if (empty($_GET['trigger_actions_on_watchdog'])) {
return;
}
$aids = trigger_get_assigned_actions('watchdog');
$context = array(
'hook' => 'watchdog',
);
actions_do(array_keys($aids), $log_entry, $context);
}
function actions_loop_test_init() {
if (!empty($_GET['trigger_actions_on_watchdog'])) {
watchdog_skip_semaphore('actions_loop_test', 'Triggering action loop');
}
}
function actions_loop_test_action_info() {
return array(
'actions_loop_test_log' => array(
'label' => t('Write a message to the log.'),
'type' => 'system',
'configurable' => FALSE,
'triggers' => array(
'any',
),
),
);
}
function actions_loop_test_log() {
$count =& drupal_static(__FUNCTION__, 0);
$count++;
watchdog_skip_semaphore('actions_loop_test', "Test log #{$count}");
}
function watchdog_skip_semaphore($type, $message, $variables = array(), $severity = WATCHDOG_NOTICE, $link = NULL) {
global $user, $base_root;
$log_entry = array(
'type' => $type,
'message' => $message,
'variables' => $variables,
'severity' => $severity,
'link' => $link,
'user' => $user,
'uid' => isset($user->uid) ? $user->uid : 0,
'request_uri' => $base_root . request_uri(),
'referer' => $_SERVER['HTTP_REFERER'],
'ip' => ip_address(),
'timestamp' => REQUEST_TIME,
);
foreach (module_implements('watchdog') as $module) {
module_invoke($module, 'watchdog', $log_entry);
}
}