HEX
Server: Apache/2.4.59 (Debian)
System: Linux keymana 4.19.0-21-cloud-amd64 #1 SMP Debian 4.19.249-2 (2022-06-30) x86_64
User: lijunjie (1003)
PHP: 7.4.33
Disabled: 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_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wp-content/plugins/erp/includes/updates/update-1.2.2.php
<?php
/**
 * Add private column in erp_crm_contact_group
 *
 * @since 1.2.2
 *
 * @return void
 */
function erp_crm_contact_group_add_private_column_1_2_2() {
    global $wpdb;

    $table = $wpdb->prefix . 'erp_crm_contact_group';
    $cols  = $wpdb->get_col( "DESC $table" );

    if ( ! in_array( 'private', $cols ) ) {
        $wpdb->query( "ALTER TABLE $table ADD `private` TINYINT(1) DEFAULT NULL AFTER `description`" );
    }
}

erp_crm_contact_group_add_private_column_1_2_2();

/**
 * Get hash from contact subscriber table and store them in meta tahble as `hash`
 *
 * @since 1.2.2
 *
 * @return void
 */
function erp_crm_contact_subscriber_get_hashes_1_2_2() {
    global $wpdb;

    $table = $wpdb->prefix . 'erp_crm_contact_subscriber';
    $cols  = $wpdb->get_col( "DESC $table" );

    if ( in_array( 'hash', $cols ) ) {
        $subscribers = $wpdb->get_results( "SELECT user_id, hash from {$wpdb->prefix}erp_crm_contact_subscriber GROUP BY user_id" );

        if ( ! empty( $subscribers ) ) {
            foreach ( $subscribers as $subscriber ) {
                if ( ! erp_people_get_meta( $subscriber->user_id, 'hash', false ) ) {
                    $hash = $subscriber->hash ?
                                $subscriber->hash :
                                sha1( microtime() . 'erp-contact-subscriber' . $subscriber->user_id );

                    erp_people_update_meta( $subscriber->user_id, 'hash', $hash );
                }
            }
        }
    }
}

erp_crm_contact_subscriber_get_hashes_1_2_2();