Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/admin/admin_events_handler.php
Show First 20 Lines • Show All 1259 Lines • ▼ Show 20 Line(s) | |||||
if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) { | if ( $this->Application->isCachingType(CACHING_TYPE_MEMORY) ) { | ||||
$this->Application->setCache('cached_urls_unit_prefixes', array_keys($prefixes), 3600); | $this->Application->setCache('cached_urls_unit_prefixes', array_keys($prefixes), 3600); | ||||
} | } | ||||
else { | else { | ||||
$this->Application->setDBCache('cached_urls_unit_prefixes', serialize(array_keys($prefixes)), 3600); | $this->Application->setDBCache('cached_urls_unit_prefixes', serialize(array_keys($prefixes)), 3600); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* Deletes stuck semaphore records. | |||||
* | |||||
* @param kEvent $event Event. | |||||
* | |||||
* @return void | |||||
*/ | |||||
protected function OnDeleteStuckSemaphoresScheduledTask(kEvent $event) | |||||
{ | |||||
$semaphore_lifetime = $this->Application->ConfigValue('SemaphoreLifetimeInSeconds'); | |||||
$sql = 'SELECT * | |||||
FROM ' . TABLE_PREFIX . 'Semaphores | |||||
WHERE Timestamp < ' . strtotime('-' . $semaphore_lifetime . ' seconds'); | |||||
$stuck_semaphores = $this->Conn->Query($sql, 'SemaphoreId'); | |||||
if ( !$stuck_semaphores ) { | |||||
return; | |||||
} | |||||
/** @var LanguagesItem $language */ | |||||
$language = $this->Application->recallObject('lang.current', null, array('skip_autoload' => true)); | |||||
$date_format = $language->GetDBField('DateFormat') . ' ' . $language->GetDBField('TimeFormat'); | |||||
foreach ( $stuck_semaphores as $semaphore_id => $semaphore_data ) { | |||||
$log = $this->Application->log('Stuck semaphore detected (unit: ' . $semaphore_data['MainPrefix'] . ')'); | |||||
$log->setLogLevel(kLogger::LL_ERROR); | |||||
$log->addTrace(unserialize($semaphore_data['Backtrace'])); | |||||
$log->setUserData(implode(PHP_EOL, array( | |||||
'Main Prefix: ' . $semaphore_data['MainPrefix'], | |||||
'Main IDs: ' . $semaphore_data['MainIDs'], | |||||
'Created On: ' . date($date_format, $semaphore_data['Timestamp']), | |||||
'Deleted On: ' . date($date_format), | |||||
))); | |||||
$log->setLogField('LogHostname', $semaphore_data['Hostname']); | |||||
$log->setLogField('LogRequestSource', 1); // Web. | |||||
$log->setLogField('LogInterface', kLogger::LI_ADMIN); | |||||
$log->setLogField('LogRequestURI', $semaphore_data['RequestURI']); | |||||
$log->setLogField('LogUserId', $semaphore_data['UserId']); | |||||
$log->setLogField('IpAddress', $semaphore_data['IpAddress']); | |||||
$log->setLogField('LogSessionKey', $semaphore_data['SessionKey']); | |||||
$log->write(); | |||||
$sql = 'DELETE FROM ' . TABLE_PREFIX . 'Semaphores | |||||
WHERE SemaphoreId = ' . $semaphore_id; | |||||
$this->Conn->Query($sql); | |||||
} | |||||
} | |||||
} | } | ||||
class UnitConfigDecorator { | class UnitConfigDecorator { | ||||
var $parentPath = Array (); | var $parentPath = Array (); | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 61 Lines • Show Last 20 Lines |