HEX
Server: nginx/1.18.0
System: Linux iZj6c1ieg2jrpk1z5tzi19Z 6.3.9-1.el7.elrepo.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 21 22:18:40 EDT 2023 x86_64
User: www (1001)
PHP: 8.2.4
Disabled: 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
Upload Files
File: /www/wwwroot/www.cytocare.cn/wp-content/plugins/shopmagic-for-woocommerce/migrations/Version_48.php
<?php
declare( strict_types=1 );

namespace WPDesk\ShopMagic\migrations;

use ShopMagicVendor\WPDesk\Migrations\AbstractMigration;
use WPDesk\ShopMagic\Database\DatabaseTable;

/**
 * Improve collation consistency between `wp_users` and `wp_shopmagic_guest`.
 * This mostly affects old installations, where the newest collation was installed for ShopMagic,
 * but old, not compatible version was already on `wp_users` table.
 */
class Version_48 extends AbstractMigration {
	public function up(): bool {
		$table = DatabaseTable::guest();
		$collation = $this->get_collation_from_existing_table();

		$our_columns = $this->wpdb->get_row(
			"SHOW FULL COLUMNS FROM {$table} WHERE Field = 'email'",
			ARRAY_A
		);
		if ( is_array( $our_columns ) ) {
			[ 'Collation' => $our_collation ] = $our_columns;
		} else {
			$our_collation = null;
		}

		if ( is_null( $collation ) || $our_collation === $collation ) {
			$this->logger->info('Guest table collation is consistent with `wp_users`. Skipping update.');
			return true;
		}

		return (bool) $this->wpdb->query(
			"
			ALTER TABLE $table
			MODIFY `email` varchar(255) COLLATE $collation;
			"
		);
	}

	private function get_collation_from_existing_table(): ?string {
		$charset = $this->wpdb->get_col_charset( $this->wpdb->users, 'user_email' );
		if ( $charset instanceof \WP_Error || $charset === false ) {
			return null;
		}

		$col_info = $this->wpdb->get_row( "SHOW FULL COLUMNS FROM {$this->wpdb->users} WHERE Field = 'user_email'",
			ARRAY_A );

		if ( is_array( $col_info ) && isset( $col_info['Collation'] ) ) {
			return $col_info['Collation'];
		}

		return null;
	}
}