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

Custom admin UI component grid breaks when collection is not AbstractDb #32292

Open
1 of 5 tasks
zaximus84 opened this issue Feb 25, 2021 · 16 comments
Open
1 of 5 tasks
Labels
Area: Framework Component: Framework/View Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@zaximus84
Copy link

zaximus84 commented Feb 25, 2021

Preconditions (*)

  1. Install Magento 2.4.2
  2. Build a custom admin grid using UI components and a data provider.
  3. Use a collection for your data provider that extends Magento\Framework\Data\Collection, but not Magento\Framework\Data\Collection\AbstractDb.

Steps to reproduce (*)

  1. Attempt to view the grid in admin.

Expected result (*)

  1. The grid displays without error.

Actual result (*)

  1. This error occurs: Call to undefined method {custom collection class}::getSelect()
    Exception in /var/www/html/vendor/magento/framework/View/Element/UiComponent/DataProvider/FilterPool.php:45

This issue was introduced in 2.4.2 due to changes in the FilterPool class. See this commit: 2638e0f

The applyFilters method type hints that the $collection argument can be an instance of Magento\Framework\Data\Collection or Magento\Framework\Data\Collection\AbstractDb, but the method executes operations that are only guaranteed on AbstractDb (i.e. getSelect).

Any AbstractDb operations should only be executed after some sort of type check to prevent errors for collections that don't extend that abstract. As an example, I built an admin grid that populates data from a remote API and has no need of a database select object, so it doesn't extend AbstractDb.


Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Feb 25, 2021

Hi @zaximus84. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, please, review the Magento Contributor Assistant documentation.

Please, add a comment to assign the issue: @magento I am working on this


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@hostep
Copy link
Contributor

hostep commented Mar 4, 2021

The exact same problem was discovered in baldwin-agency/magento2-module-url-data-integrity-checker#16

If you wrap that contents of that applyFilters method in something like the following, it no longer crashes, but I have no idea if that would be considered a good solution:

public function applyFilters(Collection $collection, SearchCriteriaInterface $criteria)
{
    if (method_exists($collection, 'getSelect')) {
        ...
    }
}

But the type checking on AbstractDb could be a solution as well...

@engcom-Golf: what do you think might be a good solution here?

@myAlexT
Copy link

myAlexT commented Mar 17, 2021

Hello. Faced this issue when going to Report->Braintree Settlement grid. And I can reproduce this problem on a clean Magento 2.4.2 installation!

@stale
Copy link

stale bot commented Jun 2, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 14 days if no further activity occurs. Is this issue still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? Thank you for your contributions!

@stale stale bot added the stale issue label Jun 2, 2021
@hostep
Copy link
Contributor

hostep commented Jun 2, 2021

Issue is definitely not stale, leaving a comment to not close it.

@Den4ik: can we get somebody to review this and propose a solution? I'm willing to create a PR for this if a good solution can be proposed, thanks!

We needed to add a silly workaround to keep our module working on 2.4.2 because of this bug: https://github.com/baldwin-agency/magento2-module-url-data-integrity-checker/pull/17/files

@stale stale bot removed the stale issue label Jun 2, 2021
@engcom-Echo engcom-Echo self-assigned this Jun 2, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jun 2, 2021

Hi @engcom-Echo. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@myAlexT
Copy link

myAlexT commented Jun 3, 2021

image
I confirm that the error is still valid. All magento 2.4.2 stores have this bug when going to Report->Braintree Settlement grid.

@engcom-Echo engcom-Echo added Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it Issue: needs update Additional information is require, waiting for response labels Jun 4, 2021
@m2-community-project m2-community-project bot moved this from Ready for Confirmation to Needs Update in Issue Confirmation and Triage Board Jun 7, 2021
@engcom-Echo
Copy link
Contributor

Hi @zaximus84 ,

On step 3 , Can you please specify which collection you used for the data provider.

Thanks

@hostep
Copy link
Contributor

hostep commented Jun 7, 2021

Hi @engcom-Echo

If you need an easy way to reproduce: install version 1.2.0 of this open source module on Magento 2.4.1.
Then in the backoffice of Magento, go to Catalog > Data Integrity Checker and click on one of the 4 submenu's and notice that the page doesn't crash.
Now do the same on Magento 2.4.2 and notice that those pages now suddenly start crashing.

The problem is triggered from a custom collection that is used by a grid datasource and inherits from Magento\Framework\Data\Collection.

The change in 2638e0f#diff-589c211efb97038b69ed19a3bbfa83af013eacf4c8f218cb8f3705aaef675543 to the applyFilters method introduced the problem in Magento 2.4.2. The new code assumes that $collection always has a getSelect method. But $collection can be either a Magento\Framework\Data\Collection\AbstractDb or a Magento\Framework\Data\Collection.
For the AbstractDb, it indeed has a getSelect method, see here. But the Collection class - or its parents - does not have a getSelect method.
So the code that was introduced in 2638e0f#diff-589c211efb97038b69ed19a3bbfa83af013eacf4c8f218cb8f3705aaef675543 will crash for all instances of $collection that aren't an AbstractDb.

Hope this makes the problem even more clearer then it already was.

@Den4ik Den4ik added Component: Framework/View Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. labels Jun 26, 2021
@m2-community-project m2-community-project bot added this to Dev In Progress in High Priority Backlog Jun 26, 2021
@m2-community-project m2-community-project bot moved this from Dev In Progress to Ready for Development in High Priority Backlog Jun 26, 2021
@sumeshkumar577
Copy link

@magento give me 2.4-develop instance - upcoming 2.4.x release

@magento-deployment-service
Copy link

Hi @sumeshkumar577. Thank you for your request. I'm working on Magento instance for you.

@engcom-Lima engcom-Lima added Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Framework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 25, 2021
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-1013 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Aug 25, 2021

✅ Confirmed by @engcom-Lima. Thank you for verifying the issue.
Issue Available: @engcom-Lima, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-1013

@Den4ik Den4ik added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Aug 27, 2021
@github-jira-sync-bot
Copy link

❌ Cannot export the issue. This GitHub issue is already linked to Jira issue(s): https://jira.corp.magento.com/browse/AC-1013

@Den4ik Den4ik removed the Issue: needs update Additional information is require, waiting for response label Aug 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Framework Component: Framework/View Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: ready for dev Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
High Priority Backlog
  
Ready for Development
Development

No branches or pull requests

8 participants