MDL-17776 added new define CLI_SCRIPT that identifies all CLI scripts + cron (cli scripts do not have session and do not like HTML in output and are executed from command line, cron is an exception)

This commit is contained in:
skodak
2009-01-03 14:28:02 +00:00
parent e8b7114d5e
commit a91b910e4f
9 changed files with 42 additions and 31 deletions
+4 -4
View File
@@ -241,8 +241,8 @@ function get_role_access($roleid, $accessdata=NULL) {
ORDER BY ctx.depth, ctx.path";
$params = array($roleid);
// we need extra caching in cron only
if (defined('FULLME') and FULLME === 'cron') {
// we need extra caching in CLI scripts and cron
if (CLI_SCRIPT) {
static $cron_cache = array();
if (!isset($cron_cache[$roleid])) {
@@ -385,7 +385,7 @@ function has_capability($capability, $context, $userid=NULL, $doanything=true) {
array_shift($contexts);
}
if (defined('FULLME') && FULLME === 'cron' && !isset($USER->access)) {
if (CLI_SCRIPT && !isset($USER->access)) {
// In cron, some modules setup a 'fake' $USER,
// ensure we load the appropriate accessdata.
if (isset($ACCESS[$userid])) {
@@ -422,7 +422,7 @@ function has_capability($capability, $context, $userid=NULL, $doanything=true) {
$ACCESS = array();
$RDEFS = array();
if (defined('FULLME') && FULLME === 'cron') {
if (CLI_SCRIPT) {
load_user_accessdata($userid);
$USER->access = $ACCESS[$userid];
$DIRTYCONTEXTS = array();