| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\Donations\Migrations; |
| 4 |
|
| 5 |
use Give\Framework\Database\DB; |
| 6 |
use Give\Framework\Migrations\Contracts\Migration; |
| 7 |
use Give\Helpers\Utils; |
| 8 |
|
| 9 |
/** |
| 10 |
* @since 3.17.2 |
| 11 |
*/ |
| 12 |
class UnserializeTitlePrefix extends Migration |
| 13 |
{ |
| 14 |
/** |
| 15 |
* @since 3.17.2 |
| 16 |
*/ |
| 17 |
public function run() |
| 18 |
{ |
| 19 |
$items = DB::table('give_donationmeta')->where('meta_key', '_give_donor_billing_title_prefix')->getAll(); |
| 20 |
|
| 21 |
foreach ($items as $item) { |
| 22 |
if (Utils::isSerialized($item->meta_value)) { |
| 23 |
$unserializedTitlePrefix = Utils::safeUnserialize($item->meta_value); |
| 24 |
|
| 25 |
DB::table('give_donationmeta') |
| 26 |
->where('donation_id', $item->donation_id) |
| 27 |
->where('meta_key', '_give_donor_billing_title_prefix') |
| 28 |
->update([ |
| 29 |
'meta_value' => $unserializedTitlePrefix, |
| 30 |
]); |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
/** |
| 37 |
* @since 3.17.2 |
| 38 |
*/ |
| 39 |
public static function id() |
| 40 |
{ |
| 41 |
return 'donation-meta-unserialize-title-prefix'; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* @since 3.17.2 |
| 46 |
*/ |
| 47 |
public static function title() |
| 48 |
{ |
| 49 |
return 'Unserialize data in the _give_donor_billing_title_prefix meta value'; |
| 50 |
} |
| 51 |
|
| 52 |
/** |
| 53 |
* @since 3.17.2 |
| 54 |
*/ |
| 55 |
public static function timestamp() |
| 56 |
{ |
| 57 |
return strtotime('2024-10-23'); |
| 58 |
} |
| 59 |
} |
| 60 |
|