| 1 |
<?php |
| 2 |
|
| 3 |
namespace IvyForms\Services\InstallActions\Migrations; |
| 4 |
|
| 5 |
use IvyForms\Common\Exceptions\InvalidArgumentException; |
| 6 |
use IvyForms\Services\InstallActions\DB\Payment\OrdersTable; |
| 7 |
|
| 8 |
/** |
| 9 |
* Creates the orders table on existing installs that were not re-activated after the feature shipped. |
| 10 |
*/ |
| 11 |
class EnsureOrdersTable |
| 12 |
{ |
| 13 |
/** |
| 14 |
* @return bool |
| 15 |
*/ |
| 16 |
public static function run(): bool |
| 17 |
{ |
| 18 |
global $wpdb; |
| 19 |
|
| 20 |
try { |
| 21 |
$tableName = OrdersTable::getTableName(); |
| 22 |
} catch (InvalidArgumentException $e) { |
| 23 |
return false; |
| 24 |
} |
| 25 |
|
| 26 |
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.DirectQuery |
| 27 |
if ($wpdb->get_var($wpdb->prepare('SHOW TABLES LIKE %s', $tableName)) === $tableName) { |
| 28 |
return true; |
| 29 |
} |
| 30 |
|
| 31 |
OrdersTable::init(); |
| 32 |
|
| 33 |
return true; |
| 34 |
} |
| 35 |
} |
| 36 |
|