--- a/webprofiler/config/translations/console.en.yml +++ b/webprofiler/config/translations/console.en.yml @@ -22,7 +22,6 @@ commands: ip: Filter by IP. url: Filter by URL. method: Filter by HTTP method. - limit: Limit printed profiles. rows: time: D, m/d/Y - H:i:s header: diff --git a/webprofiler/config/translations/console.es.yml b/webprofiler/config/translations/console.es.yml index 71f66ef..fde45ec 100644 --- a/webprofiler/config/translations/console.es.yml +++ b/webprofiler/config/translations/console.es.yml @@ -22,7 +22,6 @@ commands: ip: Filtrar por IP. url: Filtrar por URL. method: Filtrar por método HTTP. - limit: Limitar perfiles a mostrar. rows: time: D, d/m/Y - H:i:s header: diff --git a/webprofiler/src/Controller/DashboardController.php b/webprofiler/src/Controller/DashboardController.php index 2b1d93e..7aae973 100644 --- a/webprofiler/src/Controller/DashboardController.php +++ b/webprofiler/src/Controller/DashboardController.php @@ -153,12 +153,13 @@ public function dashboardAction(Profile $profile) { * @return array */ public function listAction(Request $request) { - $limit = $request->get('limit', 10); + // Don't need the profiler in the profiler page. $this->profiler->disable(); $ip = $request->query->get('ip'); - $method = $request->query->get('method'); $url = $request->query->get('url'); + $limit = $request->get('limit', 50); + $method = $request->query->get('method'); $profiles = $this->profiler->find($ip, $url, $limit, $method, '', ''); @@ -222,6 +223,8 @@ public function listAction(Request $request) { '#sticky' => TRUE, ]; + $build['pager'] = array('#type' => 'pager'); + return $build; } diff --git a/webprofiler/src/Form/ProfilesFilterForm.php b/webprofiler/src/Form/ProfilesFilterForm.php index 87e04dc..7ca84a4 100644 --- a/webprofiler/src/Form/ProfilesFilterForm.php +++ b/webprofiler/src/Form/ProfilesFilterForm.php @@ -49,14 +49,6 @@ public function buildForm(array $form, FormStateInterface $form_state) { '#default_value' => $this->getRequest()->query->get('method'), ]; - $limits = [10, 50, 100]; - $form['limit'] = [ - '#type' => 'select', - '#title' => $this->t('Limit'), - '#options' => array_combine($limits, $limits), - '#default_value' => $this->getRequest()->query->get('limit'), - ]; - $form['actions'] = ['#type' => 'actions']; $form['actions']['filter'] = [ '#type' => 'submit', diff --git a/webprofiler/src/Profiler/DatabaseProfilerStorage.php b/webprofiler/src/Profiler/DatabaseProfilerStorage.php index 2eb9a17..b7bd7e6 100644 --- a/webprofiler/src/Profiler/DatabaseProfilerStorage.php +++ b/webprofiler/src/Profiler/DatabaseProfilerStorage.php @@ -37,7 +37,8 @@ function __construct(Connection $database) { * {@inheritdoc} */ public function find($ip, $url, $limit, $method, $start = NULL, $end = NULL) { - $select = $this->database->select('webprofiler', 'wp', ['fetch' => \PDO::FETCH_ASSOC]); + $select = $this->database->select('webprofiler', 'wp', ['fetch' => \PDO::FETCH_ASSOC]) + ->extend('\Drupal\Core\Database\Query\PagerSelectExtender'); if (NULL === $start) { $start = 0; @@ -77,7 +78,9 @@ public function find($ip, $url, $limit, $method, $start = NULL, $end = NULL) { 'status_code' ]); $select->orderBy('time', 'DESC'); - $select->range(0, $limit); + + $select->limit($limit); + return $select->execute() ->fetchAllAssoc('token'); }