[wp-trac] [WordPress Trac] #61794: Bugfix in class-wp-translation-file-mo for "PHP Warning: Undefined array key 1 in"

WordPress Trac noreply at wordpress.org
Wed Jul 31 09:34:16 UTC 2024


#61794: Bugfix in class-wp-translation-file-mo for "PHP Warning:  Undefined array
key 1 in"
--------------------------+-----------------------------
 Reporter:  pander        |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.6.1
 Severity:  minor         |   Keywords:
  Focuses:  performance   |
--------------------------+-----------------------------
 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
 <?php
 list( $name, $value ) = array_map( 'trim', explode( ':', $meta_line, 2 )
 );
 }}}


 To prevent the warning, I have changed line 157 from

 {{{#!php
 <?php
 if ( '' === $meta_line ) {
 }}}


 to

 {{{#!php
 <?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.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61794>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list