From d1b7af5efac858d420a9af9c95d22ab648d8e563 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 9 Nov 2023 08:39:00 -0700 Subject: [PATCH 1/2] check if the $output index is set before manipulating it --- pantheon-sessions.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pantheon-sessions.php b/pantheon-sessions.php index be3439e..65362d3 100644 --- a/pantheon-sessions.php +++ b/pantheon-sessions.php @@ -539,7 +539,7 @@ public function add_single_index( $prefix, $output = [], $multisite = false ) { $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table ) ); if ( ! $wpdb->get_var( $query ) == $table ) { $this->safe_output( __( 'This site does not have a pantheon_sessions table, and is being skipped.', 'wp-native-php-sessions' ), 'log' ); - $output['no_session_table'] = $output['no_session_table'] + 1; + $output['no_session_table'] = isset( $output['no_session_table'] ) ? $output['no_session_table'] + 1 : 1; return $output; } @@ -559,7 +559,7 @@ public function add_single_index( $prefix, $output = [], $multisite = false ) { $type = 'log'; } - $output['id_column_exists'] = $output['id_column_exists'] + 1; + $output['id_column_exists'] = isset( $output['id_column_exists'] ) ? $output['id_column_exists'] + 1 : 1; $this->safe_output( __( 'ID column already exists and does not need to be added to the table.', 'wp-native-php-sessions' ), $type ); return $output; @@ -643,7 +643,7 @@ public function primary_key_finalize_single( $prefix = null, $output = [], $mult if ( ! $multisite ) { $type = 'error'; } else { - $output['no_old_table'] = $output['no_old_table'] + 1; + $output['no_old_table'] = isset( $output['no_old_table'] ) ? $output['no_old_table'] + 1 : 1; $type = 'log'; } @@ -688,7 +688,7 @@ public function primary_key_revert_single( $prefix = null, $output = [], $multis if ( ! $wpdb->get_var( $query ) == $old_clone_table ) { $this->safe_output( __( 'There is no old table to roll back to.', 'wp-native-php-sessions' ), $type ); - $output['no_rollback_table'] = $output['no_rollback_table'] + 1; + $output['no_rollback_table'] = isset( $output['no_rollback_table'] ) ? $output['no_rollback_table'] + 1 : 1; return $output; } From 7657557a95d1f79ce7dcab60f8ac117a2afad578 Mon Sep 17 00:00:00 2001 From: Chris Reynolds Date: Thu, 9 Nov 2023 09:45:26 -0700 Subject: [PATCH 2/2] update changelog --- README.md | 1 + readme.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 638f472..f98d670 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,7 @@ Adds a WP-CLI command to add an index to the sessions table if one does not exis ## Changelog ## ### 1.4.3-dev ### +* Fixed a PHP warning when running the `pantheon session add-index` command on a single site installation. [[#285](https://github.com/pantheon-systems/wp-native-php-sessions/pull/285)] ### 1.4.2 (November 8, 2023) ### * Fixed an issue with the `pantheon session add-index` PHP warning. [[#276](https://github.com/pantheon-systems/wp-native-php-sessions/pull/276/files)] diff --git a/readme.txt b/readme.txt index f2d432c..1877f40 100644 --- a/readme.txt +++ b/readme.txt @@ -97,6 +97,7 @@ Adds a WP-CLI command to add an index to the sessions table if one does not exis == Changelog == = 1.4.3-dev = +* Fixed a PHP warning when running the `pantheon session add-index` command on a single site installation. [[#285](https://github.com/pantheon-systems/wp-native-php-sessions/pull/285)] = 1.4.2 (November 8, 2023) = * Fixed an issue with the `pantheon session add-index` PHP warning. [[#276](https://github.com/pantheon-systems/wp-native-php-sessions/pull/276/files)]