Skip to content

Commit

Permalink
[BUGS-7105] check if the $output index is set before manipulating it (
Browse files Browse the repository at this point in the history
#285)

* check if the $output index is set before manipulating it

* update changelog
  • Loading branch information
jazzsequence authored Nov 13, 2023
1 parent 47af406 commit f3b04da
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
8 changes: 4 additions & 4 deletions pantheon-sessions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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';
}

Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down

0 comments on commit f3b04da

Please sign in to comment.