Problem/Motivation

Some argument handlers provide their own default argument handling, like the Date argument. The Date argument handler does so by extending the list of of options in the defaultArgumentForm. An exception is however thrown on saving the form.

Steps to reproduce

  • Create a new view /admin/structure/views/add using (node) content
  • Under advanced tab, add new Contextual filter, select Created date (node.created)
  • On "When the filter value is not available", select "Provide default value", on the drop-down select "Current date".
  • Try to submit this form.

Result: A fatal error occurred on dblog: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "date" plugin does not exist.

Proposed resolution

Get the date handlers in line with the other default argument handlers.
Add a 'Current date', a "Current node's creation time" and "Current node's update time" default argument handler.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Problem

Steps to reproduce:

Proposed resolution

CommentFileSizeAuthor
#213 2325899-212.patch30.03 KBpercoction
#210 2325899-210.patch30.02 KBidflood
#208 2325899-10.2.5-184.patch28.23 KBfoodslover
#205 2325899-10.2.5-183.patch11.43 KBfoodslover
#204 2325899-nr-bot.txt90 bytesneeds-review-queue-bot
#198 2325899-3751-3b362cc8.patch61.65 KBtormi
#189 2325899-169_reroll-9.5-189.patch31.94 KBanairamzap
#186 2325899-169_reroll-95.patch27.87 KBanairamzap
#184 interdiff_183-184.txt601 bytesludo.r
#184 2325899-9.5-184.patch27.88 KBludo.r
#183 2325899-9.5-183.patch27.85 KBskylord
#170 Screenshot 2021-07-13 at 16.37.38.png143.39 KBragnarkurm
#169 2325899-169-9.3-169.patch27.85 KBsokru
#164 interdiff_163-164.txt1.68 KBpdenooijer
#164 2325899-9.1.x-164.patch27.85 KBpdenooijer
#163 interdiff_161_163.txt1.01 KBanmolgoyal74
#163 2325899-9.1.x-163.patch27.78 KBanmolgoyal74
#161 2325899-9.1.x-161.patch27.55 KBpdenooijer
#152 interdiff-150-152.txt1.22 KBjungle
#152 2325899-9.x-152.patch33.4 KBjungle
#150 2325899-150-D9.patch33.35 KBsokru
#150 2325899-150-D8.patch33.37 KBsokru
#145 interdiff-142-145.txt553 bytesjungle
#145 2325899-145.patch33.45 KBjungle
#142 interdiff-141-142.txt4.99 KBjungle
#142 2325899-142.patch33.38 KBjungle
#141 2325899-141.patch30.06 KBjungle
#138 interdiff.txt235 bytesrensingh99
#138 2325899-138.patch30.06 KBrensingh99
#132 interdiff.txt2.1 KBrensingh99
#132 2325899-132.patch30.08 KBrensingh99
#125 2325899-124.patch29.88 KBlendude
#124 interdiff-2325899-123-124.txt4.37 KBlendude
#124 interdiff-2325899-123-124.txt4.37 KBlendude
#123 2325899-123.patch29.93 KBlendude
#111 interdiff-106-111.txt2.61 KBAnonymous (not verified)
#111 2325899-111.patch31.02 KBAnonymous (not verified)
#106 interdiff-104-106.txt7.41 KBAnonymous (not verified)
#106 2325899-106.patch28.58 KBAnonymous (not verified)
#104 interdiff-98-104.txt2.53 KBAnonymous (not verified)
#104 2325899-104.patch26.22 KBAnonymous (not verified)
#100 interdiff.txt2.71 KBpurushotam.rai
#100 ui_fatal_caused_by-2325899-100.patch9.72 KBpurushotam.rai
#99 2325899-99.patch7.04 KBmian3010
#98 interdiff.txt2.75 KBAnonymous (not verified)
#98 2325899-98.patch25.59 KBAnonymous (not verified)
#94 ui_fatal_caused_by-2325899-94.patch24.27 KBmian3010
#91 2325899-88-8.3.x.patch.txt25.54 KBpwolanin
#88 2325899-88.patch25.44 KBdagmar
#86 2325899-86.patch25.5 KBlendude
#86 interdiff-2325899-83-86.txt7.53 KBlendude
#83 interdiff-79-83.txt1.02 KBjofitz
#83 2325899-83.patch24.57 KBjofitz
#79 interdiff-77-79.txt451 bytesjofitz
#79 2325899-79.patch24.49 KBjofitz
#77 2325899-77.patch24.49 KBjofitz
#67 interdiff-56-67.txt477 bytesmpdonadio
#67 2325899-67.patch24.44 KBmpdonadio
#60 2325899-default_arguments_d82x_04953c5a_after_patch56_applied_with_reinstall.jpg22.9 KBhowards
#59 2325899-default_arguments_d82x_04953c5a_after_patch56_applied_without_reinstall.jpg19.49 KBhowards
#59 2325899-default_arguments_d82x_04953c5a.jpg23.89 KBhowards
#56 views_argument_handlers-2325899-56.patch23.98 KBhowards
#54 views_argument_handlers-2325899-54.patch23.66 KBhowards
#52 views_argument_handlers-2325899-52.patch23.99 KBowenbush
#47 views_argument_handlers-2325899-47.patch23.98 KBtwistor
#43 views_argument_handlers-2325899-43.patch24.15 KBlendude
#43 interdiff-2325899-41-43.patch1.97 KBlendude
#41 views_argument_handlers-2325899-41.patch25.23 KBlendude
#41 interdiff-2325899-39-41.txt7.48 KBlendude
#39 interdiff-30-39.txt17.03 KBmpdonadio
#39 interdiff-36-39.txt8.86 KBmpdonadio
#39 views_argument_handlers-2325899-39.patch18.32 KBmpdonadio
#36 interdiff-30-36.txt14.08 KBmpdonadio
#36 views_argument_handlers-2325899-36.patch13.96 KBmpdonadio
#30 drupal-core-views-argument-handlers-2325899-30.interdiff.txt1.1 KBhauruck
#30 drupal-core-views-argument-handlers-2325899-30.patch11.34 KBhauruck
#27 views.view_.test_node_date_argument_default.yml6.1 KBgeertvd
#24 2325899-24.patch11.19 KBlendude
#23 2325899-23.patch12.32 KBlendude
#21 2325899-21.patch7.54 KBwebflo
#15 2325899-15.patch7.54 KBlendude
#11 interdiff-2325899-8-11.txt728 byteslendude
#11 2325899-11.patch7.53 KBlendude
#8 interdiff-2325899-5-8.txt1.54 KBlendude
#8 2325899-8.patch7.63 KBlendude
#5 2325899-5.patch7.4 KBlendude
#5 2325899-5-SHOULDFAIL.patch3.51 KBlendude
#2 1740492-view_getplugin-1.patch1.59 KBcasey
#1 views--getplugin-1740492-1.patch1.59 KBcasey

Issue fork drupal-2325899

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

casey’s picture

StatusFileSize
new1.59 KB
casey’s picture

StatusFileSize
new1.59 KB
dawehner’s picture

Status: Active » Needs review
Issue tags: +VDC, +Needs tests

Oh right!

I guess we need a test to ensure that at least the date argument handler works as expected. An thrown exception isn't that nice.

dawehner’s picture

Status: Needs review » Needs work

.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new3.51 KB
new7.4 KB

Took a look at the fix and the code and I'd like to propose to take this in another direction.

Instead of just skipping past miss configuration, why not just provide the date default_argument_handler?

I can see a case for only providing the 'current date' default argument handler for date fields, but no such restraints are in place for the other default argument handlers, so why make an exception for date? (it's not like providing the current user id to a date field makes sense, but it's possible at the moment).

So I would propose to just get date in line with the other default argument handlers. With some changes to the current setup:
- lose support for "Current node's creation time"
- lose support for "Current node's update time"
no idea why those should have support in core, and if we do want them in core, let's give them proper default argument handlers and tests and such (but i'd say just toss them out)

This probably needs more work but let me know if this would be a good direction to take this.

The last submitted patch, 5: 2325899-5-SHOULDFAIL.patch, failed testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

@Lendude
It is great to see your engagement in views!

Right, you understood why we had this odd code. In an additional issue we could think about a type for argument plugins similar as we have
for display plugins, to limit it.

PS: We have a test.

+++ b/core/modules/views/src/Plugin/views/argument/Date.php
@@ -88,38 +86,11 @@ public static function create(ContainerInterface $container, array $configuratio
+   * Set the deafult date argument to the given argFormat.

Let's fix the 'deafult' typo here :)

lendude’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Needs tests
StatusFileSize
new7.63 KB
new1.54 KB

@dawehner, learning a ton by diving into views, great fun! Thanks for all the reviewing and great feedback.

fixed typo, added a description to the 'date format' field with a link to php.net

benjy’s picture

Status: Needs review » Reviewed & tested by the community

This patch only had cosmetic changes since @dawehner RTBC'd in #7.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 8: 2325899-8.patch, failed testing.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new7.53 KB
new728 bytes

Langcode settings needed to go. Rerolled.

jhedstrom’s picture

Issue summary: View changes
Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Patch still applies, and as #9 notes, this only has cosmetic changes and rerolls since RTBC in #7.

I added a beta phase evaluation to the issue summary.

I also bumped this to major since a fatal error through the UI seems major.

jhedstrom queued 11: 2325899-11.patch for re-testing.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 11: 2325899-11.patch, failed testing.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new7.54 KB

Rerolled, needed to account for #2429447: Use data table as views base table, if available., so base table of the test view changed to node_field_data.

Thanks for adding the beta evaluation.

jhedstrom’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC assuming bot goes green.

lendude’s picture

Issue summary: View changes

Updated issue summary to reflect the new proposed solution.

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

So we're removing functionality here that people might be using - are we sure that we want to do that?

lendude’s picture

Adding default argument handlers for "Current node's creation time" and "Current node's update time" to core doesn't make a lot of sense to me, these are not things you want to be showing for every view (even those not showing nodes at all), and are they really 'core' functionality? (not in my mind, these sounds like fringe cases, and if nodes get dedicated handlers, why not users and other entities?).

So to justify keeping the functionality, I'd say we'd need what @dawehner suggested in #7, some way to limit the default argument handlers shown. But until that exists, I'd feel that getting the 'Current date' working is more important then supporting "Current node's creation time" and "Current node's update time" in core.

So, what to do?
- Toss "Current node's creation time" and "Current node's update time" from core and move them to some contrib module
- Support "Current node's creation time" and "Current node's update time" in core as default argument handlers (probably in the node module?).
- Develop some way to limit the default argument handlers shown and keep supporting "Current node's creation time" and "Current node's update time" in core
- Develop some way to limit the default argument handlers shown and toss supporting "Current node's creation time" and "Current node's update time" from core anyway

I'd be for option 4, but curious what others think.

slashrsm’s picture

Status: Needs review » Needs work

I found this bug when working on a project. #15 fixed problem for me as I was using "date" default argument.

However, I understand concerns @alexpott had in #18 and agree that we should keep existing features in. Based on that I'd suggest keep "Current node's update time" and "Current node's creation time" and add limit functionality in a follow-up. That would be option 3 in #19 I believe.

webflo’s picture

StatusFileSize
new7.54 KB

Straight reroll

lendude’s picture

Status: Needs work » Needs review

Kickin' the testbot into gear. This still needs work, but lets see if it passes.

lendude’s picture

StatusFileSize
new12.32 KB

This patch adds the handlers for "Current node's update time" and "Current node's creation time". Tested manually but need some real tests, but don't feel like doing that right now.

lets see what this does.

lendude’s picture

Issue tags: +Needs tests
StatusFileSize
new11.19 KB

Clean up of #23, "Current node's update time" and "Current node's creation time" handlers are blatant copies of the "current node id" handler. Was looking at using the tests for node->id handler as a base for the two date handlers but alas:

  /**
   * @todo Test node default argument.
   */
  //function testArgumentDefaultNode() {}

So that is gonna take a little more effort then copy/paste.

geertvd’s picture

We have some test coverage for this in #2567773: Can't select "current date" as default option in a date contextual filter, I'm going to move that here.

geertvd’s picture

Ah seems like test coverage for the "date" argument default handler is already ok in this patch.
I'll add some more for "node_changed" and "node_created" and create a follow up for the todo mentioned in #24

geertvd’s picture

Status: Needs review » Needs work
StatusFileSize
new6.1 KB

How are the argument defaults that fetch something from a current node (like node_created, node_changed and node) actually supposed to work?
What's the current node? When I add the node id in the path it's being seen as the argument value, so my argument_default never gets called.

Even worse, when I use the node_created argument, I'm getting an error saying
Exception: The timestamp must be numeric. in Drupal\Component\Datetime\DateTimePlus::createFromTimestamp() (line 165 of /var/www/html/core/lib/Drupal/Component/Datetime/DateTimePlus.php).
That's should probably be a different issue though.

I added the view I'm testing with in case my explanation doesn't make much sense. Maybe I'm just seeing this all wrong.

lendude’s picture

My manual test case was adding a block display, and showing that block next to a node and showing all nodes that were created on the same date as the node you are watching.

The whole node_created and node_changed feel like such fringe use cases, that's why I argued in #5 to just toss them from core. But @alexpott in #18 seemed to mean that we shouldn't be removing functionality from core anymore (and I see his point).

geertvd’s picture

Yea I figured a block display was the only use case. That makes it pretty annoying to test. Will take a stab at that later today.

hauruck’s picture

StatusFileSize
new11.34 KB
new1.1 KB

Re-roll: After updating to RC1 with this patch and running DB update we got the following error from system.install system_update_8004:

Failed: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "date" plugin does not exist. in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 57 of /var/www/zeitraumexit/src/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Solution: Since the class CacheablePluginInterface no longer exists it has been replaced with CacheableDependencyInterface.

lendude’s picture

Status: Needs work » Needs review

thanks for the reroll! Let's kick the testbot into gear.

Status: Needs review » Needs work

The last submitted patch, 30: drupal-core-views-argument-handlers-2325899-30.patch, failed testing.

clemens.tolboom’s picture

I get this on a 'Created week' with 'provide default value' as 'Current date'. Guess that's the same.

What about Comment, Term and User with 'Current date' as I get the same error there on http://drupal.d8/admin/structure/views/ajax/handler/comment/default/argu...

mpdonadio’s picture

  1. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -0,0 +1,35 @@
    +  public function getArgument() {
    +    if (($node = $this->routeMatch->getParameter('node')) && $node instanceof NodeInterface) {
    +      return date($this->options['date_format'], $node->getChangedTime());
    +    }
    +    return FALSE;
    +  }
    +
    

    This should probably use the date.formatter service instead of the native date function? Also elsewhere in the patch.

  2. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
    @@ -0,0 +1,83 @@
    +use Drupal\views\Plugin\CacheablePluginInterface;
    +use Drupal\views\Plugin\views\argument_default\Date;
    +use Drupal\node\NodeInterface;
    +use Symfony\Component\DependencyInjection\ContainerInterface;
    +use Drupal\Core\Routing\RouteMatchInterface;
    +
    

    Bad ordering. Should be alphabetical.

  3. +++ b/core/modules/views/src/Plugin/views/argument_default/Date.php
    @@ -0,0 +1,74 @@
    +  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    +    parent::buildOptionsForm($form, $form_state);
    +    $form['date_format'] = array(
    +      '#type' => 'textfield',
    +      '#title' => $this->t('Date format'),
    +      '#default_value' => $this->options['date_format'],
    +      '#description' => $this->t('Provide the date format you would like to use, see <a href="http://php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats.'),
    +    );
    +  }
    +
    

    This doesn't make a lot of sense. The argument plugins that use this will define the format that they need, which you can get with the getFormula() method.

  4. +++ b/core/modules/views/src/Plugin/views/argument_default/Date.php
    @@ -0,0 +1,74 @@
    +  public function isCacheable() {
    +    return TRUE;
    +  }
    

    Relying on the request date means this isn't properly cacheable.

  5. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -0,0 +1,35 @@
    +class NodeChanged extends NodeCreated implements CacheablePluginInterface {
    +
    

    This is weird inheritance, and I think you could say it violates SOLID.

  6. +++ b/core/modules/views/src/Plugin/views/argument/Date.php
    @@ -86,38 +84,11 @@ public static function create(ContainerInterface $container, array $configuratio
    -    $form['default_argument_type']['#options'] += array('date' => $this->t('Current date'));
    -    $form['default_argument_type']['#options'] += array('node_created' => $this->t("Current node's creation time"));
    -    $form['default_argument_type']['#options'] += array('node_changed' => $this->t("Current node's update time"));
    -  }
    

    Technically, this would introduce a BC break if these handlers existed, and would require a upgrade path. I also think this would be a regression from Drupal 7.

This somewhat of a partial review as I don't think the approach is quite right.

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

I hope #34 didn't come off as being negative. The patch is good, but at this point the changes to argument/Date.php are a bit radical.

I'm going to work on my objections :)

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Status: Needs work » Needs review
StatusFileSize
new13.96 KB
new14.08 KB

Still needs test coverage for the node create and changed plugins. This is going to fail. Not sure how/why the NullArgument handler is being used here? Manual testing seems fine.

Status: Needs review » Needs work

The last submitted patch, 36: views_argument_handlers-2325899-36.patch, failed testing.

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

See what is gong on now. Working on this.

mpdonadio’s picture

Assigned: mpdonadio » Unassigned
Status: Needs work » Needs review
StatusFileSize
new18.32 KB
new8.86 KB
new17.03 KB

I think this will come up green, but it still needs some test coverage.

- the current date through the date argument plugins works when I do manual testing, but this should have proper test coverage
- the node creation/updated defaults need tests through both paths

I also looked at the exported config a lot, and I think that removing the defaultArgumentForm() is OK and not a BC break nor a regression from Drupal 7. So, we have kinda looped back back to #30, but w/o the settings form + some stuff that I identified. I attached that interdiff for reference.

Feedback appreciated.

lendude’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update

No time right now for a proper code review, but on first glance it looks a lot better then it was. I agree that removing the defaultArgumentForm is not a regression from D7, this is how it works in D7 too as far as I can tell. So this looks like the right path to take for minimal/no migration impact.

I feel an update of the issue summary is needed to make clear that we are not really removing functionality (the ability to provide own default handlers), just getting date default argument handlers in line with the plugin system. But can't think of the proper wording right now....

Back to 'needs work' for the tests.

lendude’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests, -Needs issue summary update
StatusFileSize
new7.48 KB
new25.23 KB

tests for the 'current node X time' default argument handlers.

mpdonadio’s picture

Status: Needs review » Needs work

The new tests look good. I'm a little confused by my own comment, though, from a few months ago:

the current date through the date argument plugins works when I do manual testing, but this should have proper test coverage

Do you think the testing is ArgumentDefaultTest::testArgumentDefaultDate() is adequate? Also

  1. +++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
    @@ -43,7 +43,7 @@ protected function setUp() {
    -  public function testArgumentDefaultPlugin() {
    
    @@ -80,7 +80,7 @@ public function testArgumentDefaultPlugin() {
    -  function testArgumentDefaultNoOptions() {
    +  function ptestArgumentDefaultNoOptions() {
    
  2. +++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
    @@ -104,7 +104,7 @@ function testArgumentDefaultNoOptions() {
    -  function testArgumentDefaultFixed() {
    +  function ptestArgumentDefaultFixed() {
    
  3. +++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
    @@ -43,7 +43,7 @@ protected function setUp() {
    -  public function testArgumentDefaultPlugin() {
    +  public function ptestArgumentDefaultPlugin() {
    
  4. +++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
    @@ -80,7 +80,7 @@ public function testArgumentDefaultPlugin() {
    -  function testArgumentDefaultNoOptions() {
    +  function ptestArgumentDefaultNoOptions() {
    
  5. +++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
    @@ -104,7 +104,7 @@ function testArgumentDefaultNoOptions() {
    -  function testArgumentDefaultFixed() {
    +  function ptestArgumentDefaultFixed() {
         $random = $this->randomMachineName();
    

These tests need to be added back in, and these changes aren't in the interdiff?

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new1.97 KB
new24.15 KB

@mpdonadio thanks for looking at it!

#42.1-5 sorry, found that I left those in, changed it, rerolled the interdiff and then promptly uploaded the old version of the patch....

The test coverage in ArgumentDefaultTest::testArgumentDefaultDate() matches that of the other default arguments handlers, so I think it should be fine. But since ArgumentDefaultTest is a webtest already anyway extending the tests to do a drupalGet en see if the actual filtering works should be fairly trivial should we feel the need.

The last submitted patch, 43: interdiff-2325899-41-43.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 43: views_argument_handlers-2325899-43.patch, failed testing.

lendude’s picture

Status: Needs work » Needs review

duh, .patch interdiff

twistor’s picture

StatusFileSize
new23.98 KB

Re-roll.

dawehner’s picture

+++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
@@ -0,0 +1,113 @@
+ */
+class NodeChanged extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {

IMHO we should implement this not just for nodes but for every entity with EntityChangedInterface

dawehner’s picture

Status: Needs review » Needs work
lendude’s picture

@dawehner you are pointing to the 'Current node changed time' default argument handler, so do you mean make a default argument handler for 'Current comment changed time' and 'Current user changed time'? I don't really see a use case for the node version (we just added those from a BC standpoint), let alone for the other entities. That would just clutter up the default argument selector more.

Or do you mean something else?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

owenbush’s picture

StatusFileSize
new23.99 KB

Re-rolled the patch from #47 for Drupal 8.1.x

mpdonadio’s picture

Status: Needs work » Needs review

Go testbot, go.

howards’s picture

Version: 8.1.x-dev » 8.2.x-dev
StatusFileSize
new23.66 KB

manual reroll to 8.2.x

Status: Needs review » Needs work

The last submitted patch, 54: views_argument_handlers-2325899-54.patch, failed testing.

howards’s picture

Version: 8.2.x-dev » 8.1.x-dev
StatusFileSize
new23.98 KB

Oops!

EDIT: The patches in #54 and here were a manual reroll of the patch in #52 as it would no longer apply to 8.1.x, including back when it was tested. (Applied against various commits around June 21, 2016 and failed in two different hunks.)

Patched against 8.1.x-dev (commit a734cfae, "back to -dev" after release of Drupal 8.1.9)
Patched against 8.2.x-dev (commit 0e65dfa4)

EDIT #2: Nevermind, #52 patched with fuzz; I guess I grabbed the wrong one in testing... Ugh...

howards’s picture

Status: Needs work » Needs review
mpdonadio’s picture

Assuming the additional tests I queued come up green, I think this is a good reroll. I have this question on a few issues, and still haven't gotten a definitive answer: we have a schema addition, so do we need an empty hook_update_N() to force a rebuild so it gets read in?

howards’s picture

I don't know enough to say whether or not hook_update_N() applies. However, I can try to provide additional information based on whether things work without using drush si -y. (I assume that's the threshold as to whether hook_update_N() is necessary.)

I just installed 8.2.x @ 04953c5a and tried to reproduce the original issue. I was presented with the ability to create default arguments listed in the proposed resolution, but actually saving them wouldn't work. I could save with "fixed value" but I could not save (e.g. the Views contextual argument overlay window would not disappear after clicking "Apply") with current date, current node's creation time, or current node's update time.

Unpatched Drupal installation of Views with Contextual Argument

Then I applied the patch:

[php55@Web ~/local.dev/public_html]$ patch -p1 < views_argument_handlers-2325899-56.patch
patching file core/modules/node/config/schema/node.views.schema.yml
patching file core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
patching file core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
patching file core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php
patching file core/modules/views/config/schema/views.argument_default.schema.yml
patching file core/modules/views/src/Plugin/views/argument/Date.php
patching file core/modules/views/src/Plugin/views/argument_default/Date.php
patching file core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
patching file core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_default_date.yml

And the options for current date, or node creation/update time disappeared.

Patch in comment 56 applied without reinstallation.

Afterward, I reversed the patch and the current date and node creation/update options reappeared.

[php55@Web ~/local.dev/public_html]$ patch -p1 -R < views_argument_handlers-2325899-56.patch
patching file core/modules/node/config/schema/node.views.schema.yml
patching file core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
patching file core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
patching file core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php
patching file core/modules/views/config/schema/views.argument_default.schema.yml
patching file core/modules/views/src/Plugin/views/argument/Date.php
patching file core/modules/views/src/Plugin/views/argument_default/Date.php
patching file core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
patching file core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_default_date.yml

I highly doubt this answers the question of "do we need hook_update_N()" but might highlight another issue. Hmm... (I will do more research and attempt to figure out what's going on.

howards’s picture

I reinstalled 8.2.x @ 04953c5a with the patch applied prior to installation. (e.g. patch was applied and then drush8 si -y standard --account-name='admin' --account-pass='admin' and everything seems to work. Again, I don't know enough about hook_update_N(), but it appears as though it's needed because the patch applied after Drupal has been installed has had unintentional effects. Installing Drupal with the patch previously applied gave a somewhat different order of default arguments:

Patch in comment 56 applied prior to a drush reinstall

EDIT: I was able to save everything and have the Views overlay window disappear when adding a contextual argument.

EDIT 2: Do the previous two comments answer the question of whether or not hook_update_N() is necessary? I hope this is enough information to determine whether or not the update is necessary.

howards’s picture

Is there anything else I can do to test this issue and provide more information? Is it just writing an update_hook(), or as @mpdonadio put it, "an empty update_hook()"? (I will try, but will probably fail like 100 times before it works; I R TEH ID10T. Nobody wants 10,000 notifications of failure, let alone a dumbass who can't seem to get core/scripts/run-tests.sh to work correctly without a million failures.)

I'm stupid, but I try... *smirk*

mradcliffe’s picture

Thank you for the screenshots and manual testing, howards! One thing that really helps the committers is to be able to see these manual test results in the issue summary.

The next step would be to ask in IRC (#drupal-contribute) regarding this issue and see if anyone there is able to answer @mpdonadio's question. Perhaps @dawehner could shed some light?

howards’s picture

Issue summary: View changes

Updating issue summary with manual test results.

cilefen’s picture

Issue tags: +Triaged core major

@timplunkett, @alexpott, @dawehner, @xjm and I discussed this in a triage session at DrupalCon Dublin. A fatal in the UI is major priority normally so we are keeping that status.

cilefen’s picture

Title: Views argument handlers no longer can provide their own default argument handling » UI fatal caused by views argument handlers no longer can provide their own default argument handling
howards’s picture

Is there anything I can do to help the process?

mpdonadio’s picture

Version: 8.1.x-dev » 8.2.x-dev
StatusFileSize
new24.44 KB
new477 bytes

Based on the manual tests, it sounds like we do need the empty update hook to force a cache clear to read the schema additions. Here is a quick patch. Manual testing process would be

- Install 8.2.x (has to be 8.2.x HEAD, update hook won't work otherwise)
- Apply patch
- Run and apply updates from update.php
- Test to see if everything works as expected

I did this quickly, but someone should recheck this methodically.

howards’s picture

Status: Needs review » Reviewed & tested by the community

I reinstalled from HEAD (56188d7f), added a date field to article and created a number of nodes with arbitrary dates (authored on and field_date) from yesterday, today, and tomorrow (local time). Afterward, I added a view and tried to add contextual argument, much to the same previous result. (Views contextual arguments would save/disappear with "fixed value" but not with current date, current node's creation time, or current node's update time.) I applied the patch and checked saving arguments again; similar disappearance as previously demonstrated.

Then, I ran /update.php to run the empty views_update hook and again tried saving with expected results. I was able to save contextual arguments without issue. I was also able to test the Views output.

For the tests, I set up multiple views with Block displays to see which nodes were returned. I set up nine blocks: one for each combination of "authored on", "changed", and an arbitrary field_date against each of "node created time, node changed time, and current date." I used block placement to display all of the blocks on all pages and started browsing through the previously created nodes to see which appeared in which blocks. The nodes appropriately displayed in each of the blocks according to which node was viewed. (e.g. nodes created on Sunday appeared with other nodes created on Sunday, nodes with field_date set to Tuesday appropriately appeared with other nodes' field_dates set to Tuesday. etc.)

Everything seemed to work as expected. It all appears to work well with the empty hook_update() for having the schema reload. I will provide screenshots of methodical testing if necessary, but would take a bit of explanation as to which node is displayed and its expected Views results.

Setting RTBC. Thanks for everything!

mpdonadio’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update
alexpott’s picture

Status: Reviewed & tested by the community » Needs review
+++ b/core/modules/views/src/Plugin/views/argument/Date.php
@@ -34,87 +30,12 @@ class Date extends Formula implements ContainerFactoryPluginInterface {
-  public function defaultArgumentForm(&$form, FormStateInterface $form_state) {
...
-  public function getDefaultArgument($raw = FALSE) {

All of these methods are on the parent class therefore there is no API change here. Nice.

We're adding at least three new views plugins - do we have test coverage for everything?

lendude’s picture

+++ b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
@@ -125,6 +126,25 @@ public function testArgumentDefaultFixed() {
+ function testArgumentDefaultDate() {

tests the current date

+++ b/core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php
@@ -0,0 +1,93 @@
+ * Contains \Drupal\node\Tests\Views\DateArgumentDefaultTest.

tests both the current node plugins

+++ b/core/modules/views/config/schema/views.argument_default.schema.yml
@@ -1,5 +1,9 @@
+views.argument_default.date:
+  type: boolean
+  label: 'Current date'

we seem to be missing the two 'current node' schema here though.

lendude’s picture

+++ b/core/modules/node/config/schema/node.views.schema.yml
@@ -73,6 +73,14 @@ views.argument_default.node:
+views.argument_default.node_created:
+  type: sequence
+  label: 'Current node created time'
+
+views.argument_default.node_changed:
+  type: sequence
...
+

oops, just overlooked them!

alexpott’s picture

+++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
@@ -0,0 +1,113 @@
+
+      // The Date argument handlers provide their own format strings, otherwise
+      // use a default.
+      if ($argument instanceof \Drupal\views\Plugin\views\argument\Date) {
+        /** @var \Drupal\views\Plugin\views\argument\Date $argument */
+        $format = $argument->getArgFormat();
+      }
+      else {
+        $format = 'Y-m-d';
+      }

+++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
@@ -0,0 +1,113 @@
+      // The Date argument handlers provide their own format strings, otherwise
+      // use a default.
+      if ($argument instanceof \Drupal\views\Plugin\views\argument\Date) {
+        /** @var \Drupal\views\Plugin\views\argument\Date $argument */
+        $format = $argument->getArgFormat();
+      }
+      else {
+        $format = 'Y-m-d';
+      }

+++ b/core/modules/views/src/Plugin/views/argument_default/Date.php
@@ -0,0 +1,109 @@
+    // The Date argument handlers provide their own format strings, otherwise
+    // use a default.
+    if ($argument instanceof \Drupal\views\Plugin\views\argument\Date) {
+      /** @var \Drupal\views\Plugin\views\argument\Date $argument */
+      $format = $argument->getArgFormat();
+    }
+    else {
+      $format = 'Y-m-d';
+    }

Is this logic tested for each plugin?

Anonymous’s picture

Super works, many thanks! It seems left quite little bit!

We can make a new logic in separate Feature request issue, if these tests are not enough?

Or maybe transfer logic by get $format to static method, and testing it? Example like DateHelper:

public static function getFormatByArgument($argument){
  // The Date argument handlers provide their own format strings, otherwise
  // use a default.
  if ($argument instanceof \Drupal\views\Plugin\views\argument\Date) {
    /** @var \Drupal\views\Plugin\views\argument\Date $argument */
    $format = $argument->getArgFormat();
  }
  else {
    $format = 'Y-m-d'; // DATETIME_DATE_STORAGE_FORMAT
  }
  return $format;
}
mattlt’s picture

This commit…

https://www.drupal.org/commitlog/commit/2/6663917e5c3e2d614ae98777d80dae...

…uses the same update version in `views.install` .

Looks like the patch needs to be updated.

Thanks,

•• matt

mpdonadio’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

This no longer applies, and for conflicts outside the function below.

+++ b/core/modules/views/views.install
@@ -406,5 +406,12 @@ function views_update_8200() {
 /**
+ * Clear cache to ensure schema additions are read.
+ */
+function views_update_8201() {
+  // Empty update to cause a cache rebuild so that schema additions are read.
+}
+
+/**
  * @} End of "addtogroup updates-8.2.0".

This should be changed to an empty hook_post_update_NAME(), since we are trying to avoid empty hook_update_N() in core just to trigger rebuilds.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new24.49 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, 77: 2325899-77.patch, failed testing.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new24.49 KB
new451 bytes

Corrected update hook number.

mpdonadio’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll

Still needs to be rerolled. From https://www.drupal.org/pift-ci-job/586765 / https://dispatcher.drupalci.org/job/drupal_patches/389/

13:38:36 No syntax errors detected in /var/www/html/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
13:38:36 PHP Fatal error:  Cannot redeclare views_update_8201() (previously declared in /var/www/html/core/modules/views/views.install:413) in /var/www/html/core/modules/views/views.install on line 420
13:38:36 Errors parsing /var/www/html/core/modules/views/views.install


See the comment in #76. Instead of using a hook_update_N() in views.install, this should be changed to a post-update hook in views.post_update.php

Crosspost with #79, but the comment still applies. This should be a post update hook and not and update_N.

jofitz’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll

Already done.

mpdonadio’s picture

Status: Needs review » Needs work
+++ b/core/modules/views/views.install
@@ -413,5 +413,12 @@ function views_update_8201() {
 /**
+ * Clear cache to ensure schema additions are read.
+ */
+function views_update_8202() {
+  // Empty update to cause a cache rebuild so that schema additions are read.
+}
+
+/**

See the comment near the end of #76. Instead of using a hook_update_N() in views.install, this should be changed to a post-update hook in views.post_update.php. We are really trying to avoid empty hook_update_N just to trigger rebuilds; instead we need to do them in post-update hooks.

jofitz’s picture

Status: Needs work » Needs review
StatusFileSize
new24.57 KB
new1.02 KB

Sorry, my mistake, didn't read it properly. Thanks for your patience.

balagan’s picture

I have applied the patch, and it seems that the 'current node created time' uses Y-M-D, whereas I would think it should use timestamp, or a time including seconds.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

lendude’s picture

StatusFileSize
new7.53 KB
new25.5 KB

First step to addressing @alexpotts feedback in #73, also some CS cleanup.

edysmp’s picture

I have tested the "Current date" contextual filter successfully. Thanks

Status: Needs review » Needs work

The last submitted patch, 88: 2325899-88.patch, failed testing.

dagmar’s picture

Version: 8.3.x-dev » 8.4.x-dev
Status: Needs work » Needs review

Patch only applies to 8.4.x

pwolanin’s picture

StatusFileSize
new25.54 KB

patch applies to 8.3.x with fuzz. Here as .txt

mpdonadio’s picture

argument/Date implements ContainerFactoryPluginInterface

+++ b/core/modules/views/src/Plugin/views/argument/Date.php
@@ -2,11 +2,7 @@
@@ -34,87 +30,12 @@ class Date extends Formula implements ContainerFactoryPluginInterface {

and then we remove the create method, which ContainerFactoryPluginInterface requires

+++ b/core/modules/views/src/Plugin/views/argument/Date.php
@@ -34,87 +30,12 @@ class Date extends Formula implements ContainerFactoryPluginInterface {
-  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
-    return new static(
-      $configuration,
-      $plugin_id,
-      $plugin_definition,
-      $container->get('current_route_match')
-    );
-  }

I'm confused why this is working; I don't see where the create method is coming from now. I am also curious whether this is a BC break. Asking because this has potentially gotten entangled with #2627512: Datetime Views plugins don't support timezones, which was extending this class, and the two patches don't work with each other right now.

Not sure which patch has to do what.

?

pwolanin’s picture

The very base plugin class also implements ContainerFactoryPluginInterface and the base form of create() so it doesn't actually need to be added here.

Assuming the other patch goes in first, I think the fix here will be easy.

mian3010’s picture

StatusFileSize
new24.27 KB

Rerolled to 8.2.7

The last submitted patch, 88: 2325899-88.patch, failed testing.

mpdonadio’s picture

#94, 8.2.7 is no longer supported, and 8.3.1 is coming out later today. This issue is currently against 8.4.x.

#88 is the patch that need to be reviewed. Just triggered retests.

sk33lz’s picture

Status: Needs review » Needs work
Issue tags: +Baltimore2017

#88 no longer applies cleanly in 8.4.x. Changing to Needs Work.

Anonymous’s picture

Status: Needs work » Needs review
Issue tags: -Baltimore2017
StatusFileSize
new25.59 KB
new2.75 KB

Rerolled. This patch contains next changes:

  1. - b/core/modules/views/src/Tests/Plugin/ArgumentDefaultTest.php
    + b/core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php

    ArgumentDefaultTest in new place (this is reason of Patch Failed to Apply)

  2. - b/core/modules/node/src/Tests/Views/DateArgumentDefaultTest.php
    + b/core/modules/node/tests/src/Functional/Views/DateArgumentDefaultTest.php

    Aye!)

  3. some CS cleanup and fix typo (see interdiff.txt)

And still tasks:
#73 with partial of test coverage in #86.
#92 looks like good point about BC break. Do we really need to delete the create() here?


#94: Thanks, @mian3010! This is really useful (especially two months ago) to solve the problem on 8.2.x sites, where these handlers are needed.
mian3010’s picture

StatusFileSize
new7.04 KB

Re-rolled for 8.3.3 (in case anybody, like me, needs the patch on that version)

purushotam.rai’s picture

StatusFileSize
new9.72 KB
new2.71 KB

Above patch was solving issue partially. While executing update 8300 of block_content, I was facing issue "Date" plugin not found. Combined #99 patch and #2567773: Can't select "current date" as default option in a date contextual filter resolved my issue.

Thanks

Status: Needs review » Needs work

The last submitted patch, 100: ui_fatal_caused_by-2325899-100.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

olofbokedal’s picture

I can't get the patch from #99 to work. Applied just fine, but the `Current date` default argument isn't available as an option for a regular date field. I tried to change the `default_argument_type` in the exported config file and imported the new config, but then I got the same error again: `The "date" plugin does not exist`.

I ran update.php, and also cleared the Views cache manually, but there's no difference.

tacituseu’s picture

Status: Needs work » Needs review

8.4.x is the target and #98 is still the one to review, at the very least add -do-not-test.patch to those 'helpful' patches to not disturb the issue.

Anonymous’s picture

StatusFileSize
new26.22 KB
new2.53 KB

#98 tasks:

  1. Added test coverage for all cases in NodeCreated. If it is ok, i can add same logic tested for each plugin.
  2. Returned Date::create(), because it conflicts with #2627512: Datetime Views plugins don't support timezones and seems not necessary in this issue.

#100: Thanks for the info. Perhaps this should be considered in more detail. But I have no experience with this.

#102: You are right. This occurs due to incorrect preparation date. Regular date field don't use getDateFormat() (and as result getDateField). This diff between 'created' and 'field_test2':

# regular 'field_test2'
DATE_FORMAT(node__field_test2.field_test2_value, '%Y-%m-%d') = :node__field_test2_field_test2_value

# standard 'created'
DATE_FORMAT((DATE_ADD('19700101', INTERVAL node_field_data.created SECOND) + INTERVAL 10800 SECOND), '%Y-%m-%d') = :node_field_data_created

But the heroes from the #2627512: Datetime Views plugins don't support timezones seem to have already overcome this problem! After that patch all work and query looks like:

DATE_FORMAT((node__field_test2.field_test2_value + INTERVAL 10800 SECOND), '%Y-%m-%d') = :node__field_test2_field_test2_value

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Anonymous’s picture

StatusFileSize
new28.58 KB
new7.41 KB

Changes:

  1. C/p test coverage of NodeCreated to NodeChanged + additional test coverage for Date.
    +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -6,8 +6,8 @@
    -use Drupal\datetime\Plugin\views\filter\Date;
    +use Drupal\views\Plugin\views\argument\Date;
    

    A small but important correction, so the idea of the tests in #73 was fair. And looks, it is done, but it needs to review.

  2. Replaced a few of deprecated methods.

Current patch does not include the #100, because I still do not have enough experience to do a review of this.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

idflood’s picture

Applied patch in #106 with drupal-composer, ran update.php and it fixed the issue.

pifagor’s picture

Applied patch in #106 with drupal-composer, ran update.php and it fixed the issue.

+1

lendude’s picture

+++ b/core/modules/views/src/Plugin/views/argument_default/Date.php
@@ -0,0 +1,105 @@
+  /**
+   * {@inheritdoc}
+   */
+  public function getCacheMaxAge() {
+    return 0;
+  }

I think this not getting cached is important enough to warrant a test. Just hit a page that uses this and making sure it's marked uncachable, something like that?

Anonymous’s picture

StatusFileSize
new31.02 KB
new2.61 KB

#100: Is it still relevant? It seems no one complained about it anymore. Especially since almost a year has passed, during this time there were many fixes. One of which could solve the problem.

#110: make sense, done!

rhache’s picture

@vaplas This is issue is certainly not fixed. Yesterday I tried to do a contextual filter on the current date (for a date field) and it simply won't work.

Anonymous’s picture

My question to #100 was about error: "Date" plugin not found.

@purushotam.rai suggests adding an next check to fix it:

+++ b/core/modules/views/src/Plugin/views/argument/ArgumentPluginBase.php
@@ -1108,6 +1108,15 @@ public function getPlugin($type = 'argument_default', $name = NULL) {
+    if ($type == 'argument_default') {
+      // Default arguments don't necessarily need to be plugins, they can be
+      // handled in the getDefaultArgument() method of an argument also.
+      $plugin_definition = Views::pluginManager($type)->getDefinition($name, FALSE);
+      if (!$plugin_definition) {
+        return;
+      }
+    }

But I can not reproduce this problem, perhaps it has already been fixed. Test attached to the #100 passed with the current patch, too.

All other feedback was addressed.


@rhache, have you checked these filters after applying the patch (#106 or #111, it does not matter) and running the /update.php?
richgerdes’s picture

Status: Needs review » Needs work

I came across this issue in 8.5 and am able to reproduce this on a fresh install of 8.6.x-dev. The patch in #111 did successfully apply and solved the issue. However, some feedback.

I don't think that using a 0 cache age is the correct approach here. The cache age can be determined using the seconds until the date change. This can be done using strtotime('tomorrow') - time(). As users can set individual timezones this should then have the cache context for the current user, and use their timezone to calculate the max cache age.

Also reading through the comments, I noticed #48. I think this is a very valuable thing to consider as well since it would provide wider support for the functionality.

Marking this as needs works since it should either get tests added or have a proper cache context implemented.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

acbramley’s picture

The "Date" plugin not found error still exists at least on 8.5.7, reproducable by selecting "Current date" as the argument default for a date contextual filter eg "Content: node.field_event_start_date (year)" where field_event_start_date is a date field.

Confirmed that #111 fixes it.

lamigo’s picture

The "Date" plugin not found error still exists at least on 8.6.3, reprodicable by selecting "Current date" as the argument default for a date contextual filter eg "Content: node.field_event_start_date (year)" where field_event_start_date is a date field.

Confirmed that #111 fixes it.

konfuzed’s picture

Can confirm this bug is still present on a very simple 8.6.4 installation today. Path 2325899-111 fixed it for a year/week contextual filter implementation.

kmani’s picture

Confirmed that #111 fixes it.

joachim’s picture

> IMHO we should implement this not just for nodes but for every entity with EntityChangedInterface

> Also reading through the comments, I noticed #48. I think this is a very valuable thing to consider as well since it would provide wider support for the functionality.

Yes, but... doing this would require a derivative plugin, which would mean the plugin ID would change from 'node_created' to something like 'entity_created:node', which would require a hook_update_N() to convert existing views that use 'node_created' as their argument default setting. Which rather complicates this patch.

It would be better to leave to a follow-up.

joachim’s picture

> I don't think that using a 0 cache age is the correct approach here. The cache age can be determined using the seconds until the date change. This can be done using strtotime('tomorrow') - time(). As users can set individual timezones this should then have the cache context for the current user, and use their timezone to calculate the max cache age.

Is that not also out of this issue's scope?

joachim’s picture

  1. +++ b/core/modules/node/config/schema/node.views.schema.yml
    @@ -66,6 +66,14 @@ views.argument.node_vid:
    +views.argument_default.node_created:
    +  type: sequence
    +  label: 'Current node created time'
    +
    +views.argument_default.node_changed:
    +  type: sequence
    +  label: 'Current node changed time'
    +
     views.field.node:
    

    Is this necessary?

    These plugins have no configuration, so isn't it fine for them to just use the wildcard default:

    views.argument_default.*:
      type: mapping
      label: 'Base default argument'
    

    It's what the current_user ViewsArgumentDefault plugin does.

  2. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -0,0 +1,110 @@
    + * The current node changed argument default handler.
    
    +++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
    @@ -0,0 +1,110 @@
    + * The current node created argument default handler.
    

    While we're rerolling, both of these sentences read badly. Something like 'Provides the created time of the current node as default argument value.' assuming that's under 80 chars.

  3. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -0,0 +1,110 @@
    +  /**
    +   * Return the current node changed time if a current node can be found.
    +   */
    
    +++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
    @@ -0,0 +1,110 @@
    +  /**
    +   * Return the current node creation time if a current node can be found.
    +   */
    
    +++ b/core/modules/views/src/Plugin/views/argument_default/Date.php
    @@ -0,0 +1,105 @@
    +  /**
    +   * Return the default argument.
    +   */
    

    This method is defined in ArgumentDefaultPluginBase, so the docblocks here should be @inheritdoc.

    For the two node plugins, move the text to an inline comment as it's informative.

lendude’s picture

Status: Needs work » Needs review
StatusFileSize
new29.93 KB

Straight reroll for now, just to see what this does now.

lendude’s picture

StatusFileSize
new4.37 KB
new4.37 KB

Addressed #122.

Also moved the date format in the 'current date default argument' to a class variable so that it is easy to create default arguments for different formats (like month/year/week) by just extending that class and overriding that variable.

lendude’s picture

StatusFileSize
new29.88 KB

...sigh...

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

wombatbuddy’s picture

Confirmed that #125 fixes it.

rutiolma’s picture

+1 for patch #125

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

rensingh99’s picture

Status: Needs review » Reviewed & tested by the community

Hi,

I had applied the patch with Drupal 8.9.x and it's throwing an error.

Only local images are allowed.

I have corrected that and made it compatible with 8.9.x.

Below is my review:

Before applying the patch

1) I have created the view for the 'page' content type and tried to add the 'Authored on' field in CONTEXTUAL FILTERS. But I was not able to apply these filters.
2) Then I reviewed dblog and I notice the below error.

Only local images are allowed.

After applying the patch

1) I ran update.php
2) Then I tried to add the 'Authored on' field in CONTEXTUAL FILTERS and I have added this field successfully.
3) Also, the view was working perfectly after applying the patch.

I also checked the patch with the coder module and corrected the errors from the list.

Only local images are allowed.

I was unable to fix one error because both class names are the same in core/modules/views/src/Plugin/views/argument_default/Date.php and \Drupal\views\Plugin\views\argument\Date.php

Below is the output screenshot of the coder.

Only local images are allowed.

Thanks,
Ren

clemens.tolboom’s picture

Status: Reviewed & tested by the community » Needs work

As @rensingh99 found in #130 and the failing test(s) for 8.9.x (Patch Failed to Apply) in #125 I added ... this needs work.

rensingh99’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new30.08 KB
new2.1 KB

Hi,

I had missed the patch to attach in my comment. Here is my updated patch

Thanks,
Ren

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 132: 2325899-132.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

joos’s picture

#125 worked for me

rensingh99’s picture

rensingh99’s picture

clemens.tolboom’s picture

So we have patches in comments

- #125 for D8.7.x RTBCed
- #132 for D8.8.x and D8.9.x still needs work

rensingh99’s picture

StatusFileSize
new30.06 KB
new235 bytes

Hi,

Patch #132 was failing due to fix in Remove the core key from views configuration.

I have corrected that.

Thanks,
Ren

rensingh99’s picture

Status: Needs work » Needs review
rensingh99’s picture

Status: Needs review » Reviewed & tested by the community
jungle’s picture

StatusFileSize
new30.06 KB

Reroll the patch in #138

jungle’s picture

StatusFileSize
new33.38 KB
new4.99 KB

Fix coding standard and deprecated assertions

core/modules/views/src/Plugin/views/argument_default/Date.php
85 | ERROR | [x] Namespaced classes/interfaces/traits should be referenced with use statements

jungle’s picture

Status: Reviewed & tested by the community » Needs review

The last submitted patch, 141: 2325899-141.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jungle’s picture

StatusFileSize
new33.45 KB
new553 bytes

$defaultTheme is required in DateArgumentDefaultTest

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

muaz7731’s picture

Status: Needs review » Reviewed & tested by the community

Hi, test out the patch from #145 with drupal core 8.8.6. it works. need to clear cache first to have the filter display. Thanks @jungle
set as RTBC

muaz7731’s picture

Version: 9.1.x-dev » 8.8.x-dev

I'm not sure what version to put this. maybe 8.8.x-dev?

dww’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Thanks, but this can't be RTBC if the patch fails to apply.

We need fresh patches for 9.1.x, 9.0.x and 8.9.x.

Quick skim looks like this is probably too potentially disruptive for 8.8.x, but it does have the "Triaged D8 major" tag, so maybe. ;) A separate 8.8.x patch for that branch (or maybe re-test #145 if that's still legit for 8.8x.) would be good, just in case.

Thanks,
-Derek

sokru’s picture

Version: 8.8.x-dev » 9.1.x-dev
Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new33.37 KB
new33.35 KB

Reroll from #145.
D9 patch applies cleanly to both 9.0.x and 9.1.x branch.

Status: Needs review » Needs work

The last submitted patch, 150: 2325899-150-D9.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jungle’s picture

Status: Needs work » Needs review
StatusFileSize
new33.4 KB
new1.22 KB

Fixing test failure and one CS violation of the patch for 9.x in #150

Status: Needs review » Needs work

The last submitted patch, 152: 2325899-9.x-152.patch, failed testing. View results

jungle’s picture

Status: Needs work » Needs review

#152 looks like a random failure, re-queued.

nno’s picture

Applied #150 to Drupal 8.9.4 to create views for "Today's day in history" with two contextual filters:
Content: node.field_date (day) / Provide default value = Current date
Content: node.field_date (month) / Provide default value = Current date

Works like a charm. Thank you.

jungle’s picture

Issue tags: +Bug Smash Initiative

@Lendude:

@jungle it seems unrelated changes have snuck in? I see a lot of assertEqual changed to assertEquals going on, it doesn’t seem like any of those changes are relevant?
But I have to admit that is one I left to die in a ditch, not convinced anymore we should do any of that, other then just deleting \Drupal\views\Plugin\views\argument\Date::getDefaultArgument and \Drupal\views\Plugin\views\argument\Date::defaultArgumentForm
This crap hasn’t worked since before 8.0.0, and providing a default argument for ‘the create time of the current node’ has always sounded completely pointless to me (the patch does provide a default argument for the current date which might actually be useful…)

But back when I started working on that it was still pretty much ‘it was in D7 so it must be in D8’, no matter how pointless it was

Changes of assertEqual -> assertEquals were wrong, have not swapped $expected and $actual, my bad. and some of them are out of scope/irrelevant.

The bug exists still in 9.1.x, manually tested. Due to my limited knowledge to views, I have no idea how to push this forward next :(. Thanks @Lendude's replies on slack.

solide-echt’s picture

Hi, as one of the maintainers for Calendar I have a question since that contrib is very much dependent on date contextual argument handling:

Is the 9.x patch *supposed* to work for datetime_range too? From my manual testing it doesn't. The error is:

SQLSTATE[22007]: Invalid datetime format: 7 ERROR: invalid value "T1" for "HH24" DETAIL: Value must be an integer.: SELECT "node_field_data"."created" AS "node_field_data_created", "node_field_data"."nid" AS "nid" FROM {node_field_data} "node_field_data" LEFT JOIN {node__field_date_range} "node__field_date_range" ON node_field_data.nid = node__field_date_range.entity_id AND node__field_date_range.deleted = :views_join_condition_0 WHERE ((TO_CHAR((TO_TIMESTAMP(node__field_date_range.field_date_range_value, 'YYYY-MM-DD HH24:MI:SS') + INTERVAL '7200 SECONDS'), 'MM') = :node__field_date_range_field_date_range_value_month)) AND (("node_field_data"."status" = :db_condition_placeholder_1) AND ("node_field_data"."type" IN (:db_condition_placeholder_2))) ORDER BY "node_field_data_created" DESC NULLS LAST LIMIT 10 OFFSET 0; Array ( [:node__field_date_range_field_date_range_value_month] => 10 [:db_condition_placeholder_1] => 1 [:db_condition_placeholder_2] => contact [:views_join_condition_0] => 0 )

I'll try dig in deeper, the HH24:MI:SS format looks odd.

Kind regards,
Eric

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

pdenooijer’s picture

Version: 9.2.x-dev » 9.0.x-dev
Status: Needs review » Reviewed & tested by the community

Works like a charm. This bug should be fixed for all minor versions of 9.

clemens.tolboom’s picture

Version: 9.0.x-dev » 9.2.x-dev
Status: Reviewed & tested by the community » Needs review

Reset version according to comment #158 and set to Needs review for test on 9.2.x and both #156 and #157 suggests some may still be wrong

pdenooijer’s picture

Version: 9.2.x-dev » 9.1.x-dev
StatusFileSize
new27.55 KB

As far as I can see is this a bugfix and not a disruptive change. So this can be merged to the current Drupal branch.

Rerolled the patch to branch 9.1.x as it had conflicts.

Status: Needs review » Needs work

The last submitted patch, 161: 2325899-9.1.x-161.patch, failed testing. View results

anmolgoyal74’s picture

Version: 9.1.x-dev » 9.2.x-dev
Status: Needs work » Needs review
StatusFileSize
new27.78 KB
new1.01 KB

Tried to handle the failed test cases.

pdenooijer’s picture

StatusFileSize
new27.85 KB
new1.68 KB

Thanks @anmolgoyal74 for fixing what I missed. Uploaded a new patch that fixes the deprecation warnings in the 9.2.x branch.

pdenooijer’s picture

mfgr’s picture

Working like a charm on my website (v. 9.1.4). I hope this will be integrated into Core....

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Tried to review this. I am not able to follow all the steps to reproduce in the Issue Summary. The first is fine, but then the second "Set default argument to "Current date"' I can't. There is no indication where to find this value. I then skimmed the IS and I think the current date is available after applying the patch and in a contextual filter?

Add the patch does not apply to 9.3.x.

sokru’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update, -Needs reroll
StatusFileSize
new27.85 KB

Reroll for 9.3.x + updated the issue summary with exact steps. No interdiff produced.

ragnarkurm’s picture

StatusFileSize
new143.39 KB

@quietone

see the screenshot.
Screenshot

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

egfrith’s picture

When upgrading from Drupal 8 to Drupal 9, I got the same error: "The "date" plugin does not exist.". This prevented db updates.

I fixed the issue by finding the view in which the current date had been set as a default in a contextual filter, and removing the current date default. It did take a couple of hours, so it would be great if this issue could be fixed, though I don't have expertise to offer in terms of reviewing the patch.

chucksimply’s picture

#169 works for me on 9.3.3. Thanks!

smustgrave’s picture

#169 works for us

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -0,0 +1,111 @@
    +/**
    + * Provides the 'changed' time of the current node as default argument value.
    + *
    + * @ingroup views_argument_default_plugins
    + *
    + * @ViewsArgumentDefault(
    + *   id = "node_changed",
    + *   title = @Translation("Current node 'changed' time")
    + * )
    + */
    

    Rather than a specific implementation for nodes it feels as though this should somehow be something generic that leverages \Drupal\Core\Entity\EntityChangedInterface::getChangedTime() - I think we could generate instances for all entity types and do something like \Drupal\Core\Entity\EntityForm::getEntityFromRouteMatch() to get the entity from the route match. I guess this could be a follow-up.

  2. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
    @@ -0,0 +1,111 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getCacheMaxAge() {
    +    return Cache::PERMANENT;
    +  }
    
    +++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
    @@ -0,0 +1,111 @@
    +  /**
    +   * {@inheritdoc}
    +   */
    +  public function getCacheMaxAge() {
    +    return Cache::PERMANENT;
    +  }
    

    Are we should about this - I would have thought that it would be best add the node as a cacheable dependency - I think we need to vary by the node's cache tags for example.

  3. +++ b/core/modules/node/src/Plugin/views/argument_default/NodeCreated.php
    @@ -0,0 +1,111 @@
    +/**
    + * Provides the created time of the current node as default argument value.
    + *
    + * @ingroup views_argument_default_plugins
    + *
    + * @ViewsArgumentDefault(
    + *   id = "node_created",
    + *   title = @Translation("Current node 'created' time")
    + * )
    + */
    +class NodeCreated extends ArgumentDefaultPluginBase implements CacheableDependencyInterface {
    

    Oddly there is no generic interface for getCreatedTime() so I think this plugin needs to be entity specific.

  4. +++ b/core/modules/node/tests/src/Functional/Views/DateArgumentDefaultTest.php
    @@ -0,0 +1,189 @@
    +    // Test that the nodes with a create date in the same month are shown.
    ...
    +    // Test that the nodes with a title in the same create date are shown.
    

    This is the changed date and no the create date.

  5. +++ b/core/modules/views/src/Plugin/views/argument/Date.php
    @@ -141,4 +141,14 @@ public function getFormula() {
    +  public function getArgFormat() {
    

    New code should use return type hints.

  6. +++ b/core/modules/views/src/Plugin/views/argument_default/Date.php
    @@ -0,0 +1,113 @@
    +    $request_time = $this->request->server->get('REQUEST_TIME');
    

    This should be using the time service and not the REQUEST_TIME server variable.

alexpott’s picture

+++ b/core/modules/node/src/Plugin/views/argument_default/NodeChanged.php
@@ -0,0 +1,111 @@
+      $argument = $this->argument;
+
+      // The Date argument handlers provide their own format strings, otherwise
+      // use a default.
+      if ($argument instanceof Date) {
+        /** @var \Drupal\views\Plugin\views\argument\Date $argument */
+        $format = $argument->getArgFormat();
+      }
+      else {
+        $format = 'Y-m-d';
+      }
+

This can be written as...

      // The Date argument handlers provide their own format strings, otherwise
      // use a default.
      $format = $this->argument instanceof Date ? $this->argument->getArgFormat() : 'Y-m-d';

The @var is not needed because there is the instanceof check. The $argument local variable is unnecessary too.

This can be used elsewhere in the patch too.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

damienmckenna’s picture

Ran into a related problem with a custom Search API "date" property field where it returns this error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "date" plugin does not exist. Valid plugin IDs for Drupal\Core\TypedData\TypedDataManager are: [~800 different plugins]

FWIW we hit the error displaying the property as a field in a Views block.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

davidiio’s picture

Hi everyone,

We were using the last patch in this issue but since we updated Drupal to version 9.5.0 composer indicate
" Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2021-06-28/2325899-169-9.3-169.patch"

When exploring the files I have only one .rej file and here is the content:

--- modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php
+++ modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php
@@ -29,6 +30,7 @@ class ArgumentDefaultTest extends ViewTestBase {
     'test_argument_default_current_user',
     'test_argument_default_node',
     'test_argument_default_query_param',
+    'test_argument_default_date',
     ];
 
   /**

Does this could be a problem on our site, anybody experienced the same? The patch must be reworked ?

ruslan piskarov’s picture

@davidiio, the same issue for me.

skylord’s picture

StatusFileSize
new27.85 KB

Hm. It's just an indentation issue.. Try this for 9.5.0.

ludo.r’s picture

StatusFileSize
new27.88 KB
new601 bytes

Here's the same patch as #183, with fixed tests.

ludo.r’s picture

After some investigation, I can confirm the following:

  • I applied the patch #183/#184 to D9.5 => no error when submiting the ajax form
  • I spun-off a vanilla D9.5 (aka without the patch) => error when submitting the ajax form

So I assume the patch works, I just don't know why the tests which are exactly the same as #169 don't work anymore.

anairamzap’s picture

StatusFileSize
new27.87 KB

Hello,
We were using the patch on #169 and we could not apply it when updating to Drupal 9.5.

So I'm adding a re-roll of #169 to apply cleanly on 9.5.x in case is useful

anairamzap’s picture

ok, so... I think I've found the issue with the tests failing. The test fails because the view is never loaded.

Both tests, the one for the plugin at core/modules/views/tests/src/Functional/Plugin/ArgumentDefaultTest.php AND the one for node module at core/modules/node/tests/src/Functional/Views/DateArgumentDefaultTest.php are trying to use the same view wih id test_argument_default_date the problem is the view itself, the config for it, is added on the views_test_config test module.

If you look at the DateArgumentDefaultTest setUp method, is using a different test module: node_test_views which does not provide the expected view and then of course it fails to load it.

Now I'm really not sure if we should either:

  1. Duplicate the view config, and add it to the node_test_views module.
  2. Or try to re-utilize the view from the views_test_config module.

For the second option (which seemed better so we do not duplicate a view config in a different directory) I've tried to load that module in the DateArgumentDefaultTest setUp method, something like:

  protected function setUp($import_test_views = TRUE, $modules = ['views_test_config']): void {
    parent::setUp($import_test_views, $modules);

but I've got:

1) Drupal\Tests\node\Functional\Views\DateArgumentDefaultTest::testArgumentDefaultNodeCreated
Drupal\Core\Entity\EntityStorageException: 'view' entity with ID 'test_argument_default_date' already exists.

/var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:553
/var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:517
/var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:253
/var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php:339
/var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:608
/var/www/html/web/core/modules/views/src/Tests/ViewTestData.php:52
/var/www/html/web/core/modules/views/tests/src/Functional/ViewTestBase.php:49
/var/www/html/web/core/modules/node/tests/src/Functional/Views/NodeTestBase.php:21
/var/www/html/web/core/modules/node/tests/src/Functional/Views/DateArgumentDefaultTest.php:78
/var/www/html/vendor/phpunit/phpunit/src/Framework/TestResult.php:703

So now I'm trying the other approach, but it really doesn't seem like a good idea.
If anyone here could provide some input on this, it would be great :)

Thanks,

Mariana

anairamzap’s picture

Status: Needs work » Needs review
StatusFileSize
new31.94 KB

Changing to "needs review" since a MR was provided applying most of the requested changes from last review.

Also in here I'm adding the re-rolled patch for 9.5.x that hopefully now passes the tests...

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs Review Queue Initiative

Verified the issue on D10.1 with a standard install following the steps in the issue summary.
Applying MR 3751 fixes the issue

Question for committer will new default value require upgrade paths? Imagine since this was a fatal error and no one could use the functionality the answer is no but want to make sure.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

Issue summary: View changes
Issue tags: +Needs followup

Tried to clean things up a bit.
Started by removing all patches now there is an MR.

Then assigned credits
Removed credits for simply rerolling

It looks like from #157 that this didn't work for datetime range fields?

Adding needs followups tag for #114 and #176

Updated the issue summary after reading all the comments 😩

Reviewing code next.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work

Left a review on the MR, thanks

lendude’s picture

Did the constructor property promotion stuff, added some questions, going to look at using a base class or trait which sounds like a good idea

lendude’s picture

Status: Needs work » Needs review

Think I got everything, lets see if it stays green

smustgrave’s picture

Status: Needs review » Needs work

Can the MR be updated for 11.x
Currently doesn't apply.

irsar’s picture

Even after applying the patch, views timestamp_formatter postupdate fails. We are trying to upgrade the site from 9.5 to 10.1.

tormi’s picture

StatusFileSize
new61.65 KB

Adding MR !3751 with the latest commit 3b362cc8 as a patch.

irsar’s picture

Thank you! This patch fixed the updb error. But I am getting this error "Drupal\Core\Entity\Query\QueryException: Entity queries must explicitly set whether the query should be access checked or not. See Drupal\Core\Entity\Query\QueryInterface::accessCheck(). in Drupal\Core\Entity\Query\Sql\Query->prepare() (line 141 of /app/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php)" when I load any page. Admins pages are working fine. Any idea on what's causing this error? I couldn't figure out what's causing this. Any help would be appreciated

tormi’s picture

@irsar, what @smustgrave said in #196. I'm also trying to figure out if there's a version I can use for the latest D10.

jon.lund’s picture

I am having trouble after updating to Drupal 10

When running the update script I get:

views module
Update timestamp_formatter
Failed: Drupal\Component\Plugin\Exception\PluginNotFoundException: The "calendar" plugin does not exist. Valid plugin IDs for Drupal\views\Plugin\ViewsPluginManager are: calendar_week, calendar_month, fullcalendar_view_display, unformatted_summary, default_summary, grid_responsive, opml, grid, default, table, rss, html_list, entity_reference, blazy in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /home/lhvxidmy/public_html/rise/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

I have tried removing and reinstalling the Calendar and Calendar_View Modules
I have tried uninstalling both as they are not used.
The Calendar View module will uninstall but the Calendar module will not with the following error:

The website encountered an unexpected error. Try again later.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "calendar" plugin does not exist. Valid plugin IDs for Drupal\views\Plugin\ViewsPluginManager are: calendar_week, calendar_month, fullcalendar_view_display, unformatted_summary, default_summary, grid_responsive, opml, grid, default, table, rss, html_list, entity_reference, blazy in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
Drupal\Core\Plugin\DefaultPluginManager->getDefinition('calendar') (Line: 16)
Drupal\Core\Plugin\Factory\ContainerFactory->createInstance('calendar', Array) (Line: 83)
Drupal\Component\Plugin\PluginManagerBase->createInstance('calendar') (Line: 821)
Drupal\views\Plugin\views\display\DisplayPluginBase->getPlugin('style') (Line: 897)
Drupal\views\ViewExecutable->initStyle() (Line: 877)
Drupal\views\ViewExecutable->getStyle() (Line: 476)
Drupal\views\Plugin\views\field\FieldPluginBase->defineOptions() (Line: 372)
Drupal\views\Plugin\views\field\EntityField->defineOptions() (Line: 143)
Drupal\views\Plugin\views\PluginBase->init(Object, Object, Array) (Line: 109)
Drupal\views\Plugin\views\HandlerBase->init(Object, Object, Array) (Line: 136)
Drupal\views\Plugin\views\field\FieldPluginBase->init(Object, Object, Array) (Line: 199)
Drupal\views\Plugin\views\field\EntityField->init(Object, Object, Array) (Line: 899)
Drupal\views\Plugin\views\display\DisplayPluginBase->getHandlers('field') (Line: 510)
Drupal\views\Entity\View->onDependencyRemoval(Array) (Line: 479)
Drupal\Core\Config\ConfigManager->callOnDependencyRemoval(Object, Array, 'module', Array) (Line: 342)
Drupal\Core\Config\ConfigManager->getConfigEntitiesToChangeOnDependencyRemoval('module', Array) (Line: 43)
Drupal\system\Form\ModulesUninstallConfirmForm->addDependencyListsToForm(Array, 'module', Array, Object, Object) (Line: 160)
Drupal\system\Form\ModulesUninstallConfirmForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('system_modules_uninstall_confirm_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 627)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

The site seems to work fine however I can not remove these errors.
I applied this patch with no effect on the errors.
I may be in the wrong place altogether. Any advice would be much appreciated.

carlos romero’s picture

Patch on fork

3751.patch

Tested ok drupal 11 and work fine.

carlos romero’s picture

Assigned: Unassigned » carlos romero
Status: Needs work » Reviewed & tested by the community
needs-review-queue-bot’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new90 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

foodslover’s picture

StatusFileSize
new11.43 KB

updates- please use the file of Comment#208

foodslover’s picture

foodslover’s picture

foodslover’s picture

StatusFileSize
new28.23 KB

Upon updating to Drupal 10.2.5, it became evident that the current patch (https://www.drupal.org/project/drupal/issues/2325899#comment-14900128) was no longer compatible. In response, I have refined the patch code to ensure its compatibility with the latest Drupal version, 10.2.5. My objective is to make this revised code advantageous for individuals utilizing Drupal 10.2.5 and in need of this particular functionality.

Drupal : 10.2.5
php: 8.2.15

socialnicheguru’s picture

@foodslover is there an interdiff?

idflood’s picture

StatusFileSize
new30.02 KB

I tried to reroll the merge request for drupal 10.2 but I'm not sure of the correct workflow, especially since the current merge request is based on the 10.1 branch.

Here is the commit I made: https://git.drupalcode.org/issue/drupal-2325899/-/commit/d665b876f6c1ab2...

And I'm attaching a patch which should hopefully work on 10.2.6

laura.gates’s picture

I applied #210 to 10.2.5 and my affected view allowed me to save without white screening in addition to adding and removing the date contextual filter.

I then updated to 10.2.6 and was able to do the same tests as I did for 10.2.5 without running into any issues.

percoction made their first commit to this issue’s fork.

percoction’s picture

StatusFileSize
new30.03 KB

Rerolled the patch against 10.3.x and pushed up a branch to the issue fork. Also added a static patch here

sseto’s picture

Confirm #213 worked!

cmarcera’s picture

#213 did not resolve the "The "date" plugin does not exist." error in my clean Drupal 10.4.0 install. I am still unable to select 'Current date' as the default for a contextual filter.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "date" plugin does not exist. Valid plugin IDs for Drupal\views\Plugin\ViewsPluginManager are: node, taxonomy_tid, user, current_user, raw, query_parameter, fixed in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /code/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

My current workaround is using Views Argument Token with the [current-date] token. Glad to have this solution but hope to be able to use the core functionality at some point.

xjm’s picture

Adding credit for the triage as per @cilefen in #64.

joelpittet made their first commit to this issue’s fork.

joelpittet’s picture

Assigned: carlos romero » Unassigned

I rerolled, diffed the diffs after — no changes other than context lines (and index hashes). And diffed the MR 3751 against #213

Trying to help this along... next I plan to review the unresolved comments, so leaving as Needs Work.

I will hide the other MRs to keep the focus on that one.

joelpittet changed the visibility of the branch 2325899-10.3.x-refactor to hidden.

joelpittet’s picture

Status: Needs work » Needs review

Ok setting back to Needs Review, tests should be passing again.

lendude’s picture

Went through this again, looks great, did some more manual testing with it and that also works as expected. I do think we still need to address the 'Needs followup' tag? I think it is still relevant and I don't think any follow ups were ever created.

joelpittet’s picture

Issue summary: View changes
Issue tags: -Needs followup

Took care of the follow-ups needed. Just copied the comments mostly to capture the request, hope that is sufficient to unblock this.

#3555139: Generalize "Current entity created/updated time" via plugin deriver (all entity types)
#3555138: Default date argument handlers: correct cacheability (contexts, tags, max-age)

joelpittet’s picture

Issue summary: View changes

RE #157 from @solide-echt
That Postgres error came from parsing dates with a “T” in the middle (the way datetime range fields store them) using a pattern that expected a space. The current code already quotes the “T” correctly in the format string, so that mismatch can’t happen now. I don’t see anything else in this MR that would bring it back, so I think this is resolved.

Edit: I am also maintaining (and trying to bring back to life) the calendar module.

lendude’s picture

Title: UI fatal caused by views argument handlers no longer can provide their own default argument handling » UI fatal caused by views argument handlers no longer being able to provide their own default argument handling
Status: Needs review » Reviewed & tested by the community

Follow ups look good, looks ready.

alexpott’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed 78ddb1a77b8 to 11.x and 6d419294f32 to 11.3.x. Thanks!

Well done for getting this one over the finish line.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 6d419294 on 11.3.x
    Issue #2325899 by casey, dawehner, lendude, alexpott, webflo, geertvd,...

  • alexpott committed 78ddb1a7 on 11.x
    Issue #2325899 by casey, dawehner, lendude, alexpott, webflo, geertvd,...

Status: Fixed » Closed (fixed)

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