+
+ $manager = CRM_Extension_System::singleton()->getManager();
+ if ($dao->entity_type === 'Job' && !$manager->extensionIsBeingInstalledOrEnabled($dao->module)) {
+ // Special treatment for scheduled jobs:
+ //
+ // If we're being called as part of enabling/installing a module then
+ // we want the default behaviour of setting is_active = 1.
+ //
+ // However, if we're just being called by a normal cache flush then we
+ // should not re-enable a job that an administrator has decided to disable.
+ //
+ // Without this logic there was a problem: site admin might disable
+ // a job, but then when there was a flush op, the job was re-enabled
+ // which can cause significant embarrassment, depending on the job
+ // ("Don't worry, sending mailings is disabled right now...").
+ unset($params['is_active']);
+ }
+