| @@ -135,53 +135,8 @@ | ||
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | /** |
| 139 | - * Fetch a single record row by ID, including its metadata. | |
| 140 | - * | |
| 141 | - * Stream's Query class doesn't expose a single-ID filter (record__in is | |
| 142 | - * broken for one-element arrays due to array_shift() in Query::query()), | |
| 143 | - * so query the table directly. Pass $blog_id to scope the lookup to a | |
| 144 | - * specific blog on multisite — callers running in REST/non-network-admin | |
| 145 | - * contexts should pass get_current_blog_id() to prevent cross-site reads. | |
| 146 | - * | |
| 147 | - * @param int $id Record ID. | |
| 148 | - * @param int|null $blog_id Optional blog ID to constrain the lookup to. | |
| 149 | - * | |
| 150 | - * @return array|null Associative row with merged 'meta' key, or null when | |
| 151 | - * no matching record exists. | |
| 152 | - */ | |
| 153 | - public static function get_by_id( $id, $blog_id = null ) { | |
| 154 | - global $wpdb; | |
| 155 | - | |
| 156 | - $id = (int) $id; | |
| 157 | - if ( $id <= 0 ) { | |
| 158 | - return null; | |
| 159 | - } | |
| 160 | - | |
| 161 | - $where = ''; | |
| 162 | - $prepared = array( $id ); | |
| 163 | - if ( null !== $blog_id ) { | |
| 164 | - $where = ' AND blog_id = %d'; | |
| 165 | - $prepared[] = (int) $blog_id; | |
| 166 | - } | |
| 167 | - | |
| 168 | - // $wpdb->stream and {$where} are constructed from string literals (no | |
| 169 | - // user input), and $prepared holds only integer IDs. | |
| 170 | - $sql = "SELECT * FROM {$wpdb->stream} WHERE ID = %d{$where}"; | |
| 171 | - // phpcs:ignore WordPress.DB.DirectDatabaseQuery,WordPress.DB.DirectDatabaseQuery.NoCaching,WordPress.DB.PreparedSQL.NotPrepared | |
| 172 | - $row = $wpdb->get_row( $wpdb->prepare( $sql, $prepared ), ARRAY_A ); | |
| 173 | - | |
| 174 | - if ( empty( $row ) ) { | |
| 175 | - return null; | |
| 176 | - } | |
| 177 | - | |
| 178 | - $row['meta'] = (array) get_metadata( 'record', $row['ID'] ); | |
| 179 | - | |
| 180 | - return $row; | |
| 181 | - } | |
| 182 | - | |
| 183 | - /** | |
| 184 | 139 | * Save record. |
| 185 | 140 | * |
| 186 | 141 | * @return int|WP_Error |
| 187 | 142 | */ |