Skip to:
Content

bbPress.org

#3354 closed defect (fixed)

Theme compatibility and problem with 'get_adjacent_post()' function

Reported by: GDragoN Owned by: johnjamesjacoby
Milestone: 2.6.6 Priority: high
Severity: major Version: trunk
Component: Appearance - Theme Compatibility Keywords: has-patch 2nd-opinion
Cc:

Description

Some themes (including many default Twenty* themes) show adjacent links to all posts, and in theme compatibility mode that breaks because function get_adjacent_post() expects post to have valid post_date. But, In theme compatibility mode, bbPress uses 'bbp_theme_compat_reset_post()' function and it sets post_date to 0.

Why is that done at all, when we can set post_date to proper post_date for the single topic, reply or forum we are generating compatibility post? Is there any concrete reason for why the post_date has to be 0 in theme compatibility mode or was it just some random decision not to set it?

I have attached the patch that adds date to theme compatibility reset for single topic, forum and reply.

Attachments (2)

3354_theme-compat.php (1.8 KB) - added by GDragoN 14 months ago.
3354.2.patch (6.6 KB) - added by johnjamesjacoby 12 months ago.

Download all attachments as: .zip

Change History (11)

#1 @GDragoN
14 months ago

Also, few months ago I have noticed some other issues (not just get_adjacent_post()) related to compatibility mode and the missing post_date.

#2 @johnjamesjacoby
14 months ago

  • Keywords has-patch 2nd-opinion added
  • Milestone changed from Awaiting Review to 2.6.5
  • Owner set to johnjamesjacoby
  • Status changed from new to assigned

Related to #3337.

I think it makes sense to correctly format datetime column values rather than have them simply be false. We could probably get away with 0000-00-00 00:00:00 because WordPress forced zero dates to be allowed in MySQL, but I do suspect this is going to go away someday, so perhaps Unix Epoch makes more sense, or maybe some other value.

#3 @GDragoN
14 months ago

Yeah, we can have '0000-00-00 00:00:00' instead of 0, but I think we should use the real dates when available (as my patch does) because there were some cases in the past that I noticed as a problem related to some other plugins.

#4 @johnjamesjacoby
12 months ago

  • Milestone changed from 2.6.5 to 2.6.6

#6 @johnjamesjacoby
12 months ago

I think the issue with using "real dates" is that in some instances, like User Profile pages, there isn't a datetime value to guess from.

The only other potential regression I can imagine but cannot find happening, is anyplace something like:

empty( $post->post_date )

...might be used - it would now be a non-empty value.

Thank you @GDragoN for the patch. I think I'm going to go a slightly different route. Would love if you'd be willing and able to check it out sometime soonish.

Last edited 12 months ago by johnjamesjacoby (previous) (diff)

#7 @GDragoN
12 months ago

Yeah, this would be good. The filter can be used to return real date instead of the 0 date/time, because I think I remember some cases when such date/time also causes issues, I tried that at one point. Maybe the current date/time instead of zero by default would be better. But, this is a good solution.

#8 @johnjamesjacoby
12 months ago

In 7099:

Theme Compatibility: Avoid compatibility issues between MySQL versions.

This commit introduces a new function - bbp_get_empty_datetime() - which returns a valid, filterable, "empty" MySQL formatted datetime value.

This new function is used inside the theme compatibility API to ensure that global WP_Post datetime values are not "0" to better support MySQL 8 and higher, which is dropping support for NO_ZERO_DATES.

Props GDragoN.

In trunk, for 2.7.0.

See #3354.

#9 @johnjamesjacoby
12 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 7100:

Theme Compatibility: Avoid compatibility issues between MySQL versions.

This commit introduces a new function - bbp_get_empty_datetime() - which returns a valid, filterable, "empty" MySQL formatted datetime value.

This new function is used inside the theme compatibility API to ensure that global WP_Post datetime values are not "0" to better support MySQL 8 and higher, which is dropping support for NO_ZERO_DATES.

Props GDragoN.

In branches/2.6, for 2.6.6.

Fixes #3354.

Note: See TracTickets for help on using tickets.