- <?php
-
- * Implements hook_watchdog().
- */
- function actions_loop_test_watchdog(array $log_entry) {
-
- if (empty($_GET['trigger_actions_on_watchdog']) || $log_entry['type'] !== 'actions_loop_test') {
- return;
- }
-
- $context = array(
- 'log_entry' => $log_entry,
- );
-
-
- $action_name = $_GET['trigger_actions_on_watchdog'];
- actions_execute($action_name, NULL, $context);
- }
-
- * Implements hook_init().
- */
- function actions_loop_test_init() {
- if (!empty($_GET['trigger_actions_on_watchdog'])) {
- watchdog_skip_semaphore('actions_loop_test', 'Triggering action loop');
- }
- }
-
- * Implements hook_action_info().
- */
- function actions_loop_test_action_info() {
- return array(
- 'actions_loop_test_log' => array(
- 'label' => t('Write a message to the log.'),
- 'type' => 'system',
- ),
- );
- }
-
- * Write a message to the log.
- */
- function actions_loop_test_log() {
- $count = &backdrop_static(__FUNCTION__, 0);
- $count++;
- watchdog_skip_semaphore('actions_loop_test', "Test log #$count");
- }
-
- * Replacement of the watchdog() function that eliminates the use of semaphores
- * so that we can test the abortion of an action loop.
- */
- 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);
- }
- }