WordPress.org

Make WordPress Core

Opened 7 months ago

Last modified 2 months ago

#42612 reviewing defect (bug)

Single post navigation bugs when adding posts in Starter Content

Reported by: bduclos Owned by: westonruter
Milestone: Future Release Priority: normal
Severity: normal Version: 4.7
Component: Customize Keywords: has-patch
Focuses: Cc:

Description

To reproduce the issue:

  • Inside a fresh install of Twentyseventeen, open the functions.php file. Line 132, modify the $starter_content posts array to add 2 posts:
    <?php
    'posts' => array(
            'home',
            'about' => array(
                    'thumbnail' => '{{image-sandwich}}',
            ),
            'contact' => array(
                    'thumbnail' => '{{image-espresso}}',
            ),
            'blog' => array(
                    'thumbnail' => '{{image-coffee}}',
            ),
            'homepage-section' => array(
                    'thumbnail' => '{{image-espresso}}',
            ),
    
            'the-new-office' => array(
                    'post_type'     => 'post',
                    'post_title'    => 'The new office',
                    'thumbnail'     => '{{image-espresso}}',
                    'post_content'  => 'Maecenas tristique lobortis sem sit amet consectetur. Nullam pharetra ex ex, a aliquet ligula pellentesque a. Aenean et justo volutpat, malesuada purus a, sagittis eros.',
            ),
    
            'join-the-team' => array(
                    'post_type'     => 'post',
                    'post_title'    => 'Join the team',
                    'thumbnail'     => '{{image-coffee}}',
                    'post_content'  => 'Maecenas tristique lobortis sem sit amet consectetur. Nullam pharetra ex ex, a aliquet ligula pellentesque a. Aenean et justo volutpat, malesuada purus a, sagittis eros.',
            ),                      
    ),
    
  • Open the Customizer to load the starter content and click on the Publish button.
  • Visit the first post titled "The new office". The single navigation indicates "Hello World" as the previous post while it should be "Join the team".

I think the bug comes from the fact that the 2 posts have the same exact date. Is there a way to specify the post date when configuring the starter content?

Attachments (1)

42612.diff (4.7 KB) - added by dlh 6 months ago.

Download all attachments as: .zip

Change History (19)

#1 @pratikgandhi
7 months ago

  • Keywords needs-patch added

Hello @bduclos

Its because both posts are published at the same time. There is no option in starter content in which we can give post_date so there is no bug in the customize.

Thanks

This ticket was mentioned in Slack in #core-customize by jeffpaul. View the logs.


7 months ago

#3 @westonruter
7 months ago

  • Milestone changed from Awaiting Review to 4.9.1

As I recall, a draft or auto-draft doesn't take kindly to having a post_date assigned to it. I'll need to double check that. At the very least, we could make it so that each starter content post inserted gets a post_date that decrements back 1 second for each one inserted, so that they have a stable sort according to the order they appear in the starter content config.

#4 @johnbillion
7 months ago

  • Milestone changed from 4.9.1 to 4.9.2
  • Version changed from trunk to 4.7

This ticket was mentioned in Slack in #core-customize by dlh. View the logs.


6 months ago

@dlh
6 months ago

#6 @dlh
6 months ago

  • Keywords has-patch added; needs-patch removed

From what I've been able to tell, the auto-drafts created for starter content can have post dates assigned to them without issue. But it does look as if this fix needs to happen in three places:

  1. When creating the auto-draft in WP_Customize_Manager::import_theme_starter_content().
  1. When bumping the post date in _wp_keep_alive_customize_changeset_dependent_auto_drafts().
  1. When publishing the starter content in WP_Customize_Nav_Menus::save_nav_menus_created_posts().

42612.diff attempts to address those three changes.

There's an additional complication the patch doesn't cover: When the same starter content post is reused among themes, it's no longer safe to assume that the order of post IDs in nav_menus_created_posts matches the order of posts as defined by the theme. The patch would need additional logic to sync the number of seconds removed from the post date to the array of starter content in the current theme.

Lastly, the patch doesn't attempt to cover sorting for attachments, although it seems to happen anyway via changes (2) and (3).

Last edited 6 months ago by dlh (previous) (diff)

This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.


5 months ago

#8 @westonruter
5 months ago

  • Owner set to westonruter
  • Status changed from new to reviewing

#9 @dd32
5 months ago

  • Milestone changed from 4.9.2 to 4.9.3

Bumping to 4.9.3 due to 4.9.2s release

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


5 months ago

#11 @westonruter
5 months ago

  • Milestone changed from 4.9.3 to 4.9.4

#12 @dd32
5 months ago

  • Milestone changed from 4.9.4 to 4.9.5

Bumping, 4.9.4 has been released.

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


4 months ago

#14 @audrasjb
3 months ago

Hello, As far as I know, it still needs a feedback from the owner (or a component maintener) before landing in the next minor. 4.9.5 beta release is planned for tomorrow so we'll need a confirmation otherwise it will be punted to 4.9.6 (which is not that bad).

Cheers, Jb

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


3 months ago

#16 @audrasjb
3 months ago

  • Milestone changed from 4.9.5 to 4.9.6

Bumping to 4.9.6 due to 4.9.5 beta release.

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


2 months ago

#18 @westonruter
2 months ago

  • Milestone changed from 4.9.6 to Future Release
Note: See TracTickets for help on using tickets.