Skip to content

Commit b7b8f57

Browse files
authored
Merge pull request #4 from BrianHenryIE/dev
v1.0.2
2 parents 4500dae + 27dcaf5 commit b7b8f57

File tree

6 files changed

+67
-6
lines changed

6 files changed

+67
-6
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
### 1.0.2
4+
5+
* Fixed PHP warning when loading settings page first time due to empty values.
6+
37
### 1.0.1
48
* Fixed bug with IPv6 where : was a disallowed character in the cache key.
59
* Changed the HTML "step" from 60 to 1 – I had thought it would step by 60 but still allow % values.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[![WordPress tested 5.7](https://img.shields.io/badge/WordPress-v5.7%20tested-0073aa.svg)](https://wordpress.org/plugins/plugin_slug) [![PHPCS WPCS](https://img.shields.io/badge/PHPCS-WordPress%20Coding%20Standards-8892BF.svg)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) [![PHPStan ](.github/phpstan.svg)](https://github.com/szepeviktor/phpstan-wordpress) [![PHPUnit ](.github/coverage.svg)](https://brianhenryie.github.io/bh-wc-checkout-rate-limiter/)
1+
[![WordPress tested 5.7](https://img.shields.io/badge/WordPress-v5.7%20tested-0073aa.svg)](https://wordpress.org/plugins/bh-wc-checkout-rate-limiter) [![PHPCS WPCS](https://img.shields.io/badge/PHPCS-WordPress%20Coding%20Standards-8892BF.svg)](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards) [![PHPStan ](.github/phpstan.svg)](https://github.com/szepeviktor/phpstan-wordpress) [![PHPUnit ](.github/coverage.svg)](https://brianhenryie.github.io/bh-wc-checkout-rate-limiter/)
22

33
# Checkout Rate Limiter
44

src/README.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,14 @@ directory take precedence. For example, `/assets/screenshot-1.png` would win ove
6868

6969
== Changelog ==
7070

71+
= 1.0.2 =
72+
73+
Fixed PHP warning when loading settings page first time due to empty values.
74+
7175
= 1.0.1 =
7276
* Fixed bug with IPv6 where : was a disallowed character in the cache key.
7377
* Changed the HTML "step" from 60 to 1 – I had thought it would step by 60 but still allow % values.
7478

75-
= 0.5 =
76-
* List versions from most recent at top to oldest at bottom.
77-
7879
== Upgrade Notice ==
7980

8081
= 1.0 =

src/WooCommerce/class-settings-advanced.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ public function print_attempts_per_interval_settings_field( array $value ): void
162162

163163
$option_value = $value['value'];
164164

165+
if( !isset( $option_value['attempts'] ) ) {
166+
$option_value['attempts'] = '';
167+
}
168+
169+
if( !isset( $option_value['interval'] ) ) {
170+
$option_value['interval'] = '';
171+
}
172+
165173
// Description handling... copied from WooCommerce WC_Admin_Settings.
166174
$field_description = WC_Admin_Settings::get_field_description( $value );
167175
$description = $field_description['description'];

src/bh-wc-checkout-rate-limiter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Plugin Name: Checkout Rate Limiter
1616
* Plugin URI: http://github.com/brianhenryie/bh-wc-checkout-rate-limiter/
1717
* Description: Rate limit the WooCommerce checkout to prevent card attacks.
18-
* Version: 1.0.1
18+
* Version: 1.0.2
1919
* Author: BrianHenryIE
2020
* Author URI: https://BrianHenry.IE
2121
* License: GPL-2.0+
@@ -44,7 +44,7 @@
4444
* Start at version 1.0.0 and use SemVer - https://semver.org
4545
* Rename this for your plugin and update it as you release new versions.
4646
*/
47-
define( 'BH_WC_CHECKOUT_RATE_LIMITER_VERSION', '1.0.1' );
47+
define( 'BH_WC_CHECKOUT_RATE_LIMITER_VERSION', '1.0.2' );
4848

4949
register_activation_hook( __FILE__, array( Activator::class, 'activate' ) );
5050
register_deactivation_hook( __FILE__, array( Deactivator::class, 'deactivate' ) );
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace BrianHenryIE\Checkout_Rate_Limiter\WooCommerce;
4+
5+
use BrianHenryIE\Checkout_Rate_Limiter\API\Settings_Interface;
6+
use BrianHenryIE\Checkout_Rate_Limiter\Psr\Log\NullLogger;
7+
use \Exception;
8+
9+
/**
10+
* @covers BrianHenryIE\Checkout_Rate_Limiter\WooCommerce\Settings_Advanced
11+
*
12+
* Class Ajax_WPUnit_Test
13+
* @package BrianHenryIE\Checkout_Rate_Limiter\WooCommerce
14+
*/
15+
class Settings_Advanced_WPUnit_Test extends \Codeception\TestCase\WPTestCase {
16+
17+
/**
18+
* When the settings page is first loaded, the values for the rates are not yet set, causing a PHP warning:
19+
*
20+
* `PHP Warning: Illegal string offset 'interval' in .../WooCommerce/class-settings-advanced.php on line 196`
21+
*/
22+
public function test_first_run_empty_variables() {
23+
24+
$settings = $this->makeEmpty( Settings_Interface::class );
25+
$logger = new NullLogger();
26+
27+
$sut = new Settings_Advanced( $settings, $logger );
28+
29+
$value = array(
30+
'value' => array(),
31+
'id' => '',
32+
'class' => '',
33+
'title' => '',
34+
'desc_tip' => '',
35+
);
36+
37+
$exception = null;
38+
try {
39+
$sut->print_attempts_per_interval_settings_field($value);
40+
} catch ( \PHPUnit\Framework\Exception $e ) {
41+
$exception = $e;
42+
}
43+
44+
$this->assertNull( $exception );
45+
46+
}
47+
48+
}

0 commit comments

Comments
 (0)