PluginProbe
The Innovative Form Builder – IvyForms / 1.4
The Innovative Form Builder – IvyForms v1.4
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 / ExpandReceiverColumnInNotifications.php

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

37 lines 903 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\Services\InstallActions\DB\Notification\NotificationsTable;
6
7 class ExpandReceiverColumnInNotifications
8 {
9 /**
10 * Run the migration
11 *
12 * @return bool
13 */
14 public static function run(): bool
15 {
16 global $wpdb;
17
18 $tableName = NotificationsTable::getTableName();
19 $column = $wpdb->get_row("SHOW COLUMNS FROM `{$tableName}` LIKE 'receiver'", ARRAY_A);
20
21 if (!$column) {
22 return true;
23 }
24
25 $columnType = strtolower((string) ($column['Type'] ?? ''));
26 if (preg_match('/varchar\((\d+)\)/', $columnType, $matches) && (int) $matches[1] >= 500) {
27 return true;
28 }
29
30 $result = $wpdb->query(
31 "ALTER TABLE `{$tableName}` MODIFY COLUMN `receiver` VARCHAR(500) NULL"
32 );
33
34 return $result !== false;
35 }
36 }
37