No Code Attached Yet
avatar richard67
richard67
29 May 2023

Steps to reproduce the issue

Installing Blog Sample Data fails on 5.0-dev after PR #38650 has been merged when error reporting is set to Maximum and PHP 8.1+ is used.

When error reporting is not set to Maximum, the installation succeeds.

But in both cases you get the PHP warnings mentioned below.

See also #38650 (comment) .

Expected result

No PHP warnings, installation of Blog Sample Data succeeds in any case.

Actual result

PHP warnings:

PHP Warning:  Undefined array key "searchindex" in /administrator/components/com_fields/src/Model/FieldModel.php on line 119
PHP Warning:  Attempt to read property "params" on null in /administrator/components/com_fields/src/Model/FieldModel.php on line 120
PHP Warning:  Trying to access array offset on value of type null in /administrator/components/com_fields/src/Model/FieldModel.php on line 120
PHP Warning:  Undefined array key "searchindex" in/administrator/components/com_fields/src/Model/FieldModel.php on line 120
PHP Warning:  Undefined array key "searchindex" in /administrator/components/com_fields/src/Model/FieldModel.php on line 121

System information (as much as possible)

Current 5.0-dev branch with PR #38650 merged.
PHP 8.1

Additional comments

It needs to add isset checks to the if conditions, i.e. change the code here
https://github.com/joomla/joomla-cms/blob/5.0-dev/administrator/components/com_fields/src/Model/FieldModel.php#L118-L124
from

        if (
            (is_null($field) && $data['params']['searchindex'] > 0)
            || ($field->params['searchindex'] != $data['params']['searchindex'])
            || ($data['params']['searchindex'] > 0 && ($field->state != $data['state'] || $field->access != $data['access']))
        ) {
            Factory::getApplication()->enqueueMessage(Text::_('COM_FIELDS_SEARCHINDEX_MIGHT_REQUIRE_REINDEXING'), 'notice');
        }

to

        if (isset($data['params']['searchindex'])
            && ((is_null($field) && $data['params']['searchindex'] > 0)
                || ($field->params['searchindex'] != $data['params']['searchindex'])
                || ($data['params']['searchindex'] > 0 && ($field->state != $data['state'] || $field->access != $data['access'])))
        ) {
            Factory::getApplication()->enqueueMessage(Text::_('COM_FIELDS_SEARCHINDEX_MIGHT_REQUIRE_REINDEXING'), 'notice');
        }

But maybe that's not right, and the right fix would be to add the new parameter searchindex to the fields creating in the blog sample data plugin.

avatar richard67 richard67 - open - 29 May 2023
avatar joomla-cms-bot joomla-cms-bot - change - 29 May 2023
Labels Added: No Code Attached Yet
avatar joomla-cms-bot joomla-cms-bot - labeled - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
Labels Added: PHP 8.x
avatar richard67 richard67 - labeled - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
Labels Removed: PHP 8.x
avatar richard67 richard67 - unlabeled - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67 richard67 - change - 29 May 2023
The description was changed
avatar richard67 richard67 - edited - 29 May 2023
avatar richard67
richard67 - comment - 29 May 2023

I've created a PR to fix the issue as suggested in the "Additional comments" section of the description of this issue here.

If the PR turns out to be wrong I'll reopen this issue.

avatar richard67 richard67 - change - 29 May 2023
Status New Closed
Closed_Date 0000-00-00 00:00:00 2023-05-29 14:34:36
Closed_By richard67
avatar richard67 richard67 - close - 29 May 2023

Add a Comment

Login with GitHub to post a comment