Found in #2502151: Add a shortcut block view

Problem/Motivation

A bunch of argument_default plugins have an incorrect schema.

  • views.argument_default.current_user
  • views.argument_default.node

views.argument_default.query_parameter is missing schema entirely.

Proposed resolution

Introduce views.argument_default.*

Remove views.argument_default.current_user and views.argument_default.node.

Define schema for views.argument_default.query_parameter.

Remaining tasks

None.

User interface changes

None.

API changes

None.

Data model changes

None.

Comments

tstoeckler created an issue. See original summary.

tstoeckler’s picture

Issue tags: +Novice
sagar ramgade’s picture

Status: Active » Needs review
StatusFileSize
new1.04 KB

Patch attached fixes the proposed solution.

dawehner’s picture

+++ b/core/modules/node/config/schema/node.views.schema.yml
@@ -67,11 +67,8 @@ views.argument.node_vid:
 views.argument_default.node:
-  type: sequence
+  type: mapping
   label: 'Content ID from URL'
-  sequence:
-    type: string
-    label: 'Nid'
 

+++ b/core/modules/user/config/schema/user.views.schema.yml
@@ -53,7 +53,7 @@ views.argument_default.user:
 views.argument_default.current_user:
-  type: boolean
+  type: mapping
   label: 'User ID from logged in user'
 
 views.argument_default.node:

IMHO those expose any kind of configuration so why can't we just drop those entries entirely?

tstoeckler’s picture

Re @dawehner, I was thinking the same, but if we don't declare e.g. views.argument_default.node then TypedConfigManager will fall back to undefined for the respective default_argument_options key in the config which will then fail config schema validation.

Not sure if we want to tackle the missing schema of views.argument_default.query_parameter here as well, or if we want a separate issue for that.

dawehner’s picture

According to our discussion I think we should have views.argument_default.* and then remove the other pointless ones.

dawehner’s picture

Status: Needs review » Needs work
snehi’s picture

Assigned: Unassigned » snehi
snehi’s picture

Assigned: snehi » Unassigned
anil280988’s picture

Hi tstoeckler/dawehner,
Could you suggest if "argument_default" in other modules also needed to be corrected.

dawehner’s picture

No these are the only ones needed in Drupal core.

anil280988’s picture

Status: Needs work » Needs review
StatusFileSize
new1.04 KB

Reuploading the patch, though already created by Sagar Ramgade.

dawehner’s picture

Status: Needs review » Needs work
himanshugautam’s picture

new patch considering comment 10612250

himanshugautam’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 14: schema_of_argument_default_plugins-2623568.patch, failed testing.

himanshugautam’s picture

StatusFileSize
new1.13 KB
vg3095’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 17: schema_of_argument_default_plugins-2623568-17.patch, failed testing.

sidharthap’s picture

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

Updated patch.

dawehner’s picture

Status: Needs review » Needs work

#6 is still not addressed :(

dbjpanda’s picture

Assigned: Unassigned » dbjpanda
sidharthap’s picture

Thank you @dawehner for reviewing it. is #6 says about to remove all instance of views.argument_default.* from user.views.schema.yml ?

dawehner’s picture

No, its about adding a views.argument_default.* entry

tstoeckler’s picture

Issue tags: +DrupalBCDays
tstoeckler’s picture

@dbjpanda: Oops missed that this was assigned before tagging it for the sprint on the weekend, sorry. Are you still working on this?

dbjpanda’s picture

Assigned: dbjpanda » Unassigned
tstoeckler’s picture

Thanks @dbjpana! Hopefully we will find someone on the weekend to work on this so we can finally get this done.

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.

yanniboi’s picture

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

Ok, so I'm not sure if this is right, but I have added views.argument_default.* and removed views.argument_default.node and views.argument_default.current_user.

Have I missed anything?

yanniboi’s picture

I added a test. Not sure if there is a better way to test, I'm open to suggestions.

yanniboi’s picture

StatusFileSize
new2.09 KB

Ahh that was a bad test_no_fix patch... Ignore that one for this one.

The last submitted patch, 31: schema_of_argument_default_plugins-2623568-31.patch, failed testing.

yanniboi’s picture

StatusFileSize
new3.67 KB

The last submitted patch, 31: test_no_fix.patch, failed testing.

The last submitted patch, 32: test_no_fix.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 34: schema_of_argument_default_plugins-2623568-34.patch, failed testing.

yanniboi’s picture

Status: Needs work » Needs review
StatusFileSize
new3.66 KB

Man apologies all round, I am doing badly with my patches today :/

Status: Needs review » Needs work

The last submitted patch, 38: schema_of_argument_default_plugins-2623568-38.patch, failed testing.

claudiu.cristea’s picture

dawehner’s picture

This looks quite nice ... do you think some kind of test would be though helpful here?

claudiu.cristea’s picture

Did we tested other default arguments? Have no idea.

dawehner’s picture

Sure, we have \Drupal\user\Tests\Views\ArgumentDefaultTest for example.

dawehner’s picture

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

It is always good to add some form of tests :)

claudiu.cristea’s picture

Issue summary: View changes
Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new5.33 KB
new3.33 KB

Added test for query parameter. The others are tested.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Thanks a lot @claudiu.cristea. I know writing tests can be painful sometimes, but its worth on the longrun.

xjm’s picture

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

Looks like this would need an upgrade path, no?

claudiu.cristea’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs upgrade path

@xjm, we are not changing any configuration object (view) here we're only providing schema (data definition) for existing views config objects. Nothing will change in the way they are structured. New configs/views will have the same structure as the existing ones.

I'm setting this back to RTBC for the above reasons but if you feel I'm wrong, feel free to set it back to NW.

xjm’s picture

Assigned: Unassigned » alexpott

Hmm but if it doesn't need an upgrade path then how come our existing schema tests didn't catch this? Or if the schema is wrong, then how can all config saved with the wrong schema be right?

It is totally possible I am confused about something, though, so leaving at RTBC and assigning to alexpott.

dawehner’s picture

Hmm but if it doesn't need an upgrade path then how come our existing schema tests didn't catch this? Or if the schema is wrong, then how can all config saved with the wrong schema be right?

We had no single instance of code using that plugin, so there was nothing to be validated. We added a test here.

alexpott’s picture

Yep there's no upgrade path necessary here because the change should result in no config changes. If the new schema was enforcing a data type other than string then an upgrade path would be necessary.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/node/config/schema/node.views.schema.yml
@@ -66,13 +66,6 @@ views.argument.node_vid:
-views.argument_default.node:
-  type: sequence
-  label: 'Content ID from URL'
-  sequence:
-    type: string
-    label: 'Nid'

+++ b/core/modules/user/config/schema/user.views.schema.yml
@@ -49,10 +49,6 @@ views.argument_default.user:
-views.argument_default.current_user:
-  type: boolean
-  label: 'User ID from logged in user'

These two cases are not tested. In the test view - which appears to be testing a node type argument.

Also please make test only patches.

claudiu.cristea’s picture

Status: Needs work » Needs review
StatusFileSize
new5.59 KB
new3.58 KB
new1.21 KB

Correct me if I'm wrong:

  1. views.argument_default.node is tested in \Drupal\views\Tests\Plugin\ArgumentDefaultTest::testArgumentDefaultNode()
  2. views.argument_default.current_user is tested in \Drupal\user\Tests\Views\ArgumentDefaultTest::test_plugin_argument_default_current_user()

Improved the test to check also the fallback. Added "test only" patch.

Status: Needs review » Needs work

The last submitted patch, 53: 2623568-53-test-only.patch, failed testing.

claudiu.cristea’s picture

Status: Needs work » Needs review

The test-only failed. The patch passed.

dawehner’s picture

core/modules/views/tests/modules/views_test_config/test_views/views.view.test_argument_default_node.yml uses

          default_argument_type: node
          default_argument_options: {  }

and core/modules/user/tests/modules/user_test_views/test_views/views.view.test_plugin_argument_default_current_user.yml uses no default_argument_options at all, which is why this schema was never triggered.

xjm’s picture

Assigned: alexpott » Unassigned

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

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

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

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I hope #2623568-56: Config schema of argument_default plugins is incorrect explains why the test coverage is good enough. We cannot enlarge the test coverage, unless we basically want to retest schema validation as a concept.

alexpott’s picture

Version: 8.2.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 4fc22ad and pushed to 8.3.x. Thanks!

Whilst there is no necessary upgrade path for 8.3.x because caches will be cleared we'd need a specific function for 8.2.x so I've not committed this to 8.2.x. If we want to fix this there then we need to ensure a cache flush occurs.

claudiu.cristea’s picture

Version: 8.3.x-dev » 8.2.x-dev
Status: Fixed » Needs review
StatusFileSize
new6.06 KB
new480 bytes

Here's the cache rebuild.

  • alexpott committed 4fc22ad on 8.3.x
    Issue #2623568 by yanniboi, claudiu.cristea, himanshugautam, anil280988...
claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

The patch has been once reviewed,. I don't know if needs a new review for that 8.2.x addition. I'm tentatively RTBC it.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 6663917 and pushed to 8.2.x. Thanks!

I've also committed the interdiff to 8.3.x since I'm not too wild about 8.3.x missing an update that is in 8.3.x. Committed 04a771a and pushed to 8.3.x. Thanks!

  • alexpott committed 04a771a on 8.3.x
    Issue #2623568 by yanniboi, claudiu.cristea, himanshugautam, anil280988...

  • alexpott committed 6663917 on 8.2.x
    Issue #2623568 by yanniboi, claudiu.cristea, himanshugautam, anil280988...

Status: Fixed » Closed (fixed)

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