/** * Frees consumed memory manually. * * @return void * * @codeCoverageIgnore */ protected function freeMemoryManually() { $profiler = $this->database->getProfiler(); if (is_object($profiler) && $profiler->isActive()) { $profiler->resetProfiles(); } }
/** * Propagates revision last seen. * * @param string $path Path. * @param string $revision Revision. * * @return array */ protected function propagateRevisionLastSeen($path, $revision) { $to_update = array(); $update_path = $path; $select_sql = 'SELECT RevisionLastSeen FROM Paths WHERE PathHash = :path_hash'; $update_sql = 'UPDATE Paths SET RevisionLastSeen = :revision WHERE PathHash = :path_hash'; while (($update_path = dirname($update_path) . '/') !== '//') { $update_path_hash = $this->getPathChecksum($update_path); $fields_hash = $this->databaseCache->getFromCache('Paths', $update_path_hash . '/' . __METHOD__, $select_sql, array('path_hash' => $update_path_hash)); // Missing parent path. Can happen for example, when repository was created via "cvs2svn". if ($fields_hash === false) { $profiler = $this->database->getProfiler(); if ($profiler instanceof StatementProfiler) { $profiler->removeProfile($select_sql, array('path_hash' => $update_path_hash)); } break; } // TODO: Collect these paths and issue single update after cycle finishes. if ((int) $fields_hash['RevisionLastSeen'] < $revision) { $this->database->perform($update_sql, array('revision' => $revision, 'path_hash' => $update_path_hash)); $fields_hash = array('RevisionLastSeen' => $revision); $this->databaseCache->setIntoCache('Paths', $update_path_hash . '/' . __METHOD__, $fields_hash); $to_update[$update_path_hash] = $fields_hash; } } return $to_update; }
/** * Checks, that database table contains given number of records. * * @param string $table_name Table name. * @param integer $expected_record_count Expected record count. * * @return void */ protected function assertTableCount($table_name, $expected_record_count) { $profiler = $this->database->getProfiler(); if (is_object($profiler)) { $profiler->setActive(false); } $sql = 'SELECT COUNT(*) FROM ' . $table_name; $actual_record_count = $this->database->fetchValue($sql); if (is_object($profiler)) { $profiler->setActive(true); } $this->assertEquals($expected_record_count, $actual_record_count, 'The "' . $table_name . '" table contains ' . $expected_record_count . ' records'); }
/** * * Returns the profiler object. * * @return ProfilerInterface * */ public function getProfiler() { return $this->pdo->getProfiler(); }