We currently have all the date argument plugins in the node module, E.g. CreatedYear, CreatedMonth etc... but these are used currently in node, user, and comment module. This just doesn't seem right, especially as the plugin IDs are prefixed with 'node_'. Let's move them back to views.

Comments

dawehner’s picture

Awesome change!

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/CreatedFullDate.phpundefined
@@ -2,22 +2,20 @@
+ * Definition of Drupal\views\Plugin\views\argument\CreatedFullDate.

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/argument/CreatedYear.phpundefined
@@ -2,21 +2,19 @@
+ * Definition of Drupal\views\Plugin\views\argument\CreatedYear.

We should fix all or none of them if possible.

damiankloip’s picture

StatusFileSize
new1.13 KB
new13.03 KB

Thanks! Yeah, we should fix all of them, I thought I got them, but missed two! :)

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Awesome, with the assumption that we will add module = 'views' later

damiankloip’s picture

Yeah, we need to decide how we deal with this for all plugins. I would vote that we just don't have this on any? As the Plugin manager adds views as a default but then I guess you could also argue that it is clearer if it's in the annotation...

olli’s picture

Is it ok to remove the prefix or should it be "views_"? Maybe it's me, but "created" looks little odd outside/without node.

damiankloip’s picture

Well, we don't prefix any of our own plugins. So I think how our is now is good.

damiankloip’s picture

Well, we don't prefix any of our own plugins. So I think how it is now is good.

olli’s picture

Right, didn't know that, thanks.

tim.plunkett’s picture

Status: Reviewed & tested by the community » Needs work

In #1879496: Do we need to worry about plugin ID collisions? we're talking about namespacing the plugins.

In addition, the fact that the "module" key can be left off for Views is a hack that we should remove.

So let's add 'views_' to the ones we're moving there, and not remove the module key.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new13.19 KB
new13.04 KB

I'm not sure about the prefixing just yet, as nothing is resolved in that issue. So here's a patch that adds just the module key to all annotations, and another one that also adds the views_ prefix to the plugin id.

I'm not sure how it's a hack that we default to a 'views' module key? Just like any other default for a definition really, no? :)

dawehner’s picture

Just to be more consistent I would prefer the first patch and adapt if we decide something else later.

damiankloip’s picture

Yeah, me too.

tim.plunkett’s picture

Well I definitely vote for the prefix one. I think it'll be more work to add the prefix later, and less work to remove it. But that's just me.

And the problem with the default of 'views' is that if a plugin author forgets the key, it won't blow up on discovery. And because the views module will be loaded, but not always their module, that module_exists call won't happen, and weird bugs will ensue. But that is a separate issue.

damiankloip’s picture

ok, but I'm not sure we actually really use the module key. Except maybe in views_theme? Not sure how this will, if it will affect anything off the top of my head. It makes sense though, I'm happy this will be consistent.

tbh, I just want to get this in, which is actually the moving of the files, rather than discuss these other points, it seems like maybe these should be done elsewhere. Even if we flip a coin to decide which patch in #10 should go, I am happy :).

dawehner’s picture

There seems to be only one valid way to determinate the winner ;) http://www.googlefight.com/index.php?lang=en_GB&word1=prefix&word2=module

Seriously I don't care much, as long it's not the current name.

damiankloip’s picture

Does someone want to decide which one to use here?! googlefight says use the views_ prefix ....

olli’s picture

Hey, lets do this without views_ prefix and googlefight in #1879496: Do we need to worry about plugin ID collisions?.

I'd be even fine with a date_ prefix: date_day, date_week, ...

dawehner’s picture

Just created an issue to test all these files: #1934558: Create a test for views date handlers

dawehner’s picture

It seems to be that we don't really have a standard in core, so changing our behaviour and have a inconsistent piece seems worse,
so I would vote for the non-prefix variant.

damiankloip’s picture

StatusFileSize
new13.36 KB

ok, let's settle on that then. I think if we change the plugin ids, we do this for all of them when/if there is a standard. Rerolled.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Yeah I agree!

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Just a question. Is there anything about this that's specific to a created date/time? Isn't it more dealing with timestamps as a general concept..? And if so, it seems like that would be a better name, no?

dawehner’s picture

Yeah indeed, YearDate would work as well. It might make sense to get in the tests first, as it feels wrong to work on not tested code.

#1934558: Create a test for views date handlers

dawehner’s picture

StatusFileSize
new15.32 KB

Renamed all the plugins and files.

webchick’s picture

Status: Needs review » Needs work

Cool, just committed that one. That probably means this needs a re-roll again (sorry!)

Also:

+++ b/core/modules/comment/comment.views.incundefined
@@ -215,7 +215,7 @@ function comment_views_data() {
-      'id' => 'node_created_day',
+      'id' => 'created_day',

Careful. :D

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new3.3 KB
new16.21 KB

Forgot to rename the created_day one. Sadly you didn't pushed the commit yet, so this is just a rerole for your great review!

Status: Needs review » Needs work

The last submitted patch, drupal-1893906-26.patch, failed testing.

dawehner’s picture

Status: Needs work » Needs review
StatusFileSize
new6.01 KB
new19.38 KB

Good to know that the tests fail if we move things around.

olli’s picture

Status: Needs review » Needs work

This looks great now, but does not apply anymore.

We left a todo "remove the node dependency once the handlers are moved to views" in ArgumentDateTest. Can that be fixed here?

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new705 bytes
new19.53 KB

Thanks! definitely we can remove that now :)

dawehner’s picture

Oh nice cleanup!

olli’s picture

I think user module dependency came from node so we could drop all of ArgumentDateTest::$modules and ArgumentDateTest::setUp().

dawehner’s picture

StatusFileSize
new924 bytes
new19.83 KB

Yeah you are right.

damiankloip’s picture

Awesome. I totally didn't think about that!

olli’s picture

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

#33: drupal-1893906-33.patch queued for re-testing.

xjm’s picture

Issue tags: +Quick fix
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Cool, that's much better!

Committed and pushed to 8.x. Thanks!

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