diff --git a/composer.lock b/composer.lock
index df648e7a..20ae4a3c 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1644,16 +1644,16 @@
},
{
"name": "illuminate/collections",
- "version": "v10.17.0",
+ "version": "v10.17.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/collections.git",
- "reference": "bc030c443fc43776070b96d66257c3b29153f30a"
+ "reference": "66ff5aab0dd10659aff0efe3ff101819db192dfe"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/illuminate/collections/zipball/bc030c443fc43776070b96d66257c3b29153f30a",
- "reference": "bc030c443fc43776070b96d66257c3b29153f30a",
+ "url": "https://api.github.com/repos/illuminate/collections/zipball/66ff5aab0dd10659aff0efe3ff101819db192dfe",
+ "reference": "66ff5aab0dd10659aff0efe3ff101819db192dfe",
"shasum": ""
},
"require": {
@@ -1695,11 +1695,11 @@
"issues": "https://github.com/laravel/framework/issues",
"source": "https://github.com/laravel/framework"
},
- "time": "2023-07-27T15:19:34+00:00"
+ "time": "2023-08-02T14:57:32+00:00"
},
{
"name": "illuminate/conditionable",
- "version": "v10.17.0",
+ "version": "v10.17.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/conditionable.git",
@@ -1745,7 +1745,7 @@
},
{
"name": "illuminate/contracts",
- "version": "v10.17.0",
+ "version": "v10.17.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/contracts.git",
@@ -1793,7 +1793,7 @@
},
{
"name": "illuminate/macroable",
- "version": "v10.17.0",
+ "version": "v10.17.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/macroable.git",
@@ -1839,7 +1839,7 @@
},
{
"name": "illuminate/support",
- "version": "v10.17.0",
+ "version": "v10.17.1",
"source": {
"type": "git",
"url": "https://github.com/illuminate/support.git",
@@ -4293,16 +4293,16 @@
},
{
"name": "sebastian/global-state",
- "version": "5.0.5",
+ "version": "5.0.6",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/global-state.git",
- "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2"
+ "reference": "bde739e7565280bda77be70044ac1047bc007e34"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/0ca8db5a5fc9c8646244e629625ac486fa286bf2",
- "reference": "0ca8db5a5fc9c8646244e629625ac486fa286bf2",
+ "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bde739e7565280bda77be70044ac1047bc007e34",
+ "reference": "bde739e7565280bda77be70044ac1047bc007e34",
"shasum": ""
},
"require": {
@@ -4345,7 +4345,7 @@
],
"support": {
"issues": "https://github.com/sebastianbergmann/global-state/issues",
- "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.5"
+ "source": "https://github.com/sebastianbergmann/global-state/tree/5.0.6"
},
"funding": [
{
@@ -4353,7 +4353,7 @@
"type": "github"
}
],
- "time": "2022-02-14T08:28:10+00:00"
+ "time": "2023-08-02T09:26:13+00:00"
},
{
"name": "sebastian/lines-of-code",
diff --git a/phpstan.neon.dist b/phpstan.neon.dist
index 26605199..16672ff5 100644
--- a/phpstan.neon.dist
+++ b/phpstan.neon.dist
@@ -1,5 +1,5 @@
parameters:
- level: 6
+ level: 7
inferPrivatePropertyTypeFromConstructor: true
checkMissingIterableValueType: false
stubFiles:
diff --git a/src/Admin/Editor.php b/src/Admin/Editor.php
index ee96165c..48e9438c 100644
--- a/src/Admin/Editor.php
+++ b/src/Admin/Editor.php
@@ -50,7 +50,9 @@ public function validate_before_save_cb( $data, $post ) {
$existing_post = get_post( $post['ID'] );
// Overwrite new/invalid query with previous working query, or empty
- $data['post_content'] = $existing_post->post_content;
+ if ( $existing_post ) {
+ $data['post_content'] = $existing_post->post_content;
+ }
AdminErrors::add_message( $e->getMessage() );
}
@@ -170,18 +172,21 @@ public static function grant_input_box_cb( $post ) {
checked( $value, Grant::USE_DEFAULT, false )
);
$html .= '
';
+
+ /** @var array[] */
+ $allowed_html = [
+ 'input' => [
+ 'type' => true,
+ 'id' => true,
+ 'name' => true,
+ 'value' => true,
+ 'checked' => true,
+ ],
+ 'br' => true,
+ ];
echo wp_kses(
$html,
- [
- 'input' => [
- 'type' => true,
- 'id' => true,
- 'name' => true,
- 'value' => true,
- 'checked' => true,
- ],
- 'br' => true,
- ]
+ $allowed_html
);
}
@@ -196,9 +201,21 @@ public static function maxage_input_box_cb( $post ) {
$max_age = new MaxAge();
$value = $max_age->get( $post->ID );
- $value = absint( $value ) ? $value : 0;
- $html = sprintf( '', $value );
- $html .= '
';
+
+ if ( is_wp_error( $value ) ) {
+ AdminErrors::add_message(
+ sprintf(
+ __( 'Invalid max age %s.', 'wp-graphql-smart-cache' ),
+ $value->get_error_message()
+ )
+ );
+ $value = 0;
+ } else {
+ $value = absint( $value ) ? $value : 0;
+ }
+
+ $html = sprintf( '', $value );
+ $html .= '
';
echo wp_kses(
$html,
[
@@ -271,7 +288,9 @@ public function make_excerpt_column_sortable_in_admin_cb( $columns ) {
* @return array
*/
public function wp_editor_settings( $settings, $editor_id ) {
- if ( 'content' === $editor_id && Document::TYPE_NAME === get_current_screen()->post_type ) {
+ $screen = get_current_screen();
+
+ if ( $screen && 'content' === $editor_id && Document::TYPE_NAME === $screen->post_type ) {
$settings['tinymce'] = false;
$settings['quicktags'] = false;
$settings['media_buttons'] = false;
diff --git a/src/AdminErrors.php b/src/AdminErrors.php
index f66bc234..48a2fa28 100644
--- a/src/AdminErrors.php
+++ b/src/AdminErrors.php
@@ -45,15 +45,19 @@ public function display_validation_messages() {
foreach ( $error_messages as $message ) {
$html = sprintf( '
%s