Error: Argument #2 ($haystack) must be of type array, null given

Created on 30 August 2023, about 1 year ago
Updated 5 September 2023, about 1 year ago

Problem/Motivation

Hi! This is a bug related to PHP 8.1, when I'm insert a page, a type error will be displayed:
TypeError: array_search(): Argument #2 ($haystack) must be of type array, null given in array_search() (line 83 of modules/contrib/page_manager_search/page_manager_search.module).

Steps to reproduce

  1. Install and enable the page manager module and page manager ui module
  2. Install and enable this module( page manager search )
  3. Click on Add Page(admin/structure/page_manager)
  4. Fill the required fields on the next page and click on Next button
  5. On the next page, click on the Next button
  6. On the next page, click on the Finish button

Proposed resolution

The proposed solution would be validate the 'module' array key before searching it.

Remaining tasks

  1. Review
  2. Test
  3. Commit
🐛 Bug report
Status

Needs review

Version

2.0

Component

Code

Created by

🇧🇷Brazil murilohp

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @murilohp
  • Status changed to Needs review about 1 year ago
  • 🇧🇷Brazil murilohp

    Here's a patch with the proposed solution.

  • Status changed to Needs work about 1 year ago
  • 🇵🇭Philippines clarkssquared

    Hi murilohp,

    I applied your patch in my local and I confirmed that it fixed the TypeError: array_search():, however, I noticed that when I try to create or update a page in admin/structure/page_manager there's an error flagged in my dblog,

    kindly look at the screenshot I attached for your reference.

    Thank you

  • Status changed to Needs review about 1 year ago
  • 🇧🇷Brazil murilohp

    Hey @clarkssquared thanks for the testing, but I think this error has nothing to do with this issue, I suggest you to open another issue to address this error, apparently there's a call to this non exist service on the post save of the file: Drupal\page_manager_search\Entity\PageManagerSearch. I'll move this back to NR to see what you think.

  • First commit to issue fork.
  • 🇮🇳India saranyamariappan

    Hi @ murilohp , @ clarkssquared ,

    I have applied the patch on #2 🐛 Error: Argument #2 ($haystack) must be of type array, null given Needs review and it working fine on 2.0.x-dev. In addition, I am able to reproduce the issue mentioned on #3 🐛 Error: Argument #2 ($haystack) must be of type array, null given Needs review and even I would agree to create it as an another issue.

    Apart from, I found an issue when submitting the Search Page form on /admin/config/search/pages. This time the error is from the deprecated core service has been used. I have updated it and created a patch. Please review and let me know.

Production build 0.71.5 2024