Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Record timestamp creation refactored #1149

Merged
merged 1 commit into from
Jul 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions classes/class-log.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,6 @@ function ( $var ) {
// Add user meta to Stream meta.
$stream_meta['user_meta'] = $user_meta;

// Get the current time in milliseconds.
$iso_8601_extended_date = wp_stream_get_iso_8601_extended_date();

if ( ! empty( $user->roles ) ) {
$roles = array_values( $user->roles );
$role = $roles[0];
Expand All @@ -138,7 +135,7 @@ function ( $var ) {
'blog_id' => (int) apply_filters( 'wp_stream_blog_id_logged', get_current_blog_id() ),
'user_id' => (int) $user_id,
'user_role' => (string) $role,
'created' => (string) $iso_8601_extended_date,
'created' => (string) current_time( 'mysql', true ),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always need the UTC timestamp formatted for the DATETIME field in the DB so this will ensure we always get that consistent value.

This is different from the current behaviour of wp_stream_get_iso_8601_extended_date() which always adds the timezone information:

return $date->format( 'Y-m-d\TH:i:sO' );

which was probably causing the bug as the MySQL client wasn't able to cast it to a valid DATETIME value.

'summary' => (string) vsprintf( $message, $args ),
'connector' => (string) $connector,
'context' => (string) $context,
Expand Down