Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#39412 closed defect (bug) (duplicate)

register_post_status() can trigger notices on admin list due to fallback

Reported by: dd32's profile dd32 Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch
Focuses: Cc:

Description

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?

Attachments (1)

39412.diff (1.1 KB) - added by dd32 7 years ago.

Download all attachments as: .zip

Change History (2)

@dd32
7 years ago

#1 @johnbillion
7 years ago

  • Milestone 4.8 deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #38686.

Note: See TracTickets for help on using tickets.