Skip to content

Warning: Undefined array key 2 in class-gallery.php on line 168 #1250

@mirlanbekturov

Description

@mirlanbekturov

Description of the bug

A PHP warning occurs when the code tries to access an array key that may not exist.
The issue happens in class-gallery.php at line 168 when using the following expression:

! empty( trim( $matches[2] ) )

Proposed Fix

! empty( trim( $matches[2] ?? '' ) )

Steps To Reproduce

  1. Trigger the Apple News export process on a post that does not produce a full regex match with index
  2. Observe PHP logs or browser console for warnings.
  3. See the Undefined array key 2 warning in the logs.

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions