Skip to content
Snippets Groups Projects
Verified Commit 1c773fed authored by Dave Long's avatar Dave Long
Browse files

Issue #3476175 by daffie, rajneeshb, smustgrave, dagmar: Change the filter in...

Issue #3476175 by daffie, rajneeshb, smustgrave, dagmar: Change the filter in the overview page of the dblog module to a condition object
parent 22098897
Branches
Tags
12 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!11131[10.4.x-only-DO-NOT-MERGE]: Issue ##2842525 Ajax attached to Views exposed filter form does not trigger callbacks,!10786Issue #3490579 by shalini_jha, mstrelan: Add void return to all views...,!5423Draft: Resolve #3329907 "Test2",!3878Removed unused condition head title for views,!3818Issue #2140179: $entity->original gets stale between updates,!3478Issue #3337882: Deleted menus are not removed from content type config,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!2062Issue #3246454: Add weekly granularity to views date sort,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!617Issue #3043725: Provide a Entity Handler for user cancelation,!579Issue #2230909: Simple decimals fail to pass validation
Pipeline #380204 passed with warnings
Pipeline: drupal

#380229

    Pipeline: drupal

    #380222

      Pipeline: drupal

      #380220

        +4
        ......@@ -28,14 +28,14 @@ function dblog_filters() {
        if (!empty($types)) {
        $filters['type'] = [
        'title' => t('Type'),
        'where' => "w.type = ?",
        'field' => 'w.type',
        'options' => $types,
        ];
        }
        $filters['severity'] = [
        'title' => t('Severity'),
        'where' => 'w.severity = ?',
        'field' => 'w.severity',
        'options' => RfcLogLevel::getLevels(),
        ];
        ......
        ......@@ -10,6 +10,7 @@
        use Drupal\Core\Controller\ControllerBase;
        use Drupal\Core\Database\Connection;
        use Drupal\Core\Database\Query\PagerSelectExtender;
        use Drupal\Core\Database\Query\SelectInterface;
        use Drupal\Core\Database\Query\TableSortExtender;
        use Drupal\Core\Datetime\DateFormatterInterface;
        use Drupal\Core\Extension\ModuleHandlerInterface;
        ......@@ -104,7 +105,6 @@ public static function getLogLevelClassMap() {
        */
        public function overview(Request $request) {
        $filter = $this->buildFilterQuery($request);
        $rows = [];
        $classes = static::getLogLevelClassMap();
        ......@@ -154,9 +154,8 @@ public function overview(Request $request) {
        ]);
        $query->leftJoin('users_field_data', 'ufd', '[w].[uid] = [ufd].[uid]');
        if (!empty($filter['where'])) {
        $query->where($filter['where'], $filter['args']);
        }
        $this->addFilterToQuery($request, $query);
        $result = $query
        ->limit(50)
        ->orderByHeader($header)
        ......@@ -306,14 +305,16 @@ public function eventDetails($event_id) {
        /**
        * Builds a query for database log administration filters based on session.
        *
        * This method retrieves the session-based filters from the request and applies
        * them to the provided query object. If no filters are present, the query is
        * left unchanged.
        *
        * @param \Symfony\Component\HttpFoundation\Request $request
        * The request.
        *
        * @return array|null
        * An associative array with keys 'where' and 'args' or NULL if there were
        * no filters set.
        * @param \Drupal\Core\Database\Query\SelectInterface $query
        * The database query.
        */
        protected function buildFilterQuery(Request $request) {
        protected function addFilterToQuery(Request $request, SelectInterface &$query): void {
        $session_filters = $request->getSession()->get('dblog_overview_filter', []);
        if (empty($session_filters)) {
        return;
        ......@@ -323,24 +324,29 @@ protected function buildFilterQuery(Request $request) {
        $filters = dblog_filters();
        // Build query.
        $where = $args = [];
        // Build the condition.
        $condition_and = $query->getConnection()->condition('AND');
        $condition_and_used = FALSE;
        foreach ($session_filters as $key => $filter) {
        $filter_where = [];
        $condition_or = $query->getConnection()->condition('OR');
        $condition_or_used = FALSE;
        foreach ($filter as $value) {
        $filter_where[] = $filters[$key]['where'];
        $args[] = $value;
        if ($key == 'severity') {
        $value = (int) $value;
        }
        if (in_array($value, array_keys($filters[$key]['options']))) {
        $condition_or->condition($filters[$key]['field'], $value);
        $condition_or_used = TRUE;
        }
        }
        if (!empty($filter_where)) {
        $where[] = '(' . implode(' OR ', $filter_where) . ')';
        if ($condition_or_used) {
        $condition_and->condition($condition_or);
        $condition_and_used = TRUE;
        }
        }
        $where = !empty($where) ? implode(' AND ', $where) : '';
        return [
        'where' => $where,
        'args' => $args,
        ];
        if ($condition_and_used) {
        $query->condition($condition_and);
        }
        }
        /**
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment