| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FireBox |
| 4 | - * @version 3.1.7 Free | |
| 4 | + * @version 3.1.14 Free | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | 8 | * @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| @@ -71,9 +71,9 @@ | ||
| 71 | 71 | * @return bool |
| 72 | 72 | */ |
| 73 | 73 | public static function updateState($submission_id = null, $state = null) |
| 74 | 74 | { |
| 75 | - if (!$submission_id || !in_array($state, [0, 1])) | |
| 75 | + if (!$submission_id || !in_array($state, [0, 1], true)) | |
| 76 | 76 | { |
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | |
| @@ -88,12 +88,42 @@ | ||
| 88 | 88 | return firebox()->tables->submission->update($data, $where); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | + * Returns whether a submission exists. | |
| 93 | + * | |
| 94 | + * Deliberately does not go through get(), which reads with caching enabled — calling | |
| 95 | + * that before a write would cache the pre-write row and make the update look like it | |
| 96 | + * had not happened. | |
| 97 | + * | |
| 98 | + * @param int $id | |
| 99 | + * | |
| 100 | + * @return bool | |
| 101 | + */ | |
| 102 | + public static function exists($id = null) | |
| 103 | + { | |
| 104 | + $id = (int) $id; | |
| 105 | + | |
| 106 | + if ($id <= 0) | |
| 107 | + { | |
| 108 | + return false; | |
| 109 | + } | |
| 110 | + | |
| 111 | + global $wpdb; | |
| 112 | + | |
| 113 | + $table = firebox()->tables->submission->getFullTableName(); | |
| 114 | + | |
| 115 | + return (bool) $wpdb->get_var($wpdb->prepare( | |
| 116 | + "SELECT 1 FROM `{$table}` WHERE id = %d LIMIT 1",// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared | |
| 117 | + $id | |
| 118 | + )); | |
| 119 | + } | |
| 120 | + | |
| 121 | + /** | |
| 92 | 122 | * Returns the submission details given its ID. |
| 93 | - * | |
| 123 | + * | |
| 94 | 124 | * @param int $id |
| 95 | - * | |
| 125 | + * | |
| 96 | 126 | * @return bool |
| 97 | 127 | */ |
| 98 | 128 | public static function get($id = null) |
| 99 | 129 | { |