/var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/debug_kit/src/Model/Table
NameSizeModeActions
LazyTableTrait.php28210644editdlrm
PanelsTable.php25710644editdlrm
RequestsTable.php44020644editdlrm
Edit: /var/www/vhosts/ihelp.ro/httpdocs/vendor/cakephp/debug_kit/src/Model/Table/RequestsTable.php (4402B)
hasMany('DebugKit.Panels', [ 'sort' => ['Panels.title' => 'ASC'], ]); $this->addBehavior('Timestamp', [ 'events' => [ 'Model.beforeSave' => ['requested_at' => 'new'], ], ]); $this->ensureTables(['DebugKit.Requests', 'DebugKit.Panels']); } /** * DebugKit tables are special. * * @return string */ public static function defaultConnectionName(): string { return 'debug_kit'; } /** * Finder method to get recent requests as a simple array * * @param \Cake\ORM\Query $query The query * @param array $options The options * @return \Cake\ORM\Query The query. */ public function findRecent(Query $query, array $options) { return $query->order(['Requests.requested_at' => 'DESC']) ->limit(10); } /** * Check if garbage collection should be run * * @return bool */ protected function shouldGc() { return rand(1, 100) === 100; } /** * Garbage collect old request data. * * Delete request data that is older than latest 20 requests. * You can use the `DebugKit.requestCount` config to change this limit. * This method will only trigger periodically. * * @return void */ public function gc() { if (!$this->shouldGc()) { return; } try { $noPurge = $this->find() ->select(['id']) ->enableHydration(false) ->order(['requested_at' => 'desc']) ->limit(Configure::read('DebugKit.requestCount') ?: 20) ->all() ->extract('id') ->toArray(); if (empty($noPurge)) { return; } $query = $this->Panels->query() ->delete() ->where(['request_id NOT IN' => $noPurge]); $statement = $query->execute(); $statement->closeCursor(); $query = $this->query() ->delete() ->where(['id NOT IN' => $noPurge]); $statement = $query->execute(); $statement->closeCursor(); $conn = $this->getConnection(); if ($conn->getDriver() instanceof Sqlite) { $conn->execute('VACUUM;'); } } catch (PDOException $e) { Log::warning('Unable to garbage collect requests table. This is probably due to concurrent requests.'); Log::warning((string)$e); } } }