#61794 closed defect (bug) (fixed)
Bugfix in class-wp-translation-file-mo for "PHP Warning: Undefined array key 1 in"
Reported by: | pander | Owned by: | swissspidy |
---|---|---|---|
Milestone: | 6.7 | Priority: | low |
Severity: | minor | Version: | 6.5 |
Component: | I18N | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
The warning "PHP Warning: Undefined array key 1 in" is flooding the error log file of my web service running WordPress.
I think the plugin that is the cause of this warning for me is https://github.com/qtranslate/qtranslate-xt/ or https://icalevents.com/ but I have seen it being reported for many different plugins.
Line 161 of wp-includes/l10n/class-wp-translation-file-mo.php is triggering this, is
<?php list( $name, $value ) = array_map( 'trim', explode( ':', $meta_line, 2 ) );
To prevent the warning, I have changed line 157 from
<?php if ( '' === $meta_line ) {
to
<?php if ( '' === $meta_line || strpos($meta_line, ':') === false ) {
I know the warning is valid and should be fixed elsewhere, but my knowledge of WordPress is limited and this fix prevents that performance is impeded. Perhaps the warning should be caught in a different way, but this fixed it for now for me.
If there are way to pinpoint better what is causing this, please let me know. I can help to locate it but need some guidance.
Change History (11)
#1
@
6 months ago
- Component changed from General to I18N
- Focuses performance removed
- Owner set to swissspidy
- Status changed from new to assigned
#2
@
6 months ago
The fix sounds reasonable to me, it adds some hardening.
If there are way to pinpoint better what is causing this, please let me know. I can help to locate it but need some guidance.
One of your plugins has an invalid MO file. You can try a `var_dump( $this->file ) on line 160 to find the culprit.
#3
@
6 months ago
- Keywords has-patch added
- Milestone changed from Awaiting Review to 6.7
- Priority changed from normal to low
- Version changed from 6.6.1 to 6.5
This ticket was mentioned in PR #7115 on WordPress/wordpress-develop by @swissspidy.
6 months ago
#4
Trac ticket: https://core.trac.wordpress.org/ticket/61794
This ticket was mentioned in PR #7116 on WordPress/wordpress-develop by @narenin.
6 months ago
#5
Trac ticket: https://core.trac.wordpress.org/ticket/61794
@mukesh27 commented on PR #7116:
6 months ago
#6
@swissspidy Already opened #7115
@swissspidy commented on PR #7115:
5 months ago
#9
#10
@
5 months ago
Thanks. The culprit is
string(97) "/var/www/DOMAINNAME/wp-content/plugins/amr-ical-events-list/lang/amr-ical-events-list-nl_NL.mo"
and that was repeated 1142 times.
I regenerated the MO file with
cd /var/www/DOMAINNAME/wp-content/plugins/amr-ical-events-list/lang mv amr-ical-events-list-nl_NL.mo /tmp msgfmt amr-ical-events-list-nl_NL.po -o amr-ical-events-list-nl_NL.mo
and this fixed it.
Removing performance focus as this is not related to performance.