Skip to content

Warning: Trying to access array offset on value of type null #111

Description

@mckillo

When I try to view any article, I receive the following message:
"Warning: Trying to access array offset on value of type null in \plugins\attachments\framework\src\PlgAttachmentsFramework.php on line 966"

Environment:

  • Joomla 5.2.3 with PHP 8.2.
  • Attachments 4.1.0.

The line 966 in PlgAttachmentsFramework.php:
$attachments_list = $controller->displayString($parent_id, $this->parent_type, $parent_entity, null, true, true, false, $from, $attachment_id[$i] );

In an article without any attachments, the variable $attachment_id is null and $attachment_id[$i] cause this warning, because it isn't an array. This is source of this issue.

The proposal solution is modify the line 917 in \plugins\attachments\framework\src\PlgAttachmentsFramework.php
$attachment_id = null;
for this one:
$attachment_id [] = null;

After applying this change, the warning disappears.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions