Make WordPress Core

Opened 7 years ago

Closed 2 years ago

Last modified 2 years ago

#42612 closed defect (bug) (maybelater)

Single post navigation bugs when adding posts in Starter Content

Reported by: bduclos's profile bduclos Owned by: westonruter's profile westonruter
Milestone: 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 7 years ago.

Download all attachments as: .zip

Change History (21)

#1 @pratikgandhi
7 years 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 years ago

#3 @westonruter
7 years 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 years 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.


7 years ago

@dlh
7 years ago

#6 @dlh
7 years ago

  • Keywords has-patch added; needs-patch removed

From what I've been able 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).

Version 1, edited 7 years ago by dlh (previous) (next) (diff)

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


7 years ago

#8 @westonruter
7 years ago

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

#9 @dd32
7 years 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.


7 years ago

#11 @westonruter
7 years ago

  • Milestone changed from 4.9.3 to 4.9.4

#12 @dd32
7 years 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.


7 years ago

#14 @audrasjb
7 years 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.


7 years ago

#16 @audrasjb
7 years 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.


7 years ago

#18 @westonruter
7 years ago

  • Milestone changed from 4.9.6 to Future Release

#19 @westonruter
2 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from reviewing to closed

New feature development is being directed toward the Site Editor, so I'm closing this.

#20 @westonruter
2 years ago

  • Resolution changed from wontfix to maybelater
Note: See TracTickets for help on using tickets.