magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

UI Listing - Bookmark issue when no filters #38722

Open Nuranto opened 5 months ago

Nuranto commented 5 months ago

Preconditions and environment

Steps to reproduce

  1. Create a listing with no filters, and with bookmark
  2. Load the page containing the listing
  3. Move a column to another position

Expected result

Bookmark is saved

Actual result

500 error : Exception #0 (Exception): Warning: Undefined array key "filters" in /var/www/html/vendor/magento/module-ui/Controller/Adminhtml/Bookmark/Save.php on line 250

Additional information

No response

Release note

No response

Triage and priority

m2-assistant[bot] commented 5 months ago

Hi @Nuranto. Thank you for your report. To speed up processing of this issue, make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

m2-assistant[bot] commented 5 months ago

Hi @engcom-Delta. 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: :point_down:

m2-assistant[bot] commented 5 months ago

Hi @engcom-November. 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: :point_down:

engcom-November commented 5 months ago

Hello @Nuranto,

Thank you for the report and collaboration!

Tried to verify this on 2.4.7, but the issue is not reproducible. Created a UI listing without filter element, moved the column to another position, and the bookmark is being saved. Please take a look at the screeshot below:

image

Here I have moved the content column to first position, on page refresh the new configuration is retained.

Please find the custom module used to reproduce this, and let us know if we are missing anything. I38722V.zip

Thank you.

Nuranto commented 5 months ago

Can you check the mui/bookmark/save xhr response code ? Is it 200 or 500 ?

engcom-November commented 5 months ago

mui/bookmark/save xhr code is 200

image
Nuranto commented 5 months ago

Alright, I can reproduce the issue with your module on two distinct environments, there must be an extra condition, but I don't know which one.

ekomurz commented 5 months ago

I encountered the same error after updating an existing 2.4.6 project to 2.4.7. It seems that updating the ui_bookmark table does not work always as expected.

I removed the records in that table for my admin account, and after this action: the sales grid was working just fine.

(I did not have time to investigate this further, but perhaps it may give you some clue to the origin of this issue ?)

engcom-November commented 5 months ago

Hello @ekomurz, Thank you for the input.

We were able to reproduce this issue after updating 2.4.6 instance to 2.4.7. After updating to 2.4.7, rearranged columns are saved with error code 500.

Please take a look at the screenshot below:

image

And here is the exception message:

"exception":"[object] (Exception(code: 0): Warning: Undefined array key \"filters\" in <magentoInstance>/vendor/magento/module-ui/Controller/Adminhtml/Bookmark/Save.php on line 250 at <magentoInstance>/vendor/magento/framework/App/ErrorHandler.php:62)"} []

This issue is reproduced using the custom module attached here.

Hence confirming the issue.

Thank you.

github-jira-sync-bot commented 5 months ago

:white_check_mark: Jira issue https://jira.corp.adobe.com/browse/AC-12062 is successfully created for this GitHub issue.

m2-assistant[bot] commented 5 months ago

:white_check_mark: Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, 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 commented 5 months ago

:x: You don't have permission to export this issue.

rogerdz commented 5 months ago

maybe fix with https://github.com/magento/magento2/pull/38784

ki5-mshoaibq commented 3 months ago

Is there any work around for this currently?

gjportegies commented 3 months ago

Issue present on Magento 2.4.7-p1. I'm looking for a fix as well.

ki5-mshoaibq commented 3 months ago

For now, I extended the bookmark save file <preference for="Magento\Ui\Controller\Adminhtml\Bookmark\Save" type="Vendor\Module\Controller\Adminhtml\Bookmark\Save" /> And in extended file, changed code at line#250 onwards,

if ($existingConfig && $currentConfig) {
                    /*
                     * Default Magento code commented out
                    if ($existingConfig['filters'] === $currentConfig['filters']
                        && $existingConfig['positions'] !== $currentConfig['positions']
                    */
                    //Below check added
                    if ( (isset($existingConfig['filters']) && isset($currentConfig['filters']))
                        && ($existingConfig['filters'] === $currentConfig['filters'])
                        && ($existingConfig['positions'] !== $currentConfig['positions'])
                        //e.o. Below code added
                    ) {
                        $bookmarkConfig['views'][$bookmark->getIdentifier()]['data'] = $data[self::CURRENT_IDENTIFIER];
                        $bookmark->setConfig($this->serializer->serialize($bookmarkConfig));
                        $this->bookmarkRepository->save($bookmark);
                    }
                }

This fixed my problem.

tuyennn commented 1 week ago

+1 Also got

Warning: Undefined array key \"positions\" in vendor/magento/module-ui/Controller/Adminhtml/Bookmark/Save.php on line 251

Magento 2.4.7-p3