From 26a1dc9be5165b40369fba9acc36afd2ee1a4db1 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Wed, 10 May 2023 18:52:13 +0200 Subject: [PATCH] use time() instead of strtotime( 'now' ) --- includes/collection/class-followers.php | 2 +- includes/model/class-activity.php | 2 +- includes/model/class-follower.php | 4 ++-- tests/test-class-db-activitypub-followers.php | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/includes/collection/class-followers.php b/includes/collection/class-followers.php index 0948bfb..413af3b 100644 --- a/includes/collection/class-followers.php +++ b/includes/collection/class-followers.php @@ -143,7 +143,7 @@ class Followers { 'single' => true, 'sanitize_callback' => function( $value ) { if ( ! is_numeric( $value ) && (int) $value !== $value ) { - $value = strtotime( 'now' ); + $value = \time(); } return $value; diff --git a/includes/model/class-activity.php b/includes/model/class-activity.php index 34f6146..6a8d45a 100644 --- a/includes/model/class-activity.php +++ b/includes/model/class-activity.php @@ -44,7 +44,7 @@ class Activity { } $this->type = \ucfirst( $type ); - $this->published = \gmdate( 'Y-m-d\TH:i:s\Z', \strtotime( 'now' ) ); + $this->published = \gmdate( 'Y-m-d\TH:i:s\Z', \time() ); } public function __call( $method, $params ) { diff --git a/includes/model/class-follower.php b/includes/model/class-follower.php index 10200c2..0668e4d 100644 --- a/includes/model/class-follower.php +++ b/includes/model/class-follower.php @@ -185,7 +185,7 @@ class Follower { $this->shared_inbox = $meta['inbox']; } - $this->updated_at = \strtotime( 'now' ); + $this->updated_at = \time(); } /** @@ -320,7 +320,7 @@ class Follower { ) ); - $this->updated_at = \strtotime( 'now' ); + $this->updated_at = \time(); $this->update_term_meta(); } diff --git a/tests/test-class-db-activitypub-followers.php b/tests/test-class-db-activitypub-followers.php index cf8b53f..2467363 100644 --- a/tests/test-class-db-activitypub-followers.php +++ b/tests/test-class-db-activitypub-followers.php @@ -102,7 +102,7 @@ class Test_Db_Activitypub_Followers extends WP_UnitTestCase { $follower = new \Activitypub\Model\Follower( 'https://example.com/author/jon' ); - update_term_meta( $follower->get_id(), 'updated_at', strtotime( 'now' ) - 804800 ); + update_term_meta( $follower->get_id(), 'updated_at', \time() - 804800 ); $followers = \Activitypub\Collection\Followers::get_outdated_followers(); $this->assertEquals( 1, count( $followers ) );