Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGS-7030 -- fix PHP warning on add-index #276

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion pantheon-sessions.php
Expand Up @@ -376,7 +376,13 @@ public function add_index() {

$count_query = "SELECT COUNT(*) FROM {$table};";
$count_total = $wpdb->get_results( $count_query );
$count_total = $count_total[0]->{'COUNT(*)'};

// Avoid errors when object returns an empty object.
if ( ! empty( $count_total ) ) {
$count_total = $count_total[0]->{'COUNT(*)'};
} else {
$count_total = 0;
}

if ( $count_total >= 20000 ) {
// translators: %s is the total number of rows that exist in the pantheon_sessions table.
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Expand Up @@ -105,6 +105,7 @@ Adds a WP-CLI command to add an index to the sessions table if one does not exis
== Changelog ==

= 1.4.2-dev =
* Fixed an issue with the `pantheon session add-index` PHP warning.

= 1.4.1 (October 23, 2023) =
* Fixed an issue with the `pantheon session add-index` command not working properly on WP multisite [[#270](https://github.com/pantheon-systems/wp-native-php-sessions/pull/270)]
Expand Down