Reset "install_timestamp" if it's not numeric to avoid TypeError (https://github.com/woocommerce/woocommerce-admin/pull/8100)
* Reset install_timestamp if it's not numeric to avoid type error Fix indent * Add changelogs * Remove ununnecessary logic
This commit is contained in:
parent
aa9f2df07f
commit
2f290d79a9
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: Fix
|
||||||
|
|
||||||
|
Reset "install_timestamp" if it's not numeric to avoid TypeError. #8100
|
|
@ -48,7 +48,7 @@ class WCAdminHelper {
|
||||||
public static function get_wcadmin_active_for_in_seconds() {
|
public static function get_wcadmin_active_for_in_seconds() {
|
||||||
$install_timestamp = get_option( self::WC_ADMIN_TIMESTAMP_OPTION );
|
$install_timestamp = get_option( self::WC_ADMIN_TIMESTAMP_OPTION );
|
||||||
|
|
||||||
if ( false === $install_timestamp ) {
|
if ( ! is_numeric( $install_timestamp ) ) {
|
||||||
$install_timestamp = time();
|
$install_timestamp = time();
|
||||||
update_option( self::WC_ADMIN_TIMESTAMP_OPTION, $install_timestamp );
|
update_option( self::WC_ADMIN_TIMESTAMP_OPTION, $install_timestamp );
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,15 @@ use \Automattic\WooCommerce\Admin\WCAdminHelper;
|
||||||
*/
|
*/
|
||||||
class WC_Admin_Tests_Admin_Helper extends WP_UnitTestCase {
|
class WC_Admin_Tests_Admin_Helper extends WP_UnitTestCase {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test get_wcadmin_active_for_in_seconds_with with invalid timestamp option.
|
||||||
|
*/
|
||||||
|
public function test_get_wcadmin_active_for_in_seconds_with_invalid_timestamp_option() {
|
||||||
|
update_option( WCAdminHelper::WC_ADMIN_TIMESTAMP_OPTION, 'invalid-time' );
|
||||||
|
$this->assertEquals( is_numeric( WCAdminHelper::get_wcadmin_active_for_in_seconds() ), true );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test wc_admin_active_for one hour
|
* Test wc_admin_active_for one hour
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue