Index: branches/5.2.x/core/units/logs/system_logs/system_log_eh.php =================================================================== diff -u -N -r16513 -r16754 --- branches/5.2.x/core/units/logs/system_logs/system_log_eh.php (.../system_log_eh.php) (revision 16513) +++ branches/5.2.x/core/units/logs/system_logs/system_log_eh.php (.../system_log_eh.php) (revision 16754) @@ -1,6 +1,6 @@ DeleteItems($event->Prefix, $event->Special, $ids); } } + + /** + * Removes old code fragments. + * + * @param kEvent $event Event. + * + * @return void + */ + protected function OnRotateCodeFragmentsScheduledTask(kEvent $event) + { + $id_field = $this->Application->getUnitOption($event->Prefix, 'IDField'); + $table_name = $this->Application->getUnitOption($event->Prefix, 'TableName'); + + $sql = 'SELECT LogBacktrace, ' . $id_field . ' + FROM ' . $table_name . ' + WHERE LogTimestamp < ' . strtotime('-1 month') . ' AND LogCodeFragmentsRotated = 0 + LIMIT 0,500'; + $records = $this->Conn->GetColIterator($sql, $id_field); + + foreach ( $records as $system_log_id => $trace ) { + if ( $trace ) { + $trace = unserialize($trace); + + foreach ( $trace as $index => $trace_info ) { + if ( array_key_exists('code_fragment', $trace_info) ) { + unset($trace[$index]['code_fragment']); + } + } + + $trace = serialize($trace); + } + + $this->Conn->doUpdate( + array( + 'LogBacktrace' => $trace, + 'LogCodeFragment' => null, + 'LogCodeFragmentsRotated' => 1, + ), + $table_name, + $id_field . ' = ' . $system_log_id + ); + } + } + }