Skip to content

Fix: Undefined index 'extension' when attachment URL has no file extension - #262

Open
2501030204-star wants to merge 1 commit into
WordPress:masterfrom
2501030204-star:fix/undefined-extension-index
Open

Fix: Undefined index 'extension' when attachment URL has no file extension#262
2501030204-star wants to merge 1 commit into
WordPress:masterfrom
2501030204-star:fix/undefined-extension-index

Conversation

@2501030204-star

Copy link
Copy Markdown

Description

Fixes #139

When pathinfo() is called on an attachment URL that has no file extension
(e.g. https://example.com/files/myfile), the extension key is absent
from the returned array, causing:

Notice: Undefined index: extension in class-wp-import.php on line 1043

Changes

Added isset() guards on both $parts['extension'] and $parts_new['extension']
in the URL remapping block. Falls back to the full basename when no extension
is present, preserving existing behaviour for normal URLs.

…pathinfo() is called on a URL without a file extension, the 'extension' key is absent from the returned array, causing an undefined index notice. Added isset() guards on both \$parts['extension'] and \$parts_new['extension'] in the URL remapping block. fixes WordPress#139
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Undefined index: 'extension'

1 participant