Issue Summary

Incorrect way to fetch view id in hook_views_query_alter in views.api.php

https://api.drupal.org/api/drupal/core%21modules%21views%21views.api.php...

$view->name == 'my_view'

should be changed to

$view->storage->id() == 'my_view'

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug
Issue priority Not critical because minor
Unfrozen changes Unfrozen because it only changes code to improve DX by making ViewExecutable more in line with View objects (and other entity types)
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

abhishek-anand’s picture

abhishek-anand’s picture

Status: Active » Needs review
jhodgdon’s picture

Issue tags: +VDC

Can you just use $view->id() rather than $view->storage->id()?

dawehner’s picture

Can you just use $view->id() rather than $view->storage->id()?

No you can't, $view is no the entity but the view executable which contains the logic of executing a view.

jhodgdon’s picture

Ah, OK. Then is this RTBC dawehner?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I'm drunken and fine with that

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Is it not worth adding a method to ViewExecutable called id() that just delegates to the $this->storage->id()?

vijaycs85’s picture

Here we go.

dawehner’s picture

+++ b/core/modules/views/src/ViewExecutable.php
@@ -446,6 +446,17 @@ public function __construct(ViewStorageInterface $storage, AccountInterface $use
+   * @return string|int|null

Why should it ever be an int?

jhedstrom’s picture

Status: Needs review » Needs work

Setting to needs work based on #9. I don't think it ever would return an int.

Also:

+++ b/core/modules/views/src/ViewExecutable.php
@@ -446,6 +446,17 @@ public function __construct(ViewStorageInterface $storage, AccountInterface $use
    * @todo.

While we're here, can we update this '@todo' to an actual docblock comment?

jhodgdon’s picture

Component: documentation » views.module

Not docs any more. :)

mrjmd’s picture

Status: Needs work » Needs review
FileSize
1.54 KB
682 bytes

Fixes from #10 .

jhedstrom’s picture

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

I think this now addresses #7.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Indeed.

Committed and pushed to 8.0.x. Thanks!

  • webchick committed 74128e4 on 8.0.x
    Issue #2388941 by vijaycs85, mrjmd, abhishek-anand, dawehner, alexpott:...

Status: Fixed » Closed (fixed)

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