PluginProbe
The Innovative Form Builder – IvyForms / 1.1
The Innovative Form Builder – IvyForms v1.1
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Services / InstallActions / Migrations / ConvertNotificationSmartLogicToText.php

ConvertNotificationSmartLogicToText.php in The Innovative Form Builder – IvyForms 1.1, at backend/src/Services/InstallActions/Migrations/ConvertNotificationSmartLogicToText.php

34 lines 919 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace IvyForms\Services\InstallActions\Migrations;
4
5 use IvyForms\Common\Exceptions\InvalidArgumentException;
6 use IvyForms\Services\InstallActions\DB\Notification\NotificationsTable;
7
8 class ConvertNotificationSmartLogicToText
9 {
10 /**
11 * @throws InvalidArgumentException
12 */
13 public static function run(): bool
14 {
15 global $wpdb;
16
17 $tableName = NotificationsTable::getTableName();
18 $column = $wpdb->get_row("SHOW COLUMNS FROM `{$tableName}` LIKE 'smartLogic'", ARRAY_A);
19
20 if (!$column) {
21 return true;
22 }
23
24 $columnType = strtolower((string)($column['Type'] ?? ''));
25 if (strpos($columnType, 'text') !== false || strpos($columnType, 'varchar') !== false) {
26 return true;
27 }
28
29 $result = $wpdb->query("ALTER TABLE `{$tableName}` MODIFY COLUMN `smartLogic` TEXT NULL");
30
31 return $result !== false;
32 }
33 }
34