Make WordPress Core

Opened 8 years ago

Last modified 2 months ago

#41471 new enhancement

Page dropdown walker must check selected against value field

Reported by: geminorum's profile geminorum Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Posts, Post Types Keywords: has-patch needs-unit-tests needs-testing
Focuses: Cc:

Description

Walker_PageDropdown only checks selected with the page ID and ignores value_field option.

Attachments (1)

41471.diff (1.2 KB) - added by geminorum 8 years ago.

Download all attachments as: .zip

Change History (6)

@geminorum
8 years ago

#1 @SergeyBiryukov
7 years ago

  • Component changed from General to Posts, Post Types
  • Keywords has-patch needs-unit-tests added

Related: #43522

#2 @SergeyBiryukov
7 years ago

  • Milestone changed from Awaiting Review to Future Release

This ticket was mentioned in Slack in #core by sirlouen. View the logs.


2 months ago

This ticket was mentioned in PR #10203 on WordPress/wordpress-develop by @SirLouen.


2 months ago
#4

Refreshing 41471.diff for Testing and Review Purposes

Trac ticket: https://core.trac.wordpress.org/ticket/41471

#5 @SirLouen
2 months ago

  • Focuses administration removed
  • Keywords needs-testing added
  • Type changed from defect (bug) to enhancement
  • Version 4.9 deleted

Reproduction and Patch Testing Report

Description

✅ This report validates that the indicated issue can be reproduced and patch works as expected.

Patch tested: https://github.com/WordPress/wordpress-develop/pull/10203

Environment

  • WordPress: 6.9-alpha-60093-src
  • PHP: 8.2.29
  • Server: nginx/1.29.1
  • Database: mysqli (Server: 8.4.6 / Client: mysqlnd 8.2.29)
  • Browser: Chrome 140.0.0.0
  • OS: Windows 10/11
  • Theme: Twenty Seventeen 3.9
  • MU Plugins: None activated
  • Plugins:
    • BBB Testing Dolly
    • Classic Editor 1.6.7
    • Test Reports 1.2.0

Testing Instructions

  1. Create a new page with the slug test-slug-page
  2. Create two or three other pages for the example
  3. Add the shortcode to a plugin or wherever it can be executed
  4. Add the shortcode to anotherpage
  5. The page with the test-slug-page slug should be selected by default

Actual Results

  1. ✅ Issue resolved with patch.

Additional Notes

  • Given that we are already setting by default the ID to $argsvalue_field?, having the option of assigning whatever value_field we prefer, as provided in the example in supp artifacts, improves this.
  • This must be upgraded to enhancement as this is not a bug per se.
  • Some unit test coverage for this would be ideal.

Supplemental Artifacts

function test_page_dropdown() {
    get_pages();
    $dropdown = wp_dropdown_pages( array(
        'echo' => 0,
        'value_field' => 'post_name',
        'selected' => 'test-slug-page',
        'name' => 'test_dropdown',
        'show_option_none' => 'Select a page',
    ) );
    echo $dropdown;
}
add_shortcode( 'test_dropdown', 'test_page_dropdown' );
Note: See TracTickets for help on using tickets.