← All changes
|
vendor/team-updraft/common-libs/src/updraft-tasks/class-updraft-task.php
+55
-2
3.2.3
→
4.7.0
View file →
| @@ -73,10 +73,17 @@ | ||
| 73 | 73 | * |
| 74 | 74 | * @var Object |
| 75 | 75 | */ |
| 76 | 76 | protected $_loggers; |
| 77 | - | |
| 77 | + | |
| 78 | 78 | /** |
| 79 | + * Additional dynamic properties, usually copied from the UpdraftPlus_Task object. | |
| 80 | + * | |
| 81 | + * @var array<string,mixed> | |
| 82 | + */ | |
| 83 | + protected $extra_properties = array(); | |
| 84 | + | |
| 85 | + /** | |
| 79 | 86 | * The Task constructor |
| 80 | 87 | * |
| 81 | 88 | * @param UpdraftPlus_Task|object $task UpdraftPlus_Task object. |
| 82 | 89 | */ |
| @@ -686,8 +693,54 @@ | ||
| 686 | 693 | * @return object|false |
| 687 | 694 | */ |
| 688 | 695 | private function get_task_from_db($task_id) { |
| 689 | 696 | global $wpdb; |
| 690 | - return $wpdb->get_row("SELECT * FROM {$wpdb->base_prefix}tm_tasks WHERE id = {$task_id} LIMIT 1"); | |
| 697 | + $sql = $wpdb->prepare("SELECT * FROM {$wpdb->base_prefix}tm_tasks WHERE id = %d LIMIT 1", $task_id); | |
| 698 | + return $wpdb->get_row($sql); | |
| 699 | + } | |
| 700 | + | |
| 701 | + /** | |
| 702 | + * Writing data to inaccessible/non-existing property | |
| 703 | + * | |
| 704 | + * @param string $name | |
| 705 | + * @param mixed $value | |
| 706 | + * | |
| 707 | + * @return void | |
| 708 | + */ | |
| 709 | + public function __set($name, $value) { | |
| 710 | + $this->extra_properties[$name] = $value; | |
| 711 | + } | |
| 712 | + | |
| 713 | + /** | |
| 714 | + * Reading data from inaccessible/non-existing property | |
| 715 | + * | |
| 716 | + * @param string $name | |
| 717 | + * | |
| 718 | + * @return mixed|null | |
| 719 | + */ | |
| 720 | + public function __get($name) { | |
| 721 | + return isset($this->extra_properties[$name]) ? $this->extra_properties[$name] : null; | |
| 722 | + } | |
| 723 | + | |
| 724 | + /** | |
| 725 | + * Invoked when `isset` or `empty` are called on inaccessible/non-existing property | |
| 726 | + * | |
| 727 | + * @param string $name | |
| 728 | + * | |
| 729 | + * @return bool | |
| 730 | + */ | |
| 731 | + public function __isset($name) { | |
| 732 | + return isset($this->extra_properties[$name]); | |
| 733 | + } | |
| 734 | + | |
| 735 | + /** | |
| 736 | + * Invoked when `unset` is called on inaccessible/non-existing property | |
| 737 | + * | |
| 738 | + * @param string $name | |
| 739 | + * | |
| 740 | + * @return void | |
| 741 | + */ | |
| 742 | + public function __unset($name) { | |
| 743 | + unset($this->extra_properties[$name]); | |
| 691 | 744 | } |
| 692 | 745 | } |
| 693 | 746 | endif; |