Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning by checking whether key is set. #909

Merged

Conversation

jasonhildebrand
Copy link

What does this Pull Request do?

We are adding the drupal/flag module to our Islandora instance to allow end users to create bookmarks (favourites) for repository items.

We see the warning "Warning: Undefined array key "plugin_id" in islandora_preprocess_views_view_table() (line 523 of modules/contrib/islandora/islandora.module)" when accessing a view that the drupal/flag module provides.

This PR eliminates this warning by checking for the array key using isset() before trying to use it.

How should this be tested?

The code modified is related to the "integer weight field" functionality. Test that nothing is broken by testing the "Re-order children" page.

Interested parties

@Islandora/committers

@rosiel rosiel self-assigned this Nov 9, 2022
Copy link
Member

@rosiel rosiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to recreate your error, and I'm having trouble creating a view that uses a table, but doesn't have options['plugin_id']. Can you send me some hints, or a screenshot?

And/or, can you test if $field->getPluginId() works with your view? It would be a nicer way to do this if it solves the problem.

Thanks!

@jasonhildebrand
Copy link
Author

Thanks, @rosiel for looking at this.

Yes, $field->getPluginId() works and is cleaner. It eliminates the warning and I tested that drag and drop sorting still works as expected. I have updated the PR.

In terms of reproducing the warning, I am attaching a few screenshots of my view where it occurs:

bookmarks-view
bookmarks-view-table-settings

@seth-shaw-asu seth-shaw-asu requested a review from rosiel November 30, 2022 18:38
@jasonhildebrand
Copy link
Author

As mentioned, we are using the drupal/flag module to allow end users to create bookmarks (favourites) for repository items. This view is what the drupal/flag module provides - we have made minimal changes if any.

@jasonhildebrand
Copy link
Author

I don't think this makes a difference, but I am using PHP 8.0.

Copy link
Member

@rosiel rosiel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replicated the error, and this fixed it.

@rosiel rosiel merged commit f71f6dc into Islandora:2.x Dec 1, 2022
rosiel pushed a commit to rosiel/islandora that referenced this pull request Dec 14, 2022
* Fix warning by checking whether key is set.

* Adjust plugin check in integer-weight views hook.
rosiel pushed a commit to rosiel/islandora that referenced this pull request Feb 22, 2023
* Fix warning by checking whether key is set.

* Adjust plugin check in integer-weight views hook.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants