Skip to content

Commit

Permalink
use option instead of direct db query
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Dec 29, 2024
1 parent 2a31cdf commit 2b56249
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
17 changes: 7 additions & 10 deletions classes/WpMatomo/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function looks_like_it_is_installed() {
return false;
}

if ( ! $this->is_tables_installed() ) {
if ( ! $this->is_current_instance_installed() ) {
return false;
}

Expand Down Expand Up @@ -198,6 +198,9 @@ public function install() {
Cache::flushAll();

$this->logger->log( 'Matomo install finished' );

$this->settings->set_option( Settings::INSTANCE_INSTALLED_MARKER, 1 );
$this->settings->save();
}

return true;
Expand Down Expand Up @@ -402,14 +405,8 @@ private function update_components() {
$updater->update();
}

private function is_tables_installed() {
global $wpdb;

// phpcs:disable WordPress.DB.DirectDatabaseQuery.NoCaching
// phpcs:disable WordPress.DB.DirectDatabaseQuery.DirectQuery
// phpcs:disable WordPress.DB.PreparedSQL.NotPrepared
$results = $wpdb->get_results( 'SHOW TABLES LIKE `' . $wpdb->prefix . MATOMO_DATABASE_PREFIX . 'option`' );

return ! empty( $results );
private function is_current_instance_installed() {
$is_installed = $this->settings->get_option( Settings::INSTANCE_INSTALLED_MARKER );
return ! empty( $is_installed );
}
}
1 change: 1 addition & 0 deletions classes/WpMatomo/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Settings {
const SITE_CURRENCY = 'site_currency';
const NETWORK_CONFIG_OPTIONS = 'config_options';
const DISABLE_ASYNC_ARCHIVING_OPTION_NAME = 'matomo_disable_async_archiving';
const INSTANCE_INSTALLED_MARKER = 'instance-installed';

public static $is_doing_action_tracking_related = false;
/**
Expand Down

0 comments on commit 2b56249

Please sign in to comment.