public function handle_row_id($o) { $row_id = $o->inputs->row_id->get_value(); if ($row_id < 1) { return; } $table = $this->broadcast()->broadcast_data_table(); $query = sprintf("SELECT * FROM `%s` WHERE `id` = '%s'", $table, $row_id); $o->results = $this->broadcast()->query($query); if (count($o->results) !== 1) { $o->r .= $this->broadcast()->error_('Row %s in the broadcast data table was not found!', $row_id); return; } // Try to unserialize the object. $result = reset($o->results); $bcd = BroadcastData::sql($result); $text = sprintf('<pre>%s</pre>', var_export($bcd, true)); $o->r .= $this->broadcast()->message($text); }
public function step_check_ids() { $r = ''; $max = count($this->data->ids_to_check); if ($max < 1) { $r .= $this->broadcast()->p('Finished checking database rows. Now checking the actual broadcast data relations.'); $r .= $this->next_step('check_relations'); return $r; } $r .= $this->broadcast()->p_('%s rows left to check...', count($this->data->ids_to_check)); // Check the next ids $max = min($max, data::$rows_per_step); $ids = []; for ($counter = 0; $counter < $max; $counter++) { $id = array_shift($this->data->ids_to_check); $query = sprintf("SELECT * FROM `%s` WHERE `id` = '%s'", $this->table, $id); $results = $this->broadcast()->query($query); $result = reset($results); $bcd = BroadcastData::sql($result); // Save the broadcast data in a quick index. $this->data->broadcast_data->put($id, $bcd); // 1. Is the broadcast data readable? if (!BroadcastData::unserialize_data($result['data'])) { $this->data->broken_bcd->set($id, $bcd); continue; } // Broadcast data is readable and unserializable. $blog_id = $result['blog_id']; $post_id = $result['post_id']; // Have we already seen BCD for this blog_post? $key = sprintf('%s_%s', $blog_id, $post_id); if ($this->data->seen_blog_post->has($key)) { $this->data->duplicate_bcd->put($id, $bcd); continue; } else { $this->data->seen_blog_post->put($key, true); } // 2. Does the linked post exist? if (!$this->blog_and_post_exists($blog_id, $post_id)) { $this->data->missing_post->put($id, $bcd); continue; } $this->cache_post_bcd($blog_id, $post_id, $bcd); // We have now checked the SQL row itself. // The relations we check later. $this->data->bcd_to_check->put($id, $bcd); } $r .= $this->next_step('check_ids'); return $r; }