Page Menu
Home
In-Portal Phabricator
Search
Configure Global Search
Log In
Files
F776464
D165.id404.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, Feb 7, 3:05 PM
Size
9 KB
Mime Type
text/x-diff
Expires
Sat, Feb 8, 3:05 PM (11 h, 52 m)
Engine
blob
Format
Raw Data
Handle
558891
Attached To
D165: INP-1510 Allow rotation of "Session Log" and "Changes Log"
D165.id404.diff
View Options
Index: core/install/english.lang
===================================================================
--- core/install/english.lang
+++ core/install/english.lang
@@ -208,6 +208,7 @@
<PHRASE Label="la_config_SessionBrowserSignatureCheck" Module="Core" Type="1">U2Vzc2lvbiBTZWN1cml0eSBDaGVjayBiYXNlZCBvbiBCcm93c2VyIFNpZ25hdHVyZQ==</PHRASE>
<PHRASE Label="la_config_SessionCookieDomains" Module="Core" Type="1">U2Vzc2lvbiBDb29raWUgRG9tYWlucyAoc2luZ2xlIGRvbWFpbiBwZXIgbGluZSk=</PHRASE>
<PHRASE Label="la_config_SessionIPAddressCheck" Module="Core" Type="1">U2Vzc2lvbiBTZWN1cml0eSBDaGVjayBiYXNlZCBvbiBJUA==</PHRASE>
+ <PHRASE Label="la_config_SessionLogRotationInterval" Module="Core" Type="1">S2VlcCAiU2Vzc2lvbiBMb2ciIGZvcg==</PHRASE>
<PHRASE Label="la_config_SiteNameSubTitle" Module="Core" Type="1">V2Vic2l0ZSBTdWJ0aXRsZQ==</PHRASE>
<PHRASE Label="la_config_site_zone" Module="Core" Type="1">VGltZSB6b25lIG9mIHRoZSBzaXRl</PHRASE>
<PHRASE Label="la_config_SoftMaintenanceTemplate" Module="Core" Type="1" Hint="VGhpcyB0ZW1wbGF0ZSB3aWxsIGJlIHNob3duIHRvIHRoZSBGcm9udCBFbmQgdXNlcnMgd2hlbiBTb2Z0IE1haW50ZW5hbmNlIG1vZGUgaXMgYWN0aXZlLg==">VGVtcGxhdGUgZm9yIFNvZnQgTWFpbnRlbmFuY2U=</PHRASE>
@@ -923,6 +924,7 @@
<PHRASE Label="la_opt_Failed" Module="Core" Type="1">RmFpbGVk</PHRASE>
<PHRASE Label="la_opt_February" Module="Core" Type="1">RmVicnVhcnk=</PHRASE>
<PHRASE Label="la_opt_FirstName" Module="Core" Type="1">Rmlyc3QgTmFtZQ==</PHRASE>
+ <PHRASE Label="la_opt_FiveYears" Module="Core" Type="1">NSB5ZWFycw==</PHRASE>
<PHRASE Label="la_opt_Friday" Module="Core" Type="1">RnJpZGF5</PHRASE>
<PHRASE Label="la_opt_Group" Module="Core" Type="1">R3JvdXA=</PHRASE>
<PHRASE Label="la_opt_GuestsOnly" Module="Core" Type="1">R3Vlc3RzIE9ubHk=</PHRASE>
@@ -994,10 +996,12 @@
<PHRASE Label="la_opt_Tab" Module="Core" Type="1">VGFi</PHRASE>
<PHRASE Label="la_opt_Template" Module="Core" Type="1">VGVtcGxhdGU=</PHRASE>
<PHRASE Label="la_opt_ThreeMonths" Module="Core" Type="1">MyBtb250aHM=</PHRASE>
+ <PHRASE Label="la_opt_ThreeYears" Module="Core" Type="1">MyB5ZWFycw==</PHRASE>
<PHRASE Label="la_opt_Thursday" Module="Core" Type="1">VGh1cnNkYXk=</PHRASE>
<PHRASE Label="la_opt_Title" Module="Core" Type="1">VGl0bGU=</PHRASE>
<PHRASE Label="la_opt_Tuesday" Module="Core" Type="1">VHVlc2RheQ==</PHRASE>
<PHRASE Label="la_opt_TwoWeeks" Module="Core" Type="1">MiB3ZWVrcw==</PHRASE>
+ <PHRASE Label="la_opt_TwoYears" Module="Core" Type="1">MiB5ZWFycw==</PHRASE>
<PHRASE Label="la_opt_User" Module="Core" Type="1">VXNlcg==</PHRASE>
<PHRASE Label="la_opt_UserEmailActivation" Module="Core" Type="1">RW1haWwgQWN0aXZhdGlvbg==</PHRASE>
<PHRASE Label="la_opt_UserInstantRegistration" Module="Core" Type="1">SW1tZWRpYXRlIA==</PHRASE>
Index: core/install/install_data.sql
===================================================================
--- core/install/install_data.sql
+++ core/install/install_data.sql
@@ -106,6 +106,7 @@
INSERT INTO SystemSettings VALUES(DEFAULT, 'EmailLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_EmailLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_EmailLogKeepForever', 65.02, 0, 0, 'hint:la_config_EmailLogRotationInterval');
INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogRotationInterval', '2419200', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogRotationInterval', 'select', NULL, '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2419200=la_opt_OneMonth||7257600=la_opt_ThreeMonths||29030400=la_opt_OneYear||-1=la_opt_SystemLogKeepForever', 65.03, 0, 1, 'hint:la_config_SystemLogRotationInterval');
INSERT INTO SystemSettings VALUES(DEFAULT, 'SystemLogNotificationEmail', '', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SystemLogNotificationEmail', 'text', 'a:5:{s:4:"type";s:6:"string";s:9:"formatter";s:10:"kFormatter";s:6:"regexp";s:85:"/^([-a-zA-Z0-9!\\#$%&*+\\/=?^_`{|}~.]+@[a-zA-Z0-9]{1}[-.a-zA-Z0-9_]*\\.[a-zA-Z]{2,6})$/i";s:10:"error_msgs";a:1:{s:14:"invalid_format";s:18:"!la_invalid_email!";}s:7:"default";s:0:"";}', NULL, 65.04, 0, 1, 'hint:la_config_SystemLogNotificationEmail');
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SessionLogRotationInterval', '2629800', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SessionLogRotationInterval', 'select', '', '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2629800=la_opt_OneMonth||7889400=la_opt_ThreeMonths||31557600=la_opt_OneYear||63115200=la_opt_TwoYears||94672800=la_opt_ThreeYears||157788000=la_opt_FiveYears||-1=la_opt_EmailLogKeepForever', 65.05, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportDelimiter', '1', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportDelimiter', 'select', NULL, '0=la_opt_Tab||1=la_opt_Comma||2=la_opt_Semicolon||3=la_opt_Space||4=la_opt_Colon', 70.01, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportEnclosure', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportEnclosure', 'radio', NULL, '0=la_Doublequotes||1=la_Quotes', 70.02, 0, 1, NULL);
INSERT INTO SystemSettings VALUES(DEFAULT, 'CSVExportSeparator', '0', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsCSVExport', 'la_config_CSVExportSeparator', 'radio', NULL, '0=la_Linux||1=la_Windows', 70.03, 0, 1, NULL);
Index: core/install/upgrades.sql
===================================================================
--- core/install/upgrades.sql
+++ core/install/upgrades.sql
@@ -3026,3 +3026,6 @@
UPDATE Modules
SET ClassNamespace = 'InPortal\\Core'
WHERE `Name` IN ('Core', 'In-Portal');
+
+INSERT INTO SystemSettings VALUES(DEFAULT, 'SessionLogRotationInterval', '2629800', 'In-Portal', 'in-portal:configure_advanced', 'la_section_SettingsLogs', 'la_config_SessionLogRotationInterval', 'select', '', '86400=la_opt_OneDay||604800=la_opt_OneWeek||1209600=la_opt_TwoWeeks||2629800=la_opt_OneMonth||7889400=la_opt_ThreeMonths||31557600=la_opt_OneYear||63115200=la_opt_TwoYears||94672800=la_opt_ThreeYears||157788000=la_opt_FiveYears||-1=la_opt_EmailLogKeepForever', 65.05, 0, 1, NULL);
+
Index: core/units/logs/session_logs/session_log_eh.php
===================================================================
--- core/units/logs/session_logs/session_log_eh.php
+++ core/units/logs/session_logs/session_log_eh.php
@@ -129,4 +129,74 @@
}
}
- }
\ 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;
+ }
+
+ $limit = 1;
+ $may_have_session_log = 1;
+ $config = $event->getUnitConfig();
+ $change_log_config = $this->Application->getUnitConfig('change-log');
+ $select_sql = ' SELECT ' . $config->getIDField() . '
+ FROM ' . $config->getTableName() . '
+ WHERE ' . TIMENOW . ' - SessionEnd > ' . $rotation_interval . '
+ LIMIT 0,' . $limit;
+
+ /** @var kTempTablesHandler $temp_handler */
+ $temp_handler = $this->Application->recallObject(
+ $event->getPrefixSpecial() . '_TempHandler',
+ 'kTempTablesHandler',
+ array('parent_event' => $event)
+ );
+
+ /** @var kTempTablesHandler $change_log_temp_handler */
+ $change_log_temp_handler = $this->Application->recallObject(
+ 'change-log_TempHandler',
+ 'kTempTablesHandler',
+ array('parent_event' => $event)
+ );
+
+ while ( $may_have_session_log ) {
+ $ids = $this->Conn->GetCol($select_sql);
+
+ if ( $ids ) {
+ $may_have_change_log = 1;
+ $change_log_select_sql = ' SELECT ' . $change_log_config->getIDField() . '
+ FROM ' . $change_log_config->getTableName() . '
+ WHERE SessionLogId IN (' . implode(',', $ids) . ')
+ LIMIT 0,' . $limit;
+
+ while ( $may_have_change_log ) {
+ $change_log_ids = $this->Conn->GetCol($change_log_select_sql);
+
+ if ( $change_log_ids ) {
+ $change_log_temp_handler->DeleteItems('change-log', '', $change_log_ids);
+ }
+
+ if ( count($change_log_ids) < $limit ) {
+ $may_have_change_log = 0;
+ }
+ }
+
+ $temp_handler->DeleteItems($event->Prefix, $event->Special, $ids);
+ }
+
+ if ( count($ids) < $limit ) {
+ $may_have_session_log = 0;
+ }
+ }
+ }
+
+ }
Index: core/units/logs/session_logs/session_logs_config.php
===================================================================
--- core/units/logs/session_logs/session_logs_config.php
+++ core/units/logs/session_logs/session_logs_config.php
@@ -55,6 +55,10 @@
5 => 'mode',
),
+ 'ScheduledTasks' => array(
+ 'rotate_session_logs' => array('EventName' => 'OnRotate', 'RunSchedule' => '0 0 * * *'),
+ ),
+
'IDField' => 'SessionLogId',
'StatusField' => Array ('Status'),
@@ -150,4 +154,4 @@
),
),
),
-);
\ No newline at end of file
+);
Index: core/units/logs/system_logs/system_logs_config.php
===================================================================
--- core/units/logs/system_logs/system_logs_config.php
+++ core/units/logs/system_logs/system_logs_config.php
@@ -202,4 +202,4 @@
),
),
),
-);
\ No newline at end of file
+);
Event Timeline
Log In to Comment