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

Issue fork date_pager-3150643

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

sleitner created an issue. See original summary.

sleitner’s picture

Status: Active » Needs review

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

kate heinlein’s picture

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.

kate heinlein’s picture

Status: Needs review » Needs work

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

sleitner’s picture

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

sleitner’s picture

StatusFileSize
new1.84 KB

Static patch of MR2

j_s’s picture

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

sleitner’s picture

@j_s is one of your fields named startDate?

j_s’s picture

I think so

sleitner’s picture

Status: Needs work » Needs review

@j_s I renamed the temporary column, please try MR9

j_s’s picture

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

sleitner’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

@j_s MR10 is now against 2.0.x

j_s’s picture

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

sleitner’s picture

Version: 2.0.x-dev » 2.1.x-dev
Status: Needs review » Needs work
vasyok’s picture

StatusFileSize
new1.25 KB

#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.

sleitner’s picture

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

sleitner’s picture

Status: Needs work » Needs review
vasyok’s picture

Maybe test failed, but its works :)

sleitner’s picture

Your code only worked if the date field was already a view filter or field. It fails, if another format is used.

Please test MR10

phjou’s picture

Just tried this patch, it seem to work fine as long as the view has no cache enabled.

sleitner’s picture

sleitner’s picture

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

phjou’s picture

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.

sleitner’s picture

Status: Needs review » Needs work

@phjou , I could reproduce the issue

sleitner’s picture

Status: Needs work » Needs review

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

  • sleitner committed d2b68476 on 2.1.x
    Issue #3150643 by sleitner, kate heinlein, vasyok, j_s, phjou: Date...
sleitner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.