fix: Reimplemented table verification

Verifies indexes and not only table existence
This commit is contained in:
Sibin Grasic 2024-02-01 18:51:09 +01:00
parent ef18640e48
commit 0bb0c1927e
No known key found for this signature in database
GPG key ID: 50E9E60C329EC8C1
5 changed files with 593 additions and 80 deletions

View file

@ -19,8 +19,5 @@ indent_size = 2
[*.js]
indent_size = 2

[{composer.json,package.json}]
indent_size = 4

[*.md]
trim_trailing_whitespace = false

View file

@ -1,34 +0,0 @@
## [2.1.1](https://github.com/oblakstudio/wp-plugin-installer/compare/v2.1.0...v2.1.1) (2024-01-05)


### Bug Fixes

* Instance basename sorted ([dfba698](https://github.com/oblakstudio/wp-plugin-installer/commit/dfba698486924c3b7680bf3ea6bb64e4a2298b22))

# [2.1.0](https://github.com/oblakstudio/wp-plugin-installer/compare/v2.0.4...v2.1.0) (2024-01-03)


### Features

* Added db verification to WooCommerce Tools ([97510f8](https://github.com/oblakstudio/wp-plugin-installer/commit/97510f8b99f7273496f4ebb1fb92147ed7a10880))

## [2.0.4](https://github.com/oblakstudio/wp-plugin-installer/compare/v2.0.3...v2.0.4) (2023-12-29)


### Bug Fixes

* Typo fix ([c79341f](https://github.com/oblakstudio/wp-plugin-installer/commit/c79341f97e20efac656150f3d12ab4d5ede16fd8))

## [2.0.3](https://github.com/oblakstudio/wp-plugin-installer/compare/v2.0.2...v2.0.3) (2023-12-29)


### Bug Fixes

* Typo fix ([dcc722a](https://github.com/oblakstudio/wp-plugin-installer/commit/dcc722ad19496b0b9c15aab9d63ec43d1e2194f3))

## [2.0.2](https://github.com/oblakstudio/wp-plugin-installer/compare/v2.0.1...v2.0.2) (2023-12-29)


### Bug Fixes

* **build:** Fixed release process ([f8e6f2b](https://github.com/oblakstudio/wp-plugin-installer/commit/f8e6f2bebf904068e059529fd0d346e7488f1a09))

View file

@ -1,42 +1,43 @@
{
"name": "oblak/wp-plugin-installer",
"description": "Simplifies the installation and activation of WordPress plugins",
"authors": [
{
"name": "Sibin Grasic",
"email": "sibin.grasic@oblak.studio"
}
],
"license": "GPL-2.0-only",
"version": "2.1.1",
"type": "library",
"require": {
"php": ">= 8.0",
"automattic/jetpack-constants": "^2",
"oblak/admin-notice-manager": "^2",
"woocommerce/action-scheduler": "^3.7"
},
"require-dev": {
"oblak/wordpress-coding-standard": "^1"
},
"suggest": {
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
},
"autoload": {
"psr-4": {
"Oblak\\WP\\": "src"
},
"files": [
"src/wppi-as-loader.php"
]
},
"config": {
"classmap-authoritative": true,
"optimize-autoloader": true,
"sort-packages": true,
"allow-plugins": {
"automattic/jetpack-autoloader": true,
"dealerdirect/phpcodesniffer-composer-installer": true
}
"name": "oblak/wp-plugin-installer",
"description": "Simplifies the installation and activation of WordPress plugins",
"license": "GPL-2.0-only",
"type": "library",
"authors": [
{
"name": "Sibin Grasic",
"email": "sibin.grasic@oblak.studio"
}
],
"require": {
"php": ">= 8.0",
"automattic/jetpack-constants": "^2",
"oblak/admin-notice-manager": "^2",
"woocommerce/action-scheduler": "^3.7"
},
"require-dev": {
"ergebnis/composer-normalize": "^2.42",
"oblak/wordpress-coding-standard": "^1"
},
"suggest": {
"automattic/jetpack-autoloader": "Allow for better interoperability with other plugins that use this package."
},
"autoload": {
"psr-4": {
"Oblak\\WP\\": "src"
},
"files": [
"src/wppi-as-loader.php"
]
},
"config": {
"allow-plugins": {
"automattic/jetpack-autoloader": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"ergebnis/composer-normalize": true
},
"classmap-authoritative": true,
"optimize-autoloader": true,
"sort-packages": true
}
}

541
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "6d3fa32e587ce0a20a9b7a089fff6050",
"content-hash": "a762970ddcb11ee1a26bab32fbc7f6bc",
"packages": [
{
"name": "automattic/jetpack-constants",
@ -220,6 +220,545 @@
},
"time": "2023-01-05T11:28:13+00:00"
},
{
"name": "ergebnis/composer-normalize",
"version": "2.42.0",
"source": {
"type": "git",
"url": "https://github.com/ergebnis/composer-normalize.git",
"reference": "02cf2b69ad2a74c6f11a8c3f5f054b8f949df910"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ergebnis/composer-normalize/zipball/02cf2b69ad2a74c6f11a8c3f5f054b8f949df910",
"reference": "02cf2b69ad2a74c6f11a8c3f5f054b8f949df910",
"shasum": ""
},
"require": {
"composer-plugin-api": "^2.0.0",
"ergebnis/json": "^1.2.0",
"ergebnis/json-normalizer": "^4.5.0",
"ergebnis/json-printer": "^3.5.0",
"ext-json": "*",
"justinrainbow/json-schema": "^5.2.12",
"localheinz/diff": "^1.1.1",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"composer/composer": "^2.6.6",
"ergebnis/license": "^2.4.0",
"ergebnis/php-cs-fixer-config": "^6.20.0",
"ergebnis/phpunit-slow-test-detector": "^2.9.0",
"fakerphp/faker": "^1.23.1",
"infection/infection": "~0.26.6",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "~0.18.4",
"rector/rector": "~0.19.2",
"symfony/filesystem": "^5.4.25",
"vimeo/psalm": "^5.20.0"
},
"type": "composer-plugin",
"extra": {
"class": "Ergebnis\\Composer\\Normalize\\NormalizePlugin",
"composer-normalize": {
"indent-size": 2,
"indent-style": "space"
},
"plugin-optional": true
},
"autoload": {
"psr-4": {
"Ergebnis\\Composer\\Normalize\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Möller",
"email": "am@localheinz.com",
"homepage": "https://localheinz.com"
}
],
"description": "Provides a composer plugin for normalizing composer.json.",
"homepage": "https://github.com/ergebnis/composer-normalize",
"keywords": [
"composer",
"normalize",
"normalizer",
"plugin"
],
"support": {
"issues": "https://github.com/ergebnis/composer-normalize/issues",
"security": "https://github.com/ergebnis/composer-normalize/blob/main/.github/SECURITY.md",
"source": "https://github.com/ergebnis/composer-normalize"
},
"time": "2024-01-30T11:54:02+00:00"
},
{
"name": "ergebnis/json",
"version": "1.2.0",
"source": {
"type": "git",
"url": "https://github.com/ergebnis/json.git",
"reference": "a457f25a5ba7ea11fc94f84d53678c5211abfce0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ergebnis/json/zipball/a457f25a5ba7ea11fc94f84d53678c5211abfce0",
"reference": "a457f25a5ba7ea11fc94f84d53678c5211abfce0",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"ergebnis/data-provider": "^3.2.0",
"ergebnis/license": "^2.4.0",
"ergebnis/php-cs-fixer-config": "^6.20.0",
"ergebnis/phpunit-slow-test-detector": "^2.9.0",
"fakerphp/faker": "^1.23.1",
"infection/infection": "~0.26.6",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "~0.18.4",
"rector/rector": "~0.19.2",
"vimeo/psalm": "^5.20.0"
},
"type": "library",
"extra": {
"composer-normalize": {
"indent-size": 2,
"indent-style": "space"
}
},
"autoload": {
"psr-4": {
"Ergebnis\\Json\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Möller",
"email": "am@localheinz.com",
"homepage": "https://localheinz.com"
}
],
"description": "Provides a Json value object for representing a valid JSON string.",
"homepage": "https://github.com/ergebnis/json",
"keywords": [
"json"
],
"support": {
"issues": "https://github.com/ergebnis/json/issues",
"security": "https://github.com/ergebnis/json/blob/main/.github/SECURITY.md",
"source": "https://github.com/ergebnis/json"
},
"time": "2024-01-29T15:09:24+00:00"
},
{
"name": "ergebnis/json-normalizer",
"version": "4.5.0",
"source": {
"type": "git",
"url": "https://github.com/ergebnis/json-normalizer.git",
"reference": "f0ee9e70739f121b27fac8b743e4a52b23de2152"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ergebnis/json-normalizer/zipball/f0ee9e70739f121b27fac8b743e4a52b23de2152",
"reference": "f0ee9e70739f121b27fac8b743e4a52b23de2152",
"shasum": ""
},
"require": {
"ergebnis/json": "^1.2.0",
"ergebnis/json-pointer": "^3.4.0",
"ergebnis/json-printer": "^3.5.0",
"ergebnis/json-schema-validator": "^4.2.0",
"ext-json": "*",
"justinrainbow/json-schema": "^5.2.12",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"composer/semver": "^3.4.0",
"ergebnis/data-provider": "^3.2.0",
"ergebnis/license": "^2.4.0",
"ergebnis/php-cs-fixer-config": "^6.20.0",
"ergebnis/phpunit-slow-test-detector": "^2.9.0",
"fakerphp/faker": "^1.23.1",
"infection/infection": "~0.26.6",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "~0.18.4",
"rector/rector": "~0.19.4",
"vimeo/psalm": "^5.20.0"
},
"suggest": {
"composer/semver": "If you want to use ComposerJsonNormalizer or VersionConstraintNormalizer"
},
"type": "library",
"autoload": {
"psr-4": {
"Ergebnis\\Json\\Normalizer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Möller",
"email": "am@localheinz.com",
"homepage": "https://localheinz.com"
}
],
"description": "Provides generic and vendor-specific normalizers for normalizing JSON documents.",
"homepage": "https://github.com/ergebnis/json-normalizer",
"keywords": [
"json",
"normalizer"
],
"support": {
"issues": "https://github.com/ergebnis/json-normalizer/issues",
"security": "https://github.com/ergebnis/json-normalizer/blob/main/.github/SECURITY.md",
"source": "https://github.com/ergebnis/json-normalizer"
},
"time": "2024-01-30T09:10:15+00:00"
},
{
"name": "ergebnis/json-pointer",
"version": "3.4.0",
"source": {
"type": "git",
"url": "https://github.com/ergebnis/json-pointer.git",
"reference": "b654757d873050622c2166f55ab25d04685261c5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ergebnis/json-pointer/zipball/b654757d873050622c2166f55ab25d04685261c5",
"reference": "b654757d873050622c2166f55ab25d04685261c5",
"shasum": ""
},
"require": {
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"ergebnis/data-provider": "^3.2.0",
"ergebnis/license": "^2.4.0",
"ergebnis/php-cs-fixer-config": "^6.20.0",
"ergebnis/phpunit-slow-test-detector": "^2.9.0",
"fakerphp/faker": "^1.23.1",
"infection/infection": "~0.26.6",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "~0.18.4",
"rector/rector": "~0.19.2",
"vimeo/psalm": "^5.20.0"
},
"type": "library",
"extra": {
"composer-normalize": {
"indent-size": 2,
"indent-style": "space"
}
},
"autoload": {
"psr-4": {
"Ergebnis\\Json\\Pointer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Möller",
"email": "am@localheinz.com",
"homepage": "https://localheinz.com"
}
],
"description": "Provides an abstraction of a JSON pointer.",
"homepage": "https://github.com/ergebnis/json-pointer",
"keywords": [
"RFC6901",
"json",
"pointer"
],
"support": {
"issues": "https://github.com/ergebnis/json-pointer/issues",
"security": "https://github.com/ergebnis/json-pointer/blob/main/.github/SECURITY.md",
"source": "https://github.com/ergebnis/json-pointer"
},
"time": "2024-01-29T16:37:15+00:00"
},
{
"name": "ergebnis/json-printer",
"version": "3.5.0",
"source": {
"type": "git",
"url": "https://github.com/ergebnis/json-printer.git",
"reference": "549e16fe6de34b8c3aee7b421be12caa552f3ced"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ergebnis/json-printer/zipball/549e16fe6de34b8c3aee7b421be12caa552f3ced",
"reference": "549e16fe6de34b8c3aee7b421be12caa552f3ced",
"shasum": ""
},
"require": {
"ext-json": "*",
"ext-mbstring": "*",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"ergebnis/data-provider": "^3.2.0",
"ergebnis/license": "^2.4.0",
"ergebnis/php-cs-fixer-config": "^6.20.0",
"ergebnis/phpunit-slow-test-detector": "^2.9.0",
"fakerphp/faker": "^1.23.1",
"infection/infection": "~0.26.6",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "~0.18.4",
"rector/rector": "~0.19.2",
"vimeo/psalm": "^5.20.0"
},
"type": "library",
"autoload": {
"psr-4": {
"Ergebnis\\Json\\Printer\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Möller",
"email": "am@localheinz.com",
"homepage": "https://localheinz.com"
}
],
"description": "Provides a JSON printer, allowing for flexible indentation.",
"homepage": "https://github.com/ergebnis/json-printer",
"keywords": [
"formatter",
"json",
"printer"
],
"support": {
"issues": "https://github.com/ergebnis/json-printer/issues",
"security": "https://github.com/ergebnis/json-printer/blob/main/.github/SECURITY.md",
"source": "https://github.com/ergebnis/json-printer"
},
"time": "2024-01-29T15:33:37+00:00"
},
{
"name": "ergebnis/json-schema-validator",
"version": "4.2.0",
"source": {
"type": "git",
"url": "https://github.com/ergebnis/json-schema-validator.git",
"reference": "10ed514fdc3f9b71f8a92c567afea21a2f6fa1ef"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ergebnis/json-schema-validator/zipball/10ed514fdc3f9b71f8a92c567afea21a2f6fa1ef",
"reference": "10ed514fdc3f9b71f8a92c567afea21a2f6fa1ef",
"shasum": ""
},
"require": {
"ergebnis/json": "^1.2.0",
"ergebnis/json-pointer": "^3.4.0",
"ext-json": "*",
"justinrainbow/json-schema": "^5.2.12",
"php": "~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0"
},
"require-dev": {
"ergebnis/data-provider": "^3.2.0",
"ergebnis/license": "^2.4.0",
"ergebnis/php-cs-fixer-config": "^6.20.0",
"ergebnis/phpunit-slow-test-detector": "^2.9.0",
"fakerphp/faker": "^1.23.1",
"infection/infection": "~0.26.6",
"phpunit/phpunit": "^9.6.16",
"psalm/plugin-phpunit": "~0.18.4",
"rector/rector": "~0.19.2",
"vimeo/psalm": "^5.20.0"
},
"type": "library",
"extra": {
"composer-normalize": {
"indent-size": 2,
"indent-style": "space"
}
},
"autoload": {
"psr-4": {
"Ergebnis\\Json\\SchemaValidator\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Andreas Möller",
"email": "am@localheinz.com",
"homepage": "https://localheinz.com"
}
],
"description": "Provides a JSON schema validator, building on top of justinrainbow/json-schema.",
"homepage": "https://github.com/ergebnis/json-schema-validator",
"keywords": [
"json",
"schema",
"validator"
],
"support": {
"issues": "https://github.com/ergebnis/json-schema-validator/issues",
"security": "https://github.com/ergebnis/json-schema-validator/blob/main/.github/SECURITY.md",
"source": "https://github.com/ergebnis/json-schema-validator"
},
"time": "2024-01-29T16:50:15+00:00"
},
{
"name": "justinrainbow/json-schema",
"version": "v5.2.13",
"source": {
"type": "git",
"url": "https://github.com/justinrainbow/json-schema.git",
"reference": "fbbe7e5d79f618997bc3332a6f49246036c45793"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793",
"reference": "fbbe7e5d79f618997bc3332a6f49246036c45793",
"shasum": ""
},
"require": {
"php": ">=5.3.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "~2.2.20||~2.15.1",
"json-schema/json-schema-test-suite": "1.2.0",
"phpunit/phpunit": "^4.8.35"
},
"bin": [
"bin/validate-json"
],
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.0.x-dev"
}
},
"autoload": {
"psr-4": {
"JsonSchema\\": "src/JsonSchema/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Bruno Prieto Reis",
"email": "bruno.p.reis@gmail.com"
},
{
"name": "Justin Rainbow",
"email": "justin.rainbow@gmail.com"
},
{
"name": "Igor Wiedler",
"email": "igor@wiedler.ch"
},
{
"name": "Robert Schönthal",
"email": "seroscho@googlemail.com"
}
],
"description": "A library to validate a json schema.",
"homepage": "https://github.com/justinrainbow/json-schema",
"keywords": [
"json",
"schema"
],
"support": {
"issues": "https://github.com/justinrainbow/json-schema/issues",
"source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13"
},
"time": "2023-09-26T02:20:38+00:00"
},
{
"name": "localheinz/diff",
"version": "1.1.1",
"source": {
"type": "git",
"url": "https://github.com/localheinz/diff.git",
"reference": "851bb20ea8358c86f677f5f111c4ab031b1c764c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/localheinz/diff/zipball/851bb20ea8358c86f677f5f111c4ab031b1c764c",
"reference": "851bb20ea8358c86f677f5f111c4ab031b1c764c",
"shasum": ""
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^4.2 || ^5"
},
"type": "library",
"autoload": {
"classmap": [
"src/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Sebastian Bergmann",
"email": "sebastian@phpunit.de"
},
{
"name": "Kore Nordmann",
"email": "mail@kore-nordmann.de"
}
],
"description": "Fork of sebastian/diff for use with ergebnis/composer-normalize",
"homepage": "https://github.com/localheinz/diff",
"keywords": [
"diff",
"udiff",
"unidiff",
"unified diff"
],
"support": {
"source": "https://github.com/localheinz/diff/tree/main"
},
"funding": [
{
"url": "https://github.com/sebastianbergmann",
"type": "github"
}
],
"time": "2020-07-06T04:49:32+00:00"
},
{
"name": "oblak/wordpress-coding-standard",
"version": "v1.0.1",

View file

@ -247,6 +247,8 @@ abstract class Base_Plugin_Installer {
final public function verify_base_tables( $modify_notice = true, $execute = false ) {
require_once ABSPATH . 'wp-admin/includes/upgrade.php';

global $wpdb;

if ( $execute ) {
$this->create_tables();
}
@ -255,9 +257,11 @@ abstract class Base_Plugin_Installer {
$missing_tables = array();

foreach ( $queries as $table_name => $result ) {
if ( "Created table {$table_name}" === $result ) {
$missing_tables[] = $table_name;
if ( is_numeric( $table_name ) || ! str_contains( $table_name, $wpdb->prefix ) ) {
continue;
}

$missing_tables[] = strtok( $table_name, '.' );
}

if ( 0 < count( $missing_tables ) ) {
@ -567,7 +571,13 @@ abstract class Base_Plugin_Installer {
* : Create the missing tables.
*/
final public function cli_verify_tables( $args = array(), $assoc_args = array() ) {
$results = $this->verify_base_tables();
$results = $this->verify_base_tables();
$assoc_args = wp_parse_args(
$assoc_args,
array(
'create' => false,
)
);

if ( empty( $results ) ) {
WP_CLI::success( __( 'All database tables are up to date.', 'oblak-plugin-installer' ) );