You are here

function video_update_8 in Video 5

Video_upload changes from relying on files table to locate video file to saving it in serialized_data as video_fid

File

./video.install, line 240

Code

function video_update_8() {

  /* select all the video upload video nodes */
  $vnodes = db_query("SELECT n.nid,n.vid,serialized_data FROM {node} n INNER JOIN {video} v on n.nid = v.nid WHERE n.type = 'video' AND v.vtype = 'upload' AND v.serialized_data NOT LIKE '%video_fid%'");
  while ($node = db_fetch_object($vnodes)) {

    /* load the video file info */
    if ($node->vid) {
      $result = db_query('SELECT * FROM {files} f INNER JOIN {file_revisions} r ON f.fid = r.fid WHERE r.vid = %d ORDER BY f.fid DESC', $node->vid);
      if (!$result) {
        continue;
      }
      $result = db_fetch_object($result);

      /* save the new serialized_data */
      $data = unserialize($node->serialized_data);
      $data['video_fid'] = $result->fid;
      $data = serialize($data);
      $res = db_query("UPDATE {video} SET serialized_data='%s' WHERE nid=%d", $data, $node->nid);
    }
  }
  return array();
}