Attached Files |
remove_before_scheduled_tasks_core.patch [^] (24,330 bytes) 2012-01-10 08:27
[Show Content]
Index: admin/system_presets/simple/scheduled_tasks_scheduled-task.php
===================================================================
--- admin/system_presets/simple/scheduled_tasks_scheduled-task.php (revision 15024)
+++ admin/system_presets/simple/scheduled_tasks_scheduled-task.php (working copy)
@@ -23,7 +23,7 @@
// fields to hide
$hidden_fields = Array (
- /* 'ScheduledTaskId', 'Name', 'Type', 'Status', 'Event', 'RunInterval', 'RunMode', 'LastRunOn',
+ /* 'ScheduledTaskId', 'Name', 'Type', 'Status', 'Event', 'RunInterval', 'LastRunOn',
'LastRunStatus', 'NextRunOn', 'RunTime', */
);
@@ -33,7 +33,7 @@
// fields to make required
$required_fields = Array (
- /* 'ScheduledTaskId', 'Name', 'Type', 'Status', 'Event', 'RunInterval', 'RunMode', 'LastRunOn',
+ /* 'ScheduledTaskId', 'Name', 'Type', 'Status', 'Event', 'RunInterval', 'LastRunOn',
'LastRunStatus', 'NextRunOn', 'RunTime', */
);
@@ -47,5 +47,5 @@
// hide columns in grids
$hide_columns = Array (
// currently not in user
-// 'Default' => Array ( 'ScheduledTaskId', 'Name', 'Type', 'Status', 'Event', 'RunInterval', 'RunMode', 'LastRunOn', 'LastRunStatus', 'NextRunOn', ),
+// 'Default' => Array ( 'ScheduledTaskId', 'Name', 'Type', 'Status', 'Event', 'RunInterval', 'LastRunOn', 'LastRunStatus', 'NextRunOn', ),
);
\ No newline at end of file
Index: core/admin_templates/scheduled_tasks/scheduled_task_edit.tpl
===================================================================
--- core/admin_templates/scheduled_tasks/scheduled_task_edit.tpl (revision 15024)
+++ core/admin_templates/scheduled_tasks/scheduled_task_edit.tpl (working copy)
@@ -77,7 +77,6 @@
</inp2:m_if>
<inp2:m_RenderElement name="inp_edit_box" prefix="scheduled-task" field="RunInterval"/>
- <inp2:m_RenderElement name="inp_edit_options" prefix="scheduled-task" field="RunMode" has_empty="1"/>
<inp2:m_RenderElement name="inp_label" prefix="scheduled-task" field="LastRunOn"/>
<inp2:m_RenderElement name="inp_label" prefix="scheduled-task" field="LastRunStatus"/>
<inp2:m_RenderElement name="inp_edit_date_time" prefix="scheduled-task" field="NextRunOn"/>
Index: core/install/english.lang
===================================================================
--- core/install/english.lang (revision 15024)
+++ core/install/english.lang (working copy)
@@ -587,7 +587,6 @@
<PHRASE Label="la_fld_RotationDelay" Module="Core" Type="1" Column="UHJvbW8gUm90YXRpb24gRGVsYXkgKHNlY29uZHMp">UHJvbW8gUm90YXRpb24gRGVsYXkgKHNlY29uZHMp</PHRASE>
<PHRASE Label="la_fld_RuleType" Module="Core" Type="1" Column="UnVsZSBUeXBl">UnVsZSBUeXBl</PHRASE>
<PHRASE Label="la_fld_RunInterval" Module="Core" Type="1" Column="UnVuIEludGVydmFs">UnVuIEludGVydmFs</PHRASE>
- <PHRASE Label="la_fld_RunMode" Module="Core" Type="1" Column="UnVuIE1vZGU=">UnVuIE1vZGU=</PHRASE>
<PHRASE Label="la_fld_RunTime" Module="Core" Type="1" Column="UnVuIFRpbWU=">UnVuIFRpbWU=</PHRASE>
<PHRASE Label="la_fld_SameAsThumb" Module="Core" Type="1">U2FtZSBBcyBUaHVtYg==</PHRASE>
<PHRASE Label="la_fld_ScheduleDate" Module="Core" Type="1">U2NoZWR1bGUgRGF0ZQ==</PHRASE>
Index: core/install/install_schema.sql
===================================================================
--- core/install/install_schema.sql (revision 15024)
+++ core/install/install_schema.sql (working copy)
@@ -677,7 +677,6 @@
`Status` tinyint(3) unsigned NOT NULL DEFAULT '1',
`Event` varchar(255) NOT NULL DEFAULT '',
RunInterval int(10) unsigned NOT NULL DEFAULT '0',
- RunMode tinyint(3) unsigned NOT NULL DEFAULT '2',
LastRunOn int(10) unsigned DEFAULT NULL,
LastRunStatus tinyint(3) unsigned NOT NULL DEFAULT '1',
NextRunOn int(11) DEFAULT NULL,
@@ -688,7 +687,6 @@
PRIMARY KEY (ScheduledTaskId),
KEY `Status` (`Status`),
KEY RunInterval (RunInterval),
- KEY RunMode (RunMode),
KEY LastRunOn (LastRunOn),
KEY LastRunStatus (LastRunStatus),
KEY RunTime (RunTime),
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql (revision 15024)
+++ core/install/upgrades.sql (working copy)
@@ -2594,3 +2594,5 @@
RENAME TABLE <%TABLE_PREFIX%>UserGroup TO <%TABLE_PREFIX%>UserGroupRelations;
RENAME TABLE <%TABLE_PREFIX%>Visits TO <%TABLE_PREFIX%>UserVisits;
RENAME TABLE <%TABLE_PREFIX%>SessionLogs TO <%TABLE_PREFIX%>UserSessionLogs;
+
+DELETE FROM LanguageLabels WHERE PhraseKey = 'LA_FLD_RUNMODE';
Index: core/kernel/application.php
===================================================================
--- core/kernel/application.php (revision 15024)
+++ core/kernel/application.php (working copy)
@@ -1116,7 +1116,7 @@
}
if ( $debug_mode ) {
- $this->EventManager->runScheduledTasks(reAFTER);
+ $this->EventManager->runScheduledTasks();
$this->Session->SaveData();
if ( kUtil::constOn('DBG_CACHE') ) {
@@ -1150,7 +1150,7 @@
flush();
if ( !$debug_mode ) {
- $this->EventManager->runScheduledTasks(reAFTER);
+ $this->EventManager->runScheduledTasks();
$this->Session->SaveData();
}
@@ -1973,15 +1973,14 @@
* Add new scheduled task
*
* @param string $short_name name to be used to store last maintenance run info
- * @param string $event_name
+ * @param string $event_string
* @param int $run_interval run interval in seconds
- * @param int $type before or after scheduled task
* @param int $status
* @access public
*/
- public function registerScheduledTask($short_name, $event_name, $run_interval, $type = reBEFORE, $status = STATUS_ACTIVE)
+ public function registerScheduledTask($short_name, $event_string, $run_interval, $status = STATUS_ACTIVE)
{
- $this->EventManager->registerScheduledTask($short_name, $event_name, $run_interval, $type, $status);
+ $this->EventManager->registerScheduledTask($short_name, $event_string, $run_interval, $status);
}
/**
Index: core/kernel/constants.php
===================================================================
--- core/kernel/constants.php (revision 15024)
+++ core/kernel/constants.php (working copy)
@@ -155,9 +155,6 @@
define('CONTENT_LASTAUTOSAVE_UPDATE_INTERVAL', 5 * 60); // 5 minutes
define('CONTENT_LASTAUTOSAVE_REFRESH_INTERVAL', 20); // 20 seconds
- define('reBEFORE', 1);
- define('reAFTER', 2);
-
define('hBEFORE', 1);
define('hAFTER', 2);
Index: core/kernel/event_manager.php
===================================================================
--- core/kernel/event_manager.php (revision 15024)
+++ core/kernel/event_manager.php (working copy)
@@ -117,27 +117,25 @@
* Add new scheduled task
*
* @param string $short_name name to be used to store last maintenance run info
- * @param string $event_name
+ * @param string $event_string
* @param int $run_interval run interval in seconds
- * @param int $type before or after scheduled task
* @param int $status
* @access public
*/
- public function registerScheduledTask($short_name, $event_name, $run_interval, $type = reBEFORE, $status = STATUS_ACTIVE)
+ public function registerScheduledTask($short_name, $event_string, $run_interval, $status = STATUS_ACTIVE)
{
- $this->ScheduledTasks->add($short_name, $event_name, $run_interval, $type, $status);
+ $this->ScheduledTasks->add($short_name, $event_string, $run_interval, $status);
}
/**
* Run registered scheduled tasks with specified event type
*
- * @param int $event_type
* @param bool $from_cron
* @access public
*/
- public function runScheduledTasks($event_type = reBEFORE, $from_cron = false)
+ public function runScheduledTasks($from_cron = false)
{
- $this->ScheduledTasks->runAll($event_type, $from_cron);
+ $this->ScheduledTasks->runAll($from_cron);
}
/**
Index: core/kernel/managers/cache_manager.php
===================================================================
--- core/kernel/managers/cache_manager.php (revision 15024)
+++ core/kernel/managers/cache_manager.php (working copy)
@@ -314,8 +314,7 @@
$cache_keys = Array (
'Factory.Files', 'Factory.realClasses', 'Factory.Dependencies',
'EventManager.buildEvents', 'EventManager.beforeHooks',
- 'EventManager.afterHooks', 'EventManager.beforeRegularEvents',
- 'EventManager.afterRegularEvents'
+ 'EventManager.afterHooks', 'EventManager.scheduledTasks',
);
$empty_cache = Array ();
Index: core/kernel/managers/request_manager.php
===================================================================
--- core/kernel/managers/request_manager.php (revision 15024)
+++ core/kernel/managers/request_manager.php (working copy)
@@ -66,8 +66,6 @@
$this->Application->SetVar('events', $events);
$this->Application->SetVar('passed', implode(',', $all_passed));
- $this->Application->EventManager->runScheduledTasks(reBEFORE);
-
$this->processed = true;
}
Index: core/kernel/managers/scheduled_task_manager.php
===================================================================
--- core/kernel/managers/scheduled_task_manager.php (revision 15024)
+++ core/kernel/managers/scheduled_task_manager.php (working copy)
@@ -17,20 +17,12 @@
class kScheduledTaskManager extends kBase implements kiCacheable {
/**
- * Events, that should be run before parser initialization
- *
- * @var Array
- * @access protected
- */
- protected $before = Array ();
-
- /**
* Events, that should be run after parser initialization
*
* @var Array
* @access protected
*/
- protected $after = Array ();
+ protected $tasks = Array ();
/**
* Sets data from cache to object
@@ -40,8 +32,7 @@
*/
public function setFromCache(&$data)
{
- $this->before = $data['EventManager.beforeRegularEvents'];
- $this->after = $data['EventManager.afterRegularEvents'];
+ $this->tasks = $data['EventManager.scheduledTasks'];
}
/**
@@ -53,8 +44,7 @@
public function getToCache()
{
return Array (
- 'EventManager.beforeRegularEvents' => $this->before,
- 'EventManager.afterRegularEvents' => $this->after,
+ 'EventManager.scheduledTasks' => $this->tasks,
);
}
@@ -69,11 +59,8 @@
{
static $scheduled_tasks = null;
- if ($from_cache) {
- return Array (
- reBEFORE => $this->before,
- reAFTER => $this->after,
- );
+ if ( $from_cache ) {
+ return $this->tasks;
}
if ( !isset($scheduled_tasks) ) {
@@ -82,72 +69,35 @@
$sql = 'SELECT *
FROM ' . $this->Application->getUnitOption('scheduled-task', 'TableName') . '
WHERE (Status = ' . STATUS_ACTIVE . ') AND ((LastRunStatus != ' . ScheduledTask::LAST_RUN_RUNNING . ') OR (' . $timeout_clause . '))';
- $all_scheduled_tasks = $this->Conn->Query($sql);
-
- $scheduled_tasks = Array (
- reBEFORE => Array (),
- reAFTER => Array (),
- );
-
- foreach ($all_scheduled_tasks as $scheduled_task_data) {
- $scheduled_tasks[ $scheduled_task_data['RunMode'] ][ $scheduled_task_data['Name'] ] = Array (
- 'EventName' => $scheduled_task_data['Event'],
- 'RunInterval' => (int)$scheduled_task_data['RunInterval'],
- 'LastRunOn' => (int)$scheduled_task_data['LastRunOn'],
- 'NextRunOn' => (int)$scheduled_task_data['NextRunOn'],
- 'Status' => $scheduled_task_data['Status'],
- 'LastRunStatus' => $scheduled_task_data['LastRunStatus'],
- 'SiteDomainLimitation' => $scheduled_task_data['SiteDomainLimitation'],
- );
- }
+ $scheduled_tasks = $this->Conn->Query($sql, 'Name');
}
return $scheduled_tasks;
}
/**
- * Returns scheduled tasks by type
- *
- * @param int $type
- * @return Array
- * @access protected
- */
- protected function &getByType($type)
- {
- if ($type == reBEFORE) {
- return $this->before;
- }
-
- return $this->after;
- }
-
- /**
* Add new scheduled task
*
* @param string $short_name name to be used to store last maintenance run info
- * @param string $event_name
+ * @param string $event_string
* @param int $run_interval run interval in seconds
- * @param int $type before or after scheduled task
* @param int $status
* @access public
*/
- public function add($short_name, $event_name, $run_interval, $type = reBEFORE, $status = STATUS_ACTIVE)
+ public function add($short_name, $event_string, $run_interval, $status = STATUS_ACTIVE)
{
- $scheduled_tasks =& $this->getByType($type);
-
- $scheduled_tasks[$short_name] = Array (
- 'EventName' => $event_name, 'RunInterval' => $run_interval, 'Status' => $status
+ $this->tasks[$short_name] = Array (
+ 'Event' => $event_string, 'RunInterval' => $run_interval, 'Status' => $status
);
}
/**
* Run registered scheduled tasks with specified event type
*
- * @param int $event_type
* @param bool $from_cron
* @access public
*/
- public function runAll($event_type = reBEFORE, $from_cron = false)
+ public function runAll($from_cron = false)
{
if ( defined('IS_INSTALL') ) {
return ;
@@ -158,8 +108,7 @@
return ;
}
- $scheduled_tasks = $this->getAll();
- $events_source = $scheduled_tasks[$event_type];
+ $events_source = $this->getAll();
$user_id = $this->Application->RecallVar('user_id');
$this->Application->StoreVar('user_id', USER_ROOT, true); // to prevent permission checking inside events, true for optional storage
@@ -184,7 +133,7 @@
$this->update($short_name, Array ('LastTimeoutOn' => adodb_mktime()));
}
- $next_run = $event_data['NextRunOn'];
+ $next_run = (int)$event_data['NextRunOn'];
if ($next_run && ($next_run > adodb_mktime())) {
continue;
@@ -206,7 +155,7 @@
*/
public function run($scheduled_task_data)
{
- $event = new kEvent($scheduled_task_data['EventName']);
+ $event = new kEvent($scheduled_task_data['Event']);
if ( !$this->Application->prefixRegistred($event->Prefix) ) {
// don't process scheduled tasks, left from disabled modules
Index: core/kernel/utility/unit_config_reader.php
===================================================================
--- core/kernel/utility/unit_config_reader.php (revision 15024)
+++ core/kernel/utility/unit_config_reader.php (working copy)
@@ -469,7 +469,7 @@
foreach ($scheduled_tasks as $short_name => $scheduled_task_info) {
$event_status = array_key_exists('Status', $scheduled_task_info) ? $scheduled_task_info['Status'] : STATUS_ACTIVE;
- $this->Application->delayUnitProcessing('registerScheduledTask', Array ( $short_name, $config['Prefix'] . ':' . $scheduled_task_info['EventName'], $scheduled_task_info['RunInterval'], $scheduled_task_info['Type'], $event_status ));
+ $this->Application->delayUnitProcessing('registerScheduledTask', Array ( $short_name, $config['Prefix'] . ':' . $scheduled_task_info['EventName'], $scheduled_task_info['RunInterval'], $event_status ));
}
}
Index: core/units/admin/admin_config.php
===================================================================
--- core/units/admin/admin_config.php (revision 15024)
+++ core/units/admin/admin_config.php (working copy)
@@ -25,7 +25,7 @@
),
'ScheduledTasks' => Array(
- 'optimize_performance' => Array('EventName' => 'OnOptimizePerformance', 'RunInterval' => 86400, 'Type' => reAFTER),
+ 'optimize_performance' => Array('EventName' => 'OnOptimizePerformance', 'RunInterval' => 86400),
),
'TitlePresets' => Array (
Index: core/units/forms/forms/forms_config.php
===================================================================
--- core/units/forms/forms/forms_config.php (revision 15024)
+++ core/units/forms/forms/forms_config.php (working copy)
@@ -31,8 +31,8 @@
),
'ScheduledTasks' => Array (
- 'check_submission_repies' => Array('EventName' => 'OnProcessReplies', 'RunInterval' => 3600, 'Type' => reAFTER),
- 'check_bounced_submission_repies' => Array('EventName' => 'OnProcessBouncedReplies', 'RunInterval' => 18000, 'Type' => reAFTER),
+ 'check_submission_repies' => Array('EventName' => 'OnProcessReplies', 'RunInterval' => 3600),
+ 'check_bounced_submission_repies' => Array('EventName' => 'OnProcessBouncedReplies', 'RunInterval' => 18000),
),
'Hooks' => Array(
Index: core/units/images/images_config.php
===================================================================
--- core/units/images/images_config.php (revision 15024)
+++ core/units/images/images_config.php (working copy)
@@ -70,8 +70,8 @@
),
'ScheduledTasks' => Array (
- 'clean_catalog_images' => Array ('EventName' => 'OnCleanImages', 'RunInterval' => 604800, 'Type' => reAFTER, 'Status' => STATUS_DISABLED),
- 'clean_resized_catalog_images' => Array ('EventName' => 'OnCleanResizedImages', 'RunInterval' => 2592000, 'Type' => reAFTER, 'Status' => STATUS_DISABLED),
+ 'clean_catalog_images' => Array ('EventName' => 'OnCleanImages', 'RunInterval' => 604800, 'Status' => STATUS_DISABLED),
+ 'clean_resized_catalog_images' => Array ('EventName' => 'OnCleanResizedImages', 'RunInterval' => 2592000, 'Status' => STATUS_DISABLED),
),
'IDField' => 'ImageId',
Index: core/units/mailing_lists/mailing_lists_config.php
===================================================================
--- core/units/mailing_lists/mailing_lists_config.php (revision 15024)
+++ core/units/mailing_lists/mailing_lists_config.php (working copy)
@@ -32,8 +32,8 @@
),
'ScheduledTasks' => Array (
- 'generate_mailing_queue' => Array ('EventName' => 'OnGenerateEmailQueue', 'RunInterval' => 1800, 'Type' => reAFTER),
- 'process_mailing_queue' => Array ('EventName' => 'OnProcessEmailQueue', 'RunInterval' => 1800, 'Type' => reAFTER),
+ 'generate_mailing_queue' => Array ('EventName' => 'OnGenerateEmailQueue', 'RunInterval' => 1800),
+ 'process_mailing_queue' => Array ('EventName' => 'OnProcessEmailQueue', 'RunInterval' => 1800),
),
'IDField' => 'MailingId',
Index: core/units/scheduled_tasks/scheduled_task_eh.php
===================================================================
--- core/units/scheduled_tasks/scheduled_task_eh.php (revision 15024)
+++ core/units/scheduled_tasks/scheduled_task_eh.php (working copy)
@@ -50,30 +50,25 @@
$processed_ids = Array ();
$scheduled_tasks_from_db = $this->Conn->Query($object->GetSelectSQL(), 'Name');
- foreach ($scheduled_tasks_from_cache as $run_mode => $events) {
+ foreach ($scheduled_tasks_from_cache as $scheduled_task_name => $scheduled_task_params) {
+ if ( !isset($scheduled_tasks_from_db[$scheduled_task_name]) ) {
+ $fields_hash = Array (
+ 'Event' => $scheduled_task_params['Event'],
+ 'Name' => $scheduled_task_name,
+ 'Type' => ScheduledTask::TYPE_SYSTEM,
+ 'Status' => isset($scheduled_task_params['Status']) ? $scheduled_task_params['Status'] : STATUS_ACTIVE,
+ 'RunInterval' => $scheduled_task_params['RunInterval'],
+ );
- foreach ($events as $scheduled_task_name => $scheduled_task_params) {
- if ( !isset($scheduled_tasks_from_db[$scheduled_task_name]) ) {
- $fields_hash = Array (
- 'Event' => $scheduled_task_params['EventName'],
- 'Name' => $scheduled_task_name,
- 'Type' => ScheduledTask::TYPE_SYSTEM,
- 'Status' => array_key_exists('Status', $scheduled_task_params) ? $scheduled_task_params['Status'] : STATUS_ACTIVE,
- 'RunInterval' => $scheduled_task_params['RunInterval'],
- 'RunMode' => $run_mode,
- );
-
- $object->Clear();
- $object->SetDBFieldsFromHash($fields_hash);
- $object->Create();
- }
- else {
- $object->LoadFromHash( $scheduled_tasks_from_db[$scheduled_task_name] );
- }
-
- $processed_ids[] = $object->GetID();
+ $object->Clear();
+ $object->SetDBFieldsFromHash($fields_hash);
+ $object->Create();
}
+ else {
+ $object->LoadFromHash( $scheduled_tasks_from_db[$scheduled_task_name] );
+ }
+ $processed_ids[] = $object->GetID();
}
// delete all non-processed scheduled tasks (ones, that were deleted from unit configs)
Index: core/units/scheduled_tasks/scheduled_tasks_config.php
===================================================================
--- core/units/scheduled_tasks/scheduled_tasks_config.php (revision 15024)
+++ core/units/scheduled_tasks/scheduled_tasks_config.php (working copy)
@@ -119,11 +119,6 @@
'required' => 1, 'not_null' => 1, 'default' => ''
),
'RunInterval' => Array ('type' => 'int', 'required' => 1, 'not_null' => 1, 'default' => 0),
- 'RunMode' => Array (
- 'type' => 'int',
- 'formatter' => 'kOptionsFormatter', 'options' => Array (reBEFORE => 'la_opt_Before', reAFTER => 'la_opt_After'), 'use_phrases' => 1,
- 'required' => 1, 'not_null' => 1, 'default' => 2
- ),
'LastRunOn' => Array ('type' => 'int', 'formatter' => 'kDateFormatter', 'default' => NULL),
'LastRunStatus' => Array (
@@ -159,7 +154,6 @@
'Type' => Array ('filter_block' => 'grid_options_filter', 'width' => 60, ),
'Event' => Array ('filter_block' => 'grid_like_filter', 'width' => 280, ),
'RunInterval' => Array ('filter_block' => 'grid_range_filter', 'width' => 100, ),
- 'RunMode' => Array ('filter_block' => 'grid_options_filter', 'width' => 85, ),
'LastRunOn' => Array ('filter_block' => 'grid_date_range_filter', 'width' => 145, ),
'RunTime' => Array ('filter_block' => 'grid_range_filter', 'width' => 145, ),
'LastRunStatus' => Array ('filter_block' => 'grid_options_filter', 'width' => 120, ),
Index: core/units/users/users_config.php
===================================================================
--- core/units/users/users_config.php (revision 15024)
+++ core/units/users/users_config.php (working copy)
@@ -93,8 +93,8 @@
),
'ScheduledTasks' => Array(
- 'membership_expiration' => Array('EventName' => 'OnCheckExpiredMembership', 'RunInterval' => 1800, 'Type' => reAFTER),
- 'delete_expired_sessions' => Array('EventName' => 'OnDeleteExpiredSessions', 'RunInterval' => 43200, 'Type' => reAFTER),
+ 'membership_expiration' => Array('EventName' => 'OnCheckExpiredMembership', 'RunInterval' => 1800),
+ 'delete_expired_sessions' => Array('EventName' => 'OnDeleteExpiredSessions', 'RunInterval' => 43200),
),
'IDField' => 'PortalUserId',
Index: tools/cron.php
===================================================================
--- tools/cron.php (revision 15024)
+++ tools/cron.php (working copy)
@@ -12,32 +12,31 @@
* See http://www.in-portal.org/license for copyright notices and details.
*/
- // Use either of lines above to invoke from cron:
- // */10 * * * * wget http://<server_address>/tools/cron.php -O /dev/null > /dev/null 2>&1
- // */10 * * * * /usr/bin/php /path/to/site/tools/cron.php
+// Use either of lines above to invoke from cron:
+// */10 * * * * wget http://<server_address>/tools/cron.php -O /dev/null > /dev/null 2>&1
+// */10 * * * * /usr/bin/php /path/to/site/tools/cron.php
- $start = microtime(true);
+$start = microtime(true);
- define('CRON', 1);
- define('ADMIN', 1);
- define('FULL_PATH', realpath(dirname(__FILE__) . '/..'));
- define('CMD_MODE', isset($argv) && count($argv) ? 1 : 0);
+define('CRON', 1);
+define('ADMIN', 1);
+define('FULL_PATH', realpath(dirname(__FILE__) . '/..'));
+define('CMD_MODE', isset($argv) && count($argv) ? 1 : 0);
- if (CMD_MODE) {
- define('DBG_SKIP_REPORTING', 1);
- $_SERVER['REQUEST_URI'] = 'CRON';
- $_SERVER['HTTP_USER_AGENT'] = 'gecko';
- }
+if ( CMD_MODE ) {
+ define('DBG_SKIP_REPORTING', 1);
+ $_SERVER['REQUEST_URI'] = 'CRON';
+ $_SERVER['HTTP_USER_AGENT'] = 'gecko';
+}
- include_once(FULL_PATH . '/core/kernel/startup.php');
+include_once(FULL_PATH . '/core/kernel/startup.php');
- $application =& kApplication::Instance();
- $application->Init();
+$application =& kApplication::Instance();
+$application->Init();
- // events from request are not processed, only predefined regular events
- $application->EventManager->runScheduledTasks(reBEFORE, true);
- $application->EventManager->runScheduledTasks(reAFTER, true);
+// events from request are not processed, only predefined scheduled tasks
+$application->EventManager->runScheduledTasks(true);
- $application->Done();
+$application->Done();
- $end = microtime(true);
\ No newline at end of file
+$end = microtime(true);
\ No newline at end of file
remove_before_scheduled_tasks_modules.patch [^] (16,003 bytes) 2012-01-10 08:27
[Show Content]
Index: in-auction/units/listing/listing_config.php
===================================================================
--- in-auction/units/listing/listing_config.php (revision 15024)
+++ in-auction/units/listing/listing_config.php (working copy)
@@ -23,7 +23,7 @@
'ScheduledTasks' => Array(
- 'list_items' => Array('EventName' => 'OnListItems', 'RunInterval' => 600, 'Type' => reAFTER),
+ 'list_items' => Array('EventName' => 'OnListItems', 'RunInterval' => 600),
),
'QueryString' => Array (
Index: in-auction/units/sections/sections_config.php
===================================================================
--- in-auction/units/sections/sections_config.php (revision 15024)
+++ in-auction/units/sections/sections_config.php (working copy)
@@ -27,16 +27,16 @@
),
'ScheduledTasks' => Array(
- 'seller_transactions' => Array('EventName' => 'OnGetSellerTransactions', 'RunInterval' => 600, 'Type' => reAFTER),
- 'seller_list' => Array('EventName' => 'OnGetSellerList', 'RunInterval' => 600, 'Type' => reAFTER),
- 'auto_dispute' => Array('EventName' => 'OnAutoDispute', 'RunInterval' => 600, 'Type' => reAFTER),
- 'auctions_schedule' => Array('EventName' => 'OnProcessSchedule', 'RunInterval' => 1800, 'Type' => reAFTER),
- 'subscribe_ebay_notifications' => Array('EventName' => 'OnSubscribeListingNotifications', 'RunInterval' => 360000, 'Type' => reAFTER),
- 'delete_old_hits' => Array('EventName' => 'OnDeleteOldHits', 'RunInterval' => 72000, 'Type' => reAFTER),
- 'revise_checkout_statuses' => Array('EventName' => 'OnReviseCheckoutStatuses', 'RunInterval' => 43200, 'Type' => reAFTER),
- 'receive_feedbacks' => Array('EventName' => 'OnReceiveFeedbacks', 'RunInterval' => 43200, 'Type' => reAFTER),
- 'send_feedbacks' => Array('EventName' => 'OnSendFeedbacks', 'RunInterval' => 43200, 'Type' => reAFTER),
- 'send_feedback_notifications' => Array('EventName' => 'OnSendFeedbackNotifications', 'RunInterval' => 43200, 'Type' => reAFTER),
+ 'seller_transactions' => Array('EventName' => 'OnGetSellerTransactions', 'RunInterval' => 600),
+ 'seller_list' => Array('EventName' => 'OnGetSellerList', 'RunInterval' => 600),
+ 'auto_dispute' => Array('EventName' => 'OnAutoDispute', 'RunInterval' => 600),
+ 'auctions_schedule' => Array('EventName' => 'OnProcessSchedule', 'RunInterval' => 1800),
+ 'subscribe_ebay_notifications' => Array('EventName' => 'OnSubscribeListingNotifications', 'RunInterval' => 360000),
+ 'delete_old_hits' => Array('EventName' => 'OnDeleteOldHits', 'RunInterval' => 72000),
+ 'revise_checkout_statuses' => Array('EventName' => 'OnReviseCheckoutStatuses', 'RunInterval' => 43200),
+ 'receive_feedbacks' => Array('EventName' => 'OnReceiveFeedbacks', 'RunInterval' => 43200),
+ 'send_feedbacks' => Array('EventName' => 'OnSendFeedbacks', 'RunInterval' => 43200),
+ 'send_feedback_notifications' => Array('EventName' => 'OnSendFeedbackNotifications', 'RunInterval' => 43200),
),
Index: in-commerce/units/affiliates/affiliates_config.php
===================================================================
--- in-commerce/units/affiliates/affiliates_config.php (revision 15024)
+++ in-commerce/units/affiliates/affiliates_config.php (working copy)
@@ -42,6 +42,28 @@
'DoSpecial' => 'register',
'DoEvent' => 'OnRegisterAffiliate',
),
+
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'adm',
+ 'HookToSpecial' => '',
+ 'HookToEvent' => Array('OnStartup'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnResetStatistics',
+ ),
+
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'adm',
+ 'HookToSpecial' => '',
+ 'HookToEvent' => Array('OnStartup'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnStoreAffiliate',
+ ),
),
'AggregateTags' => Array(
Array(
@@ -85,11 +107,6 @@
5 => 'mode',
),
- 'ScheduledTasks' => Array(
- 'store_affiliate' => Array('EventName' => 'OnStoreAffiliate', 'RunInterval' => 0, 'Type' => reBEFORE),
- 'reset_affiliate_stats' => Array('EventName' => 'OnResetStatistics', 'RunInterval' => 0, 'Type' => reBEFORE),
- ),
-
'IDField' => 'AffiliateId',
'StatusField' => Array('Status'), // field, that is affected by Approve/Decline events
Index: in-commerce/units/affiliates/affiliates_event_handler.php
===================================================================
--- in-commerce/units/affiliates/affiliates_event_handler.php (revision 15024)
+++ in-commerce/units/affiliates/affiliates_event_handler.php (working copy)
@@ -159,16 +159,14 @@
}
/**
- * Stores affiliate id using method from Config (session or cookie) if correct code is present in url
+ * [HOOK] Stores affiliate id using method from Config (session or cookie) if correct code is present in url
*
* @param kEvent $event
* @return bool
*/
function OnStoreAffiliate(&$event)
{
- $event->Init($event->Prefix, '-item');
-
- $object =& $event->getObject(Array ('skip_autoload' => true));
+ $object =& $this->Application->recallObject($event->Prefix . '.-item', null, Array ('skip_autoload' => true));
/* @var $object kDBItem */
$affiliate_storage_method = $this->Application->ConfigValue('Comm_AffiliateStorageMethod');
@@ -182,23 +180,21 @@
$object->Load($affiliate_id);
}
- if( $object->isLoaded() && ($object->GetDBField('Status') == 1) )
- {
+ if ( $object->isLoaded() && ($object->GetDBField('Status') == 1) ) {
// user is found with such email
- $affiliate_user =& $this->Application->recallObject('u.affiliate', null, Array('skip_autoload'=>true) );
- $affiliate_user->Load( $object->GetDBField('PortalUserId') );
+ $affiliate_user =& $this->Application->recallObject('u.affiliate', null, Array ('skip_autoload' => true));
+ /* @var $affiliate_user UsersItem */
- if($affiliate_user->GetDBField('Status') == 1)
- {
+ $affiliate_user->Load($object->GetDBField('PortalUserId'));
+
+ if ( $affiliate_user->GetDBField('Status') == 1 ) {
$affiliate_id = $object->GetDBField('AffiliateId');
$this->Application->setVisitField('AffiliateId', $affiliate_id);
- if($affiliate_storage_method == 1)
- {
+ if ( $affiliate_storage_method == 1 ) {
$this->Application->StoreVar('affiliate_id', $affiliate_id); // per session
}
- else
- {
+ else {
// in cookie
$this->Application->Session->SetCookie('affiliate_id', $affiliate_id, $this->getCookieExpiration());
}
@@ -473,40 +469,48 @@
}
/**
- * Resets statistics (accumulated amount & items sold) for affiliates based on ResetInterval in their plan
+ * [HOOK] Resets statistics (accumulated amount & items sold) for affiliates based on ResetInterval in their plan
*
* @param kEvent $event
* @author Alex
*/
function OnResetStatistics(&$event)
{
- $intervals = Array(86400 => 'la_day', 604800 => 'la_week', 2628000 => 'la_month', 7884000 => 'la_quartely', 31536000 => 'la_year');
+ $intervals = Array (86400 => 'la_day', 604800 => 'la_week', 2628000 => 'la_month', 7884000 => 'la_quartely', 31536000 => 'la_year');
- $affil_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
- $ap_table = $this->Application->getUnitOption('ap', 'TableName');
+ $affiliates_table = $this->Application->getUnitOption($event->Prefix, 'TableName');
+ $affiliate_plan_table = $this->Application->getUnitOption('ap', 'TableName');
- $sql = 'SELECT AffiliateId
- FROM '.$affil_table.' a
- LEFT JOIN '.$ap_table.' ap ON a.AffiliatePlanId = ap.AffiliatePlanId';
+ $base_time = adodb_mktime();
+ $where_clause = Array ();
- $base_time = adodb_mktime();
- $where_clause = Array();
- foreach($intervals as $interval_length => $interval_description)
- {
+ foreach ($intervals as $interval_length => $interval_description) {
$start_timestamp = $this->getPeriodStartTS($base_time, $interval_length);
- $where_clause[] = 'ap.ResetInterval = '.$interval_length.' AND LastOrderDate < '.$start_timestamp;
+ $where_clause[] = 'ap.ResetInterval = ' . $interval_length . ' AND LastOrderDate < ' . $start_timestamp;
}
- $sql .= ' WHERE ('.implode(') OR (', $where_clause).')';
+ $sql = 'SELECT AffiliateId
+ FROM ' . $affiliates_table . ' a
+ LEFT JOIN ' . $affiliate_plan_table . ' ap ON a.AffiliatePlanId = ap.AffiliatePlanId
+ WHERE (' . implode(') OR (', $where_clause) . ')';
$affiliate_ids = $this->Conn->GetCol($sql);
- if ($affiliate_ids && defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode()) {
+ if ( !$affiliate_ids ) {
+ return;
+ }
+
+ if ( defined('DEBUG_MODE') && DEBUG_MODE && $this->Application->isDebugMode() ) {
$this->Application->Debugger->appendHTML('Affiliates Pending Totals Reset: ');
$this->Application->Debugger->dumpVars($affiliate_ids);
}
- $sql = 'UPDATE '.$affil_table.' SET AccumulatedAmount = 0, ItemsSold = 0, LastOrderDate = %s WHERE AffiliateId IN (%s)';
- if($affiliate_ids) $this->Conn->Query( sprintf($sql, $base_time, implode(',', $affiliate_ids) ) );
+ $fields_hash = Array (
+ 'AccumulatedAmount' => 0,
+ 'ItemsSold' => 0,
+ 'LastOrderDate' => $base_time,
+ );
+
+ $this->Conn->doUpdate($fields_hash, $affiliates_table, 'AffiliateId IN (' . implode(',', $affiliate_ids) . ')');
}
/**
@@ -519,43 +523,43 @@
*/
function getPeriodStartTS($base_time, $period_length)
{
- switch($period_length)
- {
- case 86400: // day
- $start_timestamp = adodb_mktime(0,0,0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time) );
+ $start_timestamp = 0;
+
+ switch ($period_length) {
+ case 86400: // day
+ $start_timestamp = adodb_mktime(0, 0, 0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time));
break;
case 604800: // week
$day_seconds = 86400;
$first_week_day = $this->Application->ConfigValue('FirstDayOfWeek');
- $morning = adodb_mktime(0,0,0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time) );
+ $morning = adodb_mktime(0, 0, 0, adodb_date('m', $base_time), adodb_date('d', $base_time), adodb_date('Y', $base_time));
$week_day = adodb_date('w', $morning);
- if($week_day == $first_week_day)
- {
+ if ( $week_day == $first_week_day ) {
// if it is already first week day, then don't search for previous week day
$day_diff = 0;
}
- else
- {
+ else {
// this way, because sunday is 0, but not 7 as it should be
- $day_diff = $week_day != 0 ? $week_day - $first_week_day: 7 - $first_week_day;
+ $day_diff = $week_day != 0 ? $week_day - $first_week_day : 7 - $first_week_day;
}
$start_timestamp = $morning - $day_diff * $day_seconds;
break;
case 2628000: // month
- $start_timestamp = adodb_mktime(0,0,0, adodb_date('m', $base_time), 1, adodb_date('Y', $base_time) );
+ $start_timestamp = adodb_mktime(0, 0, 0, adodb_date('m', $base_time), 1, adodb_date('Y', $base_time));
break;
case 7884000: // quartal
- $first_quartal_month = (ceil( adodb_date('m', $base_time) / 3)-1)*3 + 1;
- $start_timestamp = adodb_mktime(0,0,0, $first_quartal_month, 1, adodb_date('Y', $base_time) );
+ $first_quartal_month = (ceil(adodb_date('m', $base_time) / 3) - 1) * 3 + 1;
+ $start_timestamp = adodb_mktime(0, 0, 0, $first_quartal_month, 1, adodb_date('Y', $base_time));
break;
case 31536000:
- $start_timestamp = adodb_mktime(0,0,0,1,1, adodb_date('Y', $base_time) );
+ $start_timestamp = adodb_mktime(0, 0, 0, 1, 1, adodb_date('Y', $base_time));
break;
}
+
return $start_timestamp;
}
Index: in-link/units/link_validation/link_validation_config.php
===================================================================
--- in-link/units/link_validation/link_validation_config.php (revision 15024)
+++ in-link/units/link_validation/link_validation_config.php (working copy)
@@ -45,7 +45,7 @@
),
'ScheduledTasks' => Array (
- 'link_validation' => Array ('EventName' => 'OnCronValidation', 'RunInterval' => 3600*24, 'Type' => reAFTER),
+ 'link_validation' => Array ('EventName' => 'OnCronValidation', 'RunInterval' => 3600*24),
),
'IDField' => 'LinkValidationId',
Index: in-link/units/listings/listings_config.php
===================================================================
--- in-link/units/listings/listings_config.php (revision 15024)
+++ in-link/units/listings/listings_config.php (working copy)
@@ -44,7 +44,7 @@
),
'ScheduledTasks' => Array (
- 'listings_expiration' => Array ('EventName' => 'OnCheckExpiredPaidListings', 'RunInterval' => 1800, 'Type' => reAFTER),
+ 'listings_expiration' => Array ('EventName' => 'OnCheckExpiredPaidListings', 'RunInterval' => 1800),
),
'IDField' => 'ListingId',
Index: in-news/units/articles/articles_config.php
===================================================================
--- in-news/units/articles/articles_config.php (revision 15024)
+++ in-news/units/articles/articles_config.php (working copy)
@@ -116,6 +116,17 @@
'DoSpecial' => '*',
'DoEvent' => 'OnCloneSubItem',
),
+
+ Array(
+ 'Mode' => hAFTER,
+ 'Conditional' => false,
+ 'HookToPrefix' => 'adm',
+ 'HookToSpecial' => '',
+ 'HookToEvent' => Array('OnStartup'),
+ 'DoPrefix' => '',
+ 'DoSpecial' => '',
+ 'DoEvent' => 'OnUpdateRSSArticles',
+ ),
),
'CatalogItem' => true,
@@ -131,10 +142,6 @@
5 => 'mode',
),
- 'ScheduledTasks' => Array (
- 'rss_category_update' => Array ('EventName' => 'OnUpdateRSSAtricles', 'RunInterval' => 0, 'Type' => reBEFORE),
- ),
-
'IDField' => 'NewsId',
'StatusField' => Array ('Status'), // field, that is affected by Approve/Decline events
Index: in-news/units/articles/articles_event_handler.php
===================================================================
--- in-news/units/articles/articles_event_handler.php (revision 15024)
+++ in-news/units/articles/articles_event_handler.php (working copy)
@@ -60,11 +60,11 @@
/**
- * [SCHEDULED TASK] Deletes expired articles + update existing articles from rss feed with new data (key - article url)
+ * [HOOK] Deletes expired articles + update existing articles from rss feed with new data (key - article url)
*
* @param kEvent $event
*/
- function OnUpdateRSSAtricles(&$event)
+ function OnUpdateRSSArticles(&$event)
{
$category_table = $this->Application->getUnitOption('c', 'TableName');
$custom_table = $this->Application->getUnitOption('c-cdata', 'TableName');
@@ -125,8 +125,10 @@
(LENGTH(cd.'.$article_custom_fields['RssOriginalURL'].') > 0)';
$article_ids = $this->Conn->GetCol($sql);
if ($article_ids) {
- $temp =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
- $temp->DeleteItems($event->Prefix, $event->Special, $article_ids);
+ $temp_handler =& $this->Application->recallObject($event->getPrefixSpecial().'_TempHandler', 'kTempTablesHandler');
+ /* @var $temp_handler kTempTablesHandler */
+
+ $temp_handler->DeleteItems($event->Prefix, $event->Special, $article_ids);
}
$sql = 'UPDATE '.$custom_table.'
remove_before_scheduled_tasks_core_fix.patch [^] (393 bytes) 2012-01-11 02:28
[Show Content]
Index: install/upgrades.sql
===================================================================
--- install/upgrades.sql (revision 15033)
+++ install/upgrades.sql (working copy)
@@ -2596,3 +2596,5 @@
RENAME TABLE <%TABLE_PREFIX%>SessionLogs TO <%TABLE_PREFIX%>UserSessionLogs;
DELETE FROM LanguageLabels WHERE PhraseKey = 'LA_FLD_RUNMODE';
+
+ALTER TABLE ScheduledTasks DROP RunMode;
|