Skip to content

Warning when Search Terms page is opened by clicking option at the footer #25245

Closed
@ghost

Description

Preconditions (*)

  1. Fresh Magento installation with magento 2.3-develop

Steps to reproduce (*)

  1. Setup vanilla 2.3-develop
  2. Create a product in the backend, give it the name "test"
  3. On the frontend, perform a search query, search for "test"
  4. Notice that it finds the product
  5. If you now go to the Search Terms page in the frontend, it will show the search term "test" => good
  6. Now in the backend, go to Marketing > SEO & Search > Search Terms
  7. Open your "test" term
  8. Set the "Number of Uses" to 0 and save
  9. Click On Search terms option present at the bottom

Expected result (*)

  1. Page opens without any error
  2. There is no errors in the system log

Actual result (*)

  1. In developer Magento mode Warning is shown on the Search Terms page
    Warning: natcasesort() expects parameter 1 to be array, null given in /var/www/html/deployer/instances/i-25245-2-3-develop/app/code/Magento/Search/Block/Term.php on line 102 [] []
  2. In default mode error is shown in system.log

Additional information

Based on comment #25245 (comment)
Fix seems to be very easy:

diff --git a/app/code/Magento/Search/Block/Term.php b/app/code/Magento/Search/Block/Term.php
index b27ef6b01fd..a1eb0bb64c9 100644
--- a/app/code/Magento/Search/Block/Term.php
+++ b/app/code/Magento/Search/Block/Term.php
@@ -87,6 +87,7 @@ class Term extends Template
                 return $this;
             }

+            $termKeys = [];
             $this->_maxPopularity = reset($terms)->getPopularity();
             $this->_minPopularity = end($terms)->getPopularity();
             $range = $this->_maxPopularity - $this->_minPopularity;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: SearchFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: doneReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions