403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.117.151.179
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /proc/7779/cwd/plugins/give/src/Donations/Migrations/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /proc/7779/cwd/plugins/give/src/Donations/Migrations/MoveDonationCommentToDonationMetaTable.php
<?php

namespace Give\Donations\Migrations;

use Exception;
use Give\Framework\Database\DB;
use Give\Framework\Migrations\Contracts\Migration;
use Give\Framework\Migrations\Exceptions\DatabaseMigrationException;
use Give\Log\Log;

/**
 * Class MoveDonationCommentToDonationMetaTable
 *
 * @since 2.27.0
 */
class MoveDonationCommentToDonationMetaTable extends Migration
{
    /**
     * @inheritdoc
     * @throws Exception
     */
    public function run()
    {
        $commentMetaTable = DB::prefix('give_commentmeta');
        $commentTable = DB::prefix('give_comments');
        $donationMetaTable = DB::prefix('give_donationmeta');

        $commentsCount = DB::get_var(
            "
            SELECT
                COUNT(1)
            FROM
                $commentTable
            WHERE
                comment_type = 'donor_donation'
            "
        );

        if (!intval($commentsCount)) {
            return;
        }

        DB::beginTransaction();

        try {
            $insertQuery = DB::query(
                "
                INSERT INTO $donationMetaTable (donation_id, meta_key, meta_value)
                SELECT
                    comment_parent,
                    '_give_donation_comment',
                    comment_content
                FROM
                    $commentTable
                WHERE
                    comment_type = 'donor_donation'
                "
            );

            if (!$insertQuery) {
                throw new Exception('Failed to insert donation comment into donation meta table.');
            }

            DB::query(
                "
                DELETE FROM $commentMetaTable
                WHERE give_comment_id IN(
                    SELECT
                        comment_ID FROM $commentTable
                    WHERE
                        comment_type = 'donor_donation'
                )
                "
            );

            DB::query(
                "
                DELETE FROM $commentTable
                WHERE comment_type = 'donor_donation'
                "
            );
        } catch (Exception $exception) {
            DB::rollback();

            Log::error('Failed running migration: ' . self::title());

            throw new DatabaseMigrationException('Failed running migration: ' . self::title(), 0, $exception);
        }

        DB::commit();
    }

    /**
     * @inheritdoc
     */
    public static function id()
    {
        return 'move-donation-comment-to-donation-meta-table';
    }

    /**
     * @inheritdoc
     */
    public static function title()
    {
        return 'Move donation comment to donation meta table';
    }

    /**
     * @inheritdoc
     */
    public static function timestamp()
    {
        return strtotime('2023-03-27');
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit