mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
Date / Time: Remove usage of mysql2date in generate_postdata method.
Remove usage of `mysql2date` in `generate_postdata`. `mysql2date` has a performance overhead, as it creates a `DateTimeZone` object each time it is called. Use a simple sub string function to generate the values needed for the `currentmonth` and `currentday` global variables. Props spacedmonkey, Rarst, SergeyBiryukov, flixos90. Fixes #57683. git-svn-id: https://develop.svn.wordpress.org/trunk@55558 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
8c7dc47219
commit
1eba58d5a6
@ -4714,11 +4714,22 @@ class WP_Query {
|
||||
|
||||
$authordata = get_userdata( $post->post_author );
|
||||
|
||||
$currentday = mysql2date( 'd.m.y', $post->post_date, false );
|
||||
$currentmonth = mysql2date( 'm', $post->post_date, false );
|
||||
$numpages = 1;
|
||||
$multipage = 0;
|
||||
$page = $this->get( 'page' );
|
||||
$currentday = false;
|
||||
$currentmonth = false;
|
||||
|
||||
$post_date = $post->post_date;
|
||||
if ( ! empty( $post_date ) && '0000-00-00 00:00:00' !== $post_date ) {
|
||||
// Avoid using mysql2date for performance reasons.
|
||||
$currentmonth = substr( $post_date, 5, 2 );
|
||||
$day = substr( $post_date, 8, 2 );
|
||||
$year = substr( $post_date, 2, 2 );
|
||||
|
||||
$currentday = sprintf( '%s.%s.%s', $day, $currentmonth, $year );
|
||||
}
|
||||
|
||||
$numpages = 1;
|
||||
$multipage = 0;
|
||||
$page = $this->get( 'page' );
|
||||
if ( ! $page ) {
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user