prepare( 'timestamp < %s', $to ) : $wpdb->prepare( 'timestamp >= %s AND timestamp < %s', $from, $to ); $runs = array(); $open = null; $after = $floor; do { // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- the plugin's own table; $table and $where are literals of this class, every value is a placeholder. $batch = $wpdb->get_results( $wpdb->prepare( "SELECT id, chain_prev, chain_hash FROM $table WHERE $where AND chain_hash IS NOT NULL AND id > %d ORDER BY id ASC LIMIT %d", $after, self::BATCH ), ARRAY_A ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $batch = is_array( $batch ) ? $batch : array(); $got = count( $batch ); foreach ( $batch as $row ) { $after = max( $after, (int) $row['id'] ); if ( Seal::is_digest( $row['chain_prev'] ) && Seal::is_digest( $row['chain_hash'] ) ) { $open = Cuts::feed( $open, $runs, $row['chain_prev'], $row['chain_hash'] ); } } } while ( self::BATCH === $got ); if ( null !== $open ) { $runs[] = $open; } Ledger::record( $key, $runs ); // phpcs:disable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- as above. $deleted = $wpdb->query( "DELETE FROM $table WHERE $where" ); // phpcs:enable WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching return is_int( $deleted ) ? $deleted : 0; } }