Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/units/logs/session_logs/session_log_eh.php
Show First 20 Lines • Show All 123 Lines • ▼ Show 20 Line(s) | |||||
if ( $related_ids ) { | if ( $related_ids ) { | ||||
$temp_handler = $this->Application->recallObject('change-log_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event->MasterEvent)); | $temp_handler = $this->Application->recallObject('change-log_TempHandler', 'kTempTablesHandler', Array ('parent_event' => $event->MasterEvent)); | ||||
/* @var $temp_handler kTempTablesHandler */ | /* @var $temp_handler kTempTablesHandler */ | ||||
$temp_handler->DeleteItems('change-log', '', $related_ids); | $temp_handler->DeleteItems('change-log', '', $related_ids); | ||||
} | } | ||||
} | } | ||||
} | /** | ||||
No newline at end of file | * [SCHEDULED TASK] Will remove old session logs | ||||
* | |||||
* @param kEvent $event Event. | |||||
* | |||||
* @return void | |||||
*/ | |||||
protected function OnRotate(kEvent $event) | |||||
{ | |||||
$rotation_interval = (int)$this->Application->ConfigValue('SessionLogRotationInterval'); | |||||
if ( $rotation_interval === -1 ) { | |||||
// Forever. | |||||
return; | |||||
} | |||||
$session_log_temp_handler = $this->getTempTablesHandler($event->getPrefixSpecial(), $event); | |||||
$change_log_temp_handler = $this->getTempTablesHandler('change-log', $event); | |||||
$limit = 100; | |||||
$session_log_config = $event->getUnitConfig(); | |||||
$session_log_select_sql = ' SELECT ' . $session_log_config->getIDField() . ' | |||||
FROM ' . $session_log_config->getTableName() . ' | |||||
WHERE ' . TIMENOW . ' - SessionEnd > ' . $rotation_interval . ' | |||||
LIMIT 0,' . $limit; | |||||
$change_log_config = $this->Application->getUnitConfig('change-log'); | |||||
do { | |||||
$session_log_ids = $this->Conn->GetCol($session_log_select_sql); | |||||
if ( !$session_log_ids ) { | |||||
break; | |||||
} | |||||
$change_log_select_sql = ' SELECT ' . $change_log_config->getIDField() . ' | |||||
FROM ' . $change_log_config->getTableName() . ' | |||||
WHERE SessionLogId IN (' . implode(',', $session_log_ids) . ') | |||||
LIMIT 0,' . $limit; | |||||
do { | |||||
$change_log_ids = $this->Conn->GetCol($change_log_select_sql); | |||||
if ( $change_log_ids ) { | |||||
$change_log_temp_handler->DeleteItems('change-log', '', $change_log_ids); | |||||
} | |||||
} while ( count($change_log_ids) == $limit ); | |||||
$session_log_temp_handler->DeleteItems($event->Prefix, $event->Special, $session_log_ids); | |||||
} while ( count($session_log_ids) == $limit ); | |||||
} | |||||
/** | |||||
* Get temp tables handler instance. | |||||
* | |||||
* @param string $prefix_special Prefix, special. | |||||
* @param kEvent $event Event. | |||||
* | |||||
* @return kTempTablesHandler | |||||
*/ | |||||
public function getTempTablesHandler($prefix_special, kEvent $event) | |||||
{ | |||||
return $this->Application->recallObject( | |||||
$prefix_special . '_TempHandler', | |||||
'kTempTablesHandler', | |||||
array('parent_event' => $event) | |||||
); | |||||
} | |||||
} |