PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
give / src / Donations / Migrations / AddMissingDonorIdToDonationComments.php

AddMissingDonorIdToDonationComments.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0, at src/Donations/Migrations/AddMissingDonorIdToDonationComments.php

64 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Donations\Migrations;
4
5 use Give\Framework\Database\DB;
6 use Give\Framework\Migrations\Contracts\Migration;
7
8 /**
9 * Class AddMissingDonorIdToDonationComment
10 *
11 * @since 2.24.0
12 */
13 class AddMissingDonorIdToDonationComments extends Migration
14 {
15 /**
16 * @inheritdoc
17 */
18 public function run()
19 {
20 $commentMetaTable = DB::prefix('give_commentmeta');
21 $commentTable = DB::prefix('give_comments');
22 $donationMetaTable = DB::prefix('give_donationmeta');
23
24 DB::query(
25 "
26 UPDATE
27 $commentMetaTable AS cm
28 INNER JOIN $commentTable AS c ON c.comment_ID = cm.give_comment_id
29 INNER JOIN $donationMetaTable AS dm ON c.comment_parent = dm.donation_id
30 SET
31 cm.meta_value = dm.meta_value
32 WHERE
33 dm.meta_key = '_give_payment_donor_id'
34 AND cm.meta_key = '_give_donor_id'
35 AND(cm.meta_value IS NULL OR cm.meta_value = '')
36 "
37 );
38 }
39
40 /**
41 * @inheritdoc
42 */
43 public static function id()
44 {
45 return 'add-missing-donor-id-in-donation-comments';
46 }
47
48 /**
49 * @inheritdoc
50 */
51 public static function title()
52 {
53 return 'Add missing donor id in donation comments';
54 }
55
56 /**
57 * @inheritdoc
58 */
59 public static function timestamp()
60 {
61 return strtotime('2022-12-19');
62 }
63 }
64