[wp-trac] [WordPress Trac] #39412: register_post_status() can trigger notices on admin list due to fallback

WordPress Trac noreply at wordpress.org
Wed Dec 28 04:11:44 UTC 2016


#39412: register_post_status() can trigger notices on admin list due to fallback
-------------------------------+-----------------------
 Reporter:  dd32               |      Owner:
     Type:  defect (bug)       |     Status:  new
 Priority:  normal             |  Milestone:  4.8
Component:  Posts, Post Types  |    Version:
 Severity:  normal             |   Keywords:  has-patch
  Focuses:                     |
-------------------------------+-----------------------
 if a post status is registered using only the `label` parameter, the
 `label_count` fallback causes PHP notices to be thrown on the post listing
 screen.

 Notices:
 {{{
 Notice: Undefined index: domain in src/wp-includes/l10n.php on line 514
 Notice: Undefined index: context in src/wp-includes/l10n.php on line 517
 Notice: Undefined index: singular in src/wp-includes/l10n.php on line 520
 Notice: Undefined index: plural in src/wp-includes/l10n.php on line 520
 }}}

 Example of registration call:
 {{{
 <?php
 add_action( 'init', function() {
         register_post_status( 'test-status', [ 'label' => 'Test Status',
 'show_in_admin_status_list' => true
 } );
 }}}

 Example code to move a post to the status:
 {{{
 $p = get_post( 1 );
 $p->post_status = 'test-status';
 wp_update_post( $p );
 }}}

 This is caused as we're building an array manually of `array( $label,
 $label )` and passing that to `translate_nooped_plural()`.

 One option (see patch) is to pass it through `_n_noop()` which seems
 incorrect, as it's not a translatable string, but as `_n_noop()` doesn't
 actually do the translation, it seems the correct option. @ocean90
 thoughts?

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


More information about the wp-trac mailing list