Opened 2 years ago
Last modified 2 years ago
#56996 new defect (bug)
Getting error Uncaught exception 'TypeError' with message 'Cannot access offset of type string on string' in /var/www/wp-includes/media.php:2147
Reported by: | umesh.nevase | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | blocker | Version: | 6.1 |
Component: | General | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
WordPress 6.1 and PHP8.
Getting this error on the page with the old caption shortcodes. if regex does not find 2nd offset. giving below error
Uncaught exception 'TypeError' with message 'Cannot access offset of type string on string' in /var/www/wp-includes/media.php:2147
Change History (5)
This ticket was mentioned in PR #3567 on WordPress/wordpress-develop by umeshnevase.
2 years ago
#2
- Keywords has-patch added; needs-patch removed
I've reinitialized $attr to an array.
The Fatal error is coming with PHP 8.0 and WordPress 6.1
Trac ticket: https://core.trac.wordpress.org/ticket/56996
#3
in reply to:
↑ description
@
2 years ago
On WordPress 6.1 the issue is coming on line number: 2198
Replying to umesh.nevase:
WordPress 6.1 and PHP8.
Getting this error on the page with the old caption shortcodes. if regex does not find 2nd offset. giving below error
Uncaught exception 'TypeError' with message 'Cannot access offset of type string on string' in /var/www/wp-includes/media.php:2147
This ticket was mentioned in PR #3572 on WordPress/wordpress-develop by mslinnea.
2 years ago
#4
- Keywords has-unit-tests added
On PHP 8, there is a fatal error for the [caption]
shortcode when there are no attributes.
To replicate the issue, add the following code to the shortcode block:
[caption]<img class="alignnone" src="test.jpeg" width="2048" height="1091" />Test[/caption]
I suggest solving this issue by casting $attr
to an array, as this is the same way that the function shortcode_atts
prevents this issue, which is what other shortcodde callback functions call, like wp_video_shortcode
.
Trac ticket: https://core.trac.wordpress.org/ticket/56996
#5
@
2 years ago
This issue appears to the be the same one as https://core.trac.wordpress.org/ticket/45929
The issue is coming if [caption] shortcode doesn't have any attributes. The issue is not with 2nd offset.