? Pending

User tests: Successful: Unsuccessful:

avatar joomdonation
joomdonation
16 Feb 2023

Pull Request for Issue # .

Summary of Changes

This PR adds a check to make sure Itemid from request points to a valid menu item before merging it's query data with the query from previous process to prevent fatal error.

Testing Instructions

  1. Type this link directly in the browser http://localhost/joomla/index.php?option=com_content&Itemid=1000 (Note Itemid=1000, there is no menu item with ID = 1000 in the setup, you can replace it with any invalid menu item id)

Actual result BEFORE applying this Pull Request

You get fatal error:

0 array_merge(): Argument #1 must be of type array, null given

Expected result AFTER applying this Pull Request

No fatal error, page displayed OK

Link to documentations

Please select:

  • No documentation changes for docs.joomla.org needed
  • No documentation changes for manual.joomla.org needed

@Hackwar Is it OK to add this check ? In theory, getItem method from calling code could return null, so I think it makes sense to add the check (we have other similar check in the same class)

avatar joomla-cms-bot joomla-cms-bot - change - 16 Feb 2023
Category Libraries
avatar joomdonation joomdonation - open - 16 Feb 2023
avatar joomdonation joomdonation - change - 16 Feb 2023
Status New Pending
avatar alikon
alikon - comment - 16 Feb 2023

ok no more fatal error with pr applyed

but strange page rendered

image

avatar joomdonation
joomdonation - comment - 16 Feb 2023

@alikon I'm unsure what's strange here? For that link, no view is provided, so the component will display it's default view (categories view in this case). So it looks OK for me.

avatar sandewt
sandewt - comment - 16 Feb 2023

but strange page rendered

The same thing happens if $query['option'] is not set. See line 395

 if (!isset($query['option'])) {
            return;
        }
avatar joomdonation
joomdonation - comment - 16 Feb 2023

@sandewt It is different, I think. When there is no option provided, we will get 404 error and expected. In this case, if wrong Itemid is provided, it causes fatal error and that should not happen.

avatar sandewt
sandewt - comment - 16 Feb 2023

In this case I get the following. See the picture.
I don't see a 404 error message or a fatal error.

unset($query['option']);

if (!isset($query['option'])) {
      return;
 }

issue_39470

avatar joomdonation
joomdonation - comment - 16 Feb 2023

Sorry @sandewt . I could not follow your issue, but I believe it is not related to the change in this PR. It just do a simple check to prevent fatal error, anything else is not related.

avatar alikon
alikon - comment - 16 Feb 2023

ah yes @joomdonation it's correct

avatar alikon alikon - test_item - 16 Feb 2023 - Tested successfully
avatar alikon
alikon - comment - 16 Feb 2023

I have tested this item successfully on 62ba7fb


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39870.

avatar sandewt
sandewt - comment - 16 Feb 2023

it is not related to the change in this PR

Indeed.

Also sorry, that I wasn't completely clear @joomdonation

avatar sandewt sandewt - test_item - 16 Feb 2023 - Tested successfully
avatar sandewt
sandewt - comment - 16 Feb 2023

I have tested this item successfully on 62ba7fb


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/39870.

avatar wilsonge wilsonge - close - 16 Feb 2023
avatar wilsonge wilsonge - merge - 16 Feb 2023
avatar wilsonge wilsonge - change - 16 Feb 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-02-16 12:34:48
Closed_By wilsonge
Labels Added: ?
avatar wilsonge
wilsonge - comment - 16 Feb 2023

Thanks!

Add a Comment

Login with GitHub to post a comment