| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.9/wp-content/plugins/fluentform/app/Modules/Payments/Migrations/ |
Upload File : |
<?php
namespace FluentForm\App\Modules\Payments\Migrations;
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly.
}
class OrderItems
{
/**
* Migrate the table.
*
* @return void
*/
public static function migrate()
{
global $wpdb;
$charsetCollate = $wpdb->get_charset_collate();
$table = $wpdb->prefix . 'fluentform_order_items';
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Migration file, direct query needed
if ($wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE %s", $table)) != $table) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange -- Migration file, schema change is the purpose
$sql = "CREATE TABLE $table (
id int(11) NOT NULL AUTO_INCREMENT,
form_id int(11) NOT NULL,
submission_id int(11) NOT NULL,
type varchar(255) DEFAULT 'single',
parent_holder varchar(255),
billing_interval varchar(255),
item_name varchar(255),
quantity int(11) DEFAULT 1,
item_price BIGINT UNSIGNED,
line_total BIGINT UNSIGNED,
created_at timestamp NULL,
updated_at timestamp NULL,
PRIMARY KEY (id)
) $charsetCollate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
} else {
self::maybeAlterColumns();
}
}
public static function maybeAlterColumns()
{
global $wpdb;
$table = $wpdb->prefix . 'fluentform_order_items';
// find the data types of each column
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder -- Migration file, checking table structure, %1s is for identifier
$results = $wpdb->get_results($wpdb->prepare("DESCRIBE %1s", $table));
$items = [];
foreach ($results as $result) {
$items[$result->Field] = $result->Type;
}
$isBigInItemPrice = strpos($items['item_price'], 'bigint') !== false;;
$isBigInitPrice = strpos($items['line_total'], 'bigint') !== false;;
// if not big int convert to big int
if (!$isBigInItemPrice) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder -- Migration file, schema change is the purpose, %1s is for identifier
$wpdb->query($wpdb->prepare("ALTER TABLE %1s MODIFY item_price BIGINT UNSIGNED", $table));
}
if (!$isBigInitPrice) {
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder -- Migration file, schema change is the purpose, %1s is for identifier
$wpdb->query($wpdb->prepare("ALTER TABLE %1s MODIFY line_total BIGINT UNSIGNED", $table));
}
}
}