Comments

miiimooo created an issue. See original summary.

jhodgdon’s picture

Version: 8.0.x-dev » 8.2.x-dev
Issue summary: View changes
Issue tags: +needs backport to 8.1.x, +needs backport to 8.0.x, +Novice

Thanks for the issue! Marking Novice and fixing the issue summary slightly. Also this should be fixed in 8.2 and then it should be applied to the other 8.x versions (probably the same patch will apply to all).

johnrosswvsu’s picture

Status: Active » Needs review
StatusFileSize
new1.77 KB

Hi,

I have created a patch to address the request, but I have also found other instances of wrong use for $view->name.

There is one in hook_views_post_build and another in hook_views_pre_execute.

Please review.

Thanks.

PS: Patch also works for 8.0.x and 8.1.x.

jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good! Thanks for fixing the other instances of $view->name in the same file. That is a perfectly excellent expansion of the issue scope.

johnrosswvsu’s picture

I grep in the entire code base and found no other instances except in this file. Please let me know should you find more.

johnrosswvsu’s picture

Hi @jhodgdon,

I have found in https://api.drupal.org/api/drupal/core%21modules%21views%21src%21Views.p... the following documentaton:

views object (containing $exclude_view->storage->name and $exclude_view->current_display)

Does this case apply as well? Looked around in the codes and can see that in the following for example:
https://api.drupal.org/api/drupal/core%21modules%21views%21src%21Plugin%...

Line 162 uses: if ($view_id && $this->view->storage->id() != $view_id) {

I am not particularly sure about this one so I need anyone to check this.

alexpott’s picture

I can't make my mind up about the scope of this issue - whether or not to fix all the things in views.api.php that are broken... for example hook_field_views_data_views_data_alter has $entity_type_id = $field->entity_type; which should be $entity_type_id = $field->entityTypeId(); and I think $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); is wrong too. In other places $view->query->tables - the tables property does not exist as far as I can see. Same for $view->query->table_queue. And hook_views_query_alter also needs work.

jhodgdon’s picture

Status: Reviewed & tested by the community » Needs review

Well that is a good question, and probably not a novice issue if the scope is "Fix all the outdated stuff in views.api.php". Your call... I have been getting the scope wrong on issues lately and am not making this decision.

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

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now 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.

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

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now 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.

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.

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.

sk33lz’s picture

Some of these fixes have already been changed in previous commits it seems. I can't speak to the scope of this issue, but I re-rolled #6 to get this patch ready in it's current state for 8.6.x.

leoneldiaz02’s picture

Issue tags: +Nashville2018

I tested the patch, and the patch worked correctly.

leoneldiaz02’s picture

i also reviewed the patch and i saw that they were using the old coding standards for array and replaced for the new standard.

sk33lz’s picture

Thanks for the clarification on that. I saw the array was done differently between versions and I was unsure about that change.

bdlangton’s picture

This is a weird case because the original issue is already fixed in 8.6.x. The latest patch fixes something different. I don't see anything wrong with it, but just wanted to point that out.

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.

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.

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.

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.

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.

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.

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.

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.

smustgrave’s picture

Triggering a 9.5 build. Once that's complete I'll RTBC

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Looks good.

avpaderno’s picture

The issue summary needs to be updated; it doesn't describe what the patch is effectively fixing.

(I am changing two issue tags, since this patch won't be back-ported to branches that are now unsupported.)

smustgrave’s picture

Issue summary: View changes
smustgrave’s picture

@apaderno updated the summary if that helped.

avpaderno’s picture

Status: Reviewed & tested by the community » Needs work

The documentation for hook_views_pre_view() doesn't contain any reference to $name nor name(). That is not even what the patch is changing, since it changes the documentation comment for the Views::getViewsAsOptions() method, which is using the following documentation comment.

  /**
   * Returns an array of view as options array, that can be used by select,
   * checkboxes and radios as #options.
   *
   * @param bool $views_only
   *   If TRUE, only return views, not displays.
   * @param string $filter
   *   Filters the views on status. Can either be 'all' (default), 'enabled' or
   *   'disabled'
   * @param mixed $exclude_view
   *   View or current display to exclude.
   *   Either a:
   *   - views object (containing $exclude_view->storage->name and $exclude_view->current_display)
   *   - views name as string:  e.g. my_view
   *   - views name and display id (separated by ':'): e.g. my_view:default
   * @param bool $optgroup
   *   If TRUE, returns an array with optgroups for each view (will be ignored for
   *   $views_only = TRUE). Can be used by select
   * @param bool $sort
   *   If TRUE, the list of views is sorted ascending.
   *
   * @return array
   *   An associative array for use in select.
   *   - key: view name and display id separated by ':', or the view name only.
   */
  public static function getViewsAsOptions($views_only = FALSE, $filter = 'all', $exclude_view = NULL, $optgroup = FALSE, $sort = FALSE) {
    // …
  }

The last attached patch contains the following lines.

--- a/core/modules/views/src/Views.php
+++ b/core/modules/views/src/Views.php
@@ -285,7 +285,7 @@ public static function getDisabledViews() {
    * @param mixed $exclude_view
    *   View or current display to exclude.
    *   Either a:
-   *   - views object (containing $exclude_view->storage->name and $exclude_view->current_display)
+   *   - views object (containing $exclude_view->storage->id() and $exclude_view->current_display)
    *   - views name as string:  e.g. my_view
    *   - views name and display id (separated by ':'): e.g. my_view:default
    * @param bool $optgroup

The issue summary and the issue title must be updated.

avpaderno’s picture

$exclude_view->storage->id() seems to still be not correct, since neither the Views class nor the DisplayPluginBase class seems to have a $storage property.

avpaderno’s picture

Furthermore, if the purpose of this issue is fixing the documentation comment for Views::getViewsAsOptions(), there are other fixes to apply.
For example, instead of views object, it should use Views object; it should not use colons followed by e.g. but a comma followed by for example; it should not use display id but display ID.

pradhumanjain2311’s picture

Assigned: Unassigned » pradhumanjain2311
WagnerMelo’s picture

Status: Needs work » Needs review
StatusFileSize
new1.39 KB
new38.27 KB

Hello, i worked in this issue, and did the changes asked by @apaderno on #33.
And about the comment #32 from @apaderno too, talking about the $exclude_view->storage->id(), i think that this way as are, its right because storage is a service from core, and is used in the same file at line line 325.

And sorry @pradhumanjainOSL, but i don't know if you know, but usually in core issues, we should don't assigne to ourself, only send the pathc, and made comments.
this link below explain better about that.
https://www.drupal.org/docs/develop/issues/fields-and-other-parts-of-an-...

smustgrave’s picture

To help compare what was changed can you provide an interdiff please

asha nair’s picture

Applied patch in #35 successfully on 9.5x-dev. The patch has done the changes mentioned in #33 and changed '$view->name' to '$view->id()'.

pradhumanjain2311’s picture

Assigned: pradhumanjain2311 » Unassigned

@WagnerMelo I m new to contribution. Thanks for giving me the information about not assigning the core issues.

WagnerMelo’s picture

StatusFileSize
new1.27 KB

Sorry about that, here are the interdiff @smustgrave.

NP @pradhumanjainOSL we are here to learn together.

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.

sahil.goyal’s picture

Hi, Thanx @WagnerMelo for the patch, As you corrected the documentation as per the comment #32 and #33, it looks great and relatable, I have tried to applied it successfully on 10.1.x it applied cleany, so it can be compatible for 10.1.x.

sahil.goyal’s picture

Status: Needs review » Reviewed & tested by the community

Moving to RTDC for now till further update.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/views/src/Views.php
@@ -287,9 +287,9 @@ public static function getDisabledViews() {
+   *   - views name as string,for example my_view
+   *   - views name and display ID (separated by ':'), for example my_view:default

I think the examples should be in single quotes and if we're changing these lines we should break the lines on 80 chars.

I would expect the docblock to end up looking something like:

   * @param \Drupal\views\ViewExecutable|string $exclude_view
   *   View or current display to exclude.
   *   Either a:
   *   - View executable object
   *   - View name, for example: 'my_view'
   *   - View name and display ID separated by ':', for example: 'my_view:page'
anchal_gupta’s picture

StatusFileSize
new1.38 KB
new843 bytes

I have uploaded the patch
Addressed #43 point.

anchal_gupta’s picture

Status: Needs work » Needs review
alexpott’s picture

Status: Needs review » Needs work

@Anchal_gupta how about fixing the 80 chars issue and the @param types too - as per #43.

pradhumanjain2311’s picture

Status: Needs work » Needs review
StatusFileSize
new1.5 KB
new833 bytes

Try to address comment #43.

avpaderno’s picture

Just a small change: The first line is missing a space after the comma and before for example..

+   *   - views name,for example 'my_view'
+   *   - views name and display ID separated by ':', for example 'my_view:page'
pradhumanjain2311’s picture

StatusFileSize
new1.5 KB
new635 bytes

Try to address #48.

avpaderno’s picture

Status: Needs review » Reviewed & tested by the community

The patch fixes also the line longer than 80 characters. This is RTBTC.

  • alexpott committed d887580 on 10.1.x
    Issue #2689923 by pradhumanjainOSL, johnrosswvsu, WagnerMelo,...
alexpott’s picture

Version: 10.1.x-dev » 9.4.x-dev
Status: Reviewed & tested by the community » Fixed

Backported to 9.4.x as this is a docs bug fix.

Committed and pushed d88758034c to 10.1.x and 4467280292 to 10.0.x and 9ebe2b579b to 9.5.x and 6f71312b3f to 9.4.x. Thanks!

  • alexpott committed 4467280 on 10.0.x
    Issue #2689923 by pradhumanjainOSL, johnrosswvsu, WagnerMelo,...

  • alexpott committed 9ebe2b5 on 9.5.x
    Issue #2689923 by pradhumanjainOSL, johnrosswvsu, WagnerMelo,...

  • alexpott committed 6f71312 on 9.4.x
    Issue #2689923 by pradhumanjainOSL, johnrosswvsu, WagnerMelo,...

Status: Fixed » Closed (fixed)

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