Date pager does not respect filter

Created on 10 June 2020, almost 5 years ago
Updated 15 May 2023, almost 2 years ago

Date pager does not respect filter and shows all years even if the years are filtered out before.

πŸ› Bug report
Status

Needs review

Version

1.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany sleitner

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡©πŸ‡ͺGermany Kate Heinlein Berlin

    Kate Heinlein β†’ made their first commit to this issue’s fork.

  • πŸ‡©πŸ‡ͺGermany Kate Heinlein Berlin

    Thanks (again!) @sleitner.
    I merged it, but honestly with reviewing not entirely sure if it will work with all possible queries as sub queries.
    So please come back in case there are any issues.

  • Status changed to Needs work almost 2 years ago
  • πŸ‡©πŸ‡ͺGermany Kate Heinlein Berlin

    Sorry, I had to take back your changes.
    The original view's queries did not join properly.

  • πŸ‡©πŸ‡ͺGermany sleitner

    Did you get an error message? Or any other clue how to reproduce this?

  • πŸ‡©πŸ‡ͺGermany sleitner

    Static patch of MR2

  • πŸ‡ΊπŸ‡ΈUnited States j_s

    I tried the patch and get this error:
    Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'startDate' in field list is ambiguous

  • πŸ‡©πŸ‡ͺGermany sleitner

    @j_s is one of your fields named startDate?

  • πŸ‡ΊπŸ‡ΈUnited States j_s

    I think so

  • Merge request !9Resolve #3150643 "Date pager does" β†’ (Closed) created by sleitner
  • πŸ‡©πŸ‡ͺGermany sleitner

    @j_s I renamed the temporary column, please try MR9

  • πŸ‡ΊπŸ‡ΈUnited States j_s

    I couldn't get MR9 applied. It might be that it needs to be against 2.0.x instead of 8.x-1.x.

  • Merge request !10Resolve #3150643 "Date pager does" β†’ (Open) created by sleitner
  • πŸ‡©πŸ‡ͺGermany sleitner

    @j_s MR10 is now against 2.0.x

  • πŸ‡ΊπŸ‡ΈUnited States j_s

    Using MR10 I now get:
    Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'startDatePager' in field list is ambiguous

  • πŸ‡ΊπŸ‡¦Ukraine vasyok

    #8 does not compatipbe with current 2.1.1-alpha2
    I tried to patch it manually, but I received "The website encountered an unexpected error. "

    There is an error in Drupal's log.
    Message
    Drupal\Core\Database\IntegrityConstraintViolationException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'startDate' in field list is ambiguous: SELECT MIN(startDate) AS "min", MAX(endDate) AS "max" FROM "node__field_start" "node__field_start" INNER JOIN (SELECT "node_field_data"."langcode" AS "node_field_data_langcode", "node__field_start"."field_start_value" AS "node__field_start_field_start_value", "node_field_data"."nid" AS "nid", "node__field_start"."field_start_value" AS "startDate", "node__field_start"."field_start_value" AS "endDate" FROM "node_field_data" "node_field_data" LEFT JOIN "node__field_start" "node__field_start" ON node_field_data.nid = node__field_start.entity_id AND (node__field_start.deleted = :views_join_condition_0 AND node__field_start.langcode = node_field_data.langcode) INNER JOIN "taxonomy_index" "taxonomy_index" ON node_field_data.nid = taxonomy_index.nid WHERE ((taxonomy_index.tid = :taxonomy_index_tid)) AND (("node_field_data"."status" = :db_condition_placeholder_0) AND ("node_field_data"."langcode" IN (:db_condition_placeholder_1)) AND ((DATE_FORMAT((node__field_start.field_start_value + INTERVAL 3600 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2025-02-23T06:47:16' + INTERVAL 3600 SECOND), '%Y-%m-%d\T%H:%i:%s')))) ORDER BY "node__field_start_field_start_value" ASC) "node_field_datanidnode__field_startentity_idANDnode__field_startdeleted0ANDnode__field_startlangcodenode_field_datalangcode" INNER JOIN (SELECT "node_field_data"."langcode" AS "node_field_data_langcode", "node__field_start"."field_start_value" AS "node__field_start_field_start_value", "node_field_data"."nid" AS "nid", "node__field_start"."field_start_value" AS "startDate", "node__field_start"."field_start_value" AS "endDate" FROM "node_field_data" "node_field_data" LEFT JOIN "node__field_start" "node__field_start" ON node_field_data.nid = node__field_start.entity_id AND (node__field_start.deleted = :views_join_condition_0 AND node__field_start.langcode = node_field_data.langcode) INNER JOIN "taxonomy_index" "taxonomy_index" ON node_field_data.nid = taxonomy_index.nid WHERE ((taxonomy_index.tid = :taxonomy_index_tid)) AND (("node_field_data"."status" = :db_condition_placeholder_0) AND ("node_field_data"."langcode" IN (:db_condition_placeholder_1)) AND ((DATE_FORMAT((node__field_start.field_start_value + INTERVAL 3600 SECOND), '%Y-%m-%d\T%H:%i:%s') >= DATE_FORMAT(('2025-02-23T06:47:16' + INTERVAL 3600 SECOND), '%Y-%m-%d\T%H:%i:%s')))) ORDER BY "node__field_start_field_start_value" ASC) "node_field_datanidtaxonomy_indexnid"; Array ( [:taxonomy_index_tid] => 59 [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => en [:views_join_condition_0] => 0 ) in Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException() (line 45 of /var/www/html/web/core/modules/mysql/src/Driver/Database/mysql/ExceptionHandler.php).

    Backtrace

    #0 /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php(883): Drupal\mysql\Driver\Database\mysql\ExceptionHandler->handleExecutionException()
    #1 /var/www/html/web/core/lib/Drupal/Core/Database/Query/Select.php(524): Drupal\Core\Database\Connection->query()
    #2 /var/www/html/web/modules/contrib/date_pager/src/Plugin/views/pager/DatePager.php(429): Drupal\Core\Database\Query\Select->execute()
    #3 /var/www/html/web/modules/contrib/date_pager/src/Plugin/views/pager/DatePager.php(441): Drupal\date_pager\Plugin\views\pager\DatePager->getDateRange()

    DeepSeec resolve this so I attach new patch.

  • πŸ‡©πŸ‡ͺGermany sleitner

    @vasyok the tests are failing https://git.drupalcode.org/project/date_pager/-/jobs/4477490 . Needs test coverage for filter usage.

  • πŸ‡ΊπŸ‡¦Ukraine vasyok

    Maybe test failed, but its works :)

  • πŸ‡©πŸ‡ͺGermany sleitner

    Your code only worked if the date field was already a view filter or field. If you use another format, it fails.
    Please test MR10

  • πŸ‡¨πŸ‡¦Canada phjou Vancouver πŸ‡¨πŸ‡¦ πŸ‡ͺπŸ‡Ί

    Just tried this patch, it doesn't seem to work.

    I have a filter on the Year and all the values are disappearing with the patch, while before the options were there but not working at all.

  • πŸ‡©πŸ‡ͺGermany sleitner
  • πŸ‡©πŸ‡ͺGermany sleitner

    Did you try the latest MR? The attached patches are outdated.

  • πŸ‡¨πŸ‡¦Canada phjou Vancouver πŸ‡¨πŸ‡¦ πŸ‡ͺπŸ‡Ί

    Yes I believe I tried the latest patch. Works fine when no cache is set on the view, but on tag based cache, my view was resetting the pager to only one page using this pager. My view is also set to use ajax.

  • πŸ‡©πŸ‡ͺGermany sleitner

    @phjou , I could reproduce the issue

  • πŸ‡©πŸ‡ͺGermany sleitner

    The date range was set too late, after the filter was applied. Please review the MR

Production build 0.71.5 2024