Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
cf561875
Commit
cf561875
authored
Aug 22, 2009
by
webchick
Browse files
#296322
follow-up. It's extremely helpful when I remember to commit ALL files. :P
parent
4c028a19
Changes
3
Hide whitespace changes
Inline
Side-by-side
modules/simpletest/tests/actions_loop_test.info
0 → 100644
View file @
cf561875
;
$
Id
$
name
=
Actions
loop
test
description
=
Support
module
for
action
loop
testing
.
package
=
Testing
version
=
VERSION
core
=
7.
x
files
[]
=
actions_loop_test
.
module
hidden
=
TRUE
modules/simpletest/tests/actions_loop_test.install
0 → 100644
View file @
cf561875
<?php
// $Id$
/**
* Implementation of hook_install().
*/
function
actions_loop_test_install
()
{
db_update
(
'system'
)
->
fields
(
array
(
'weight'
=>
1
))
->
condition
(
'name'
,
'actions_loop_test'
)
->
execute
();
}
modules/simpletest/tests/actions_loop_test.module
0 → 100644
View file @
cf561875
<?php
// $Id$
/**
* Implement hook_hook_info().
*/
function
actions_loop_test_hook_info
()
{
return
array
(
'actions_loop_test'
=>
array
(
'watchdog'
=>
array
(
'run'
=>
array
(
'runs when'
=>
t
(
'When a message is logged'
),
),
),
),
);
}
/**
* Implement hook_watchdog().
*/
function
actions_loop_test_watchdog
(
array
$log_entry
)
{
// If the triggering actions are not explicitly enabled, abort.
if
(
empty
(
$_GET
[
'trigger_actions_on_watchdog'
]))
{
return
;
}
// Get all the action ids assigned to the trigger on the watchdog hook's
// "run" event.
$aids
=
_trigger_get_hook_aids
(
'watchdog'
,
'run'
);
// We can pass in any applicable information in $context. There isn't much in
// this case, but we'll pass in the hook name and the operation name as the
// bare minimum.
$context
=
array
(
'hook'
=>
'watchdog'
,
'op'
=>
'run'
,
);
// Fire the actions on the associated object ($log_entry) and the context
// variable.
actions_do
(
array_keys
(
$aids
),
$log_entry
,
$context
);
}
/**
* Implement hook_init().
*/
function
actions_loop_test_init
()
{
if
(
!
empty
(
$_GET
[
'trigger_actions_on_watchdog'
]))
{
watchdog_skip_semaphore
(
'actions_loop_test'
,
'Triggering action loop'
);
}
}
/**
* Implement hook_action_info().
*/
function
actions_loop_test_action_info
()
{
return
array
(
'actions_loop_test_log'
=>
array
(
'description'
=>
t
(
'Write a message to the log.'
),
'type'
=>
'system'
,
'configurable'
=>
FALSE
,
'hooks'
=>
array
(
'any'
=>
TRUE
,
)
),
);
}
/**
* Write a message to the log.
*/
function
actions_loop_test_log
()
{
$count
=
&
drupal_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
;
// Prepare the fields to be logged
$log_entry
=
array
(
'type'
=>
$type
,
'message'
=>
$message
,
'variables'
=>
$variables
,
'severity'
=>
$severity
,
'link'
=>
$link
,
'user'
=>
$user
,
'request_uri'
=>
$base_root
.
request_uri
(),
'referer'
=>
$_SERVER
[
'HTTP_REFERER'
],
'ip'
=>
ip_address
(),
'timestamp'
=>
REQUEST_TIME
,
);
// Call the logging hooks to log/process the message
foreach
(
module_implements
(
'watchdog'
)
as
$module
)
{
module_invoke
(
$module
,
'watchdog'
,
$log_entry
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment