I know these are a lot of updates to be patching at once, but I ended up working on them in parallel so here they are. Because there are so many updates here I'm hoping this patch can be tested more before I commit it.

Updates:

  • 4.7 node revision support: Now supports the new node revision system in 4.7. This means creating revisions also creates a new version of all the video data. The main change is the addition of of the vid field to the video database table. The big problem with this update is all the old nid values need to be copied over to the vid field.
  • Theme function updates: Some of the theme functions have been updated, mainly all the HTML generated for the custom_fields and metadata rows has been put into the theme_video_fields() function. This allows the "odd" "even" formatting to actually work.
  • Flash .swf file support: Support for the file type .swf has been added. A textarea has been added to the video form for entering custom parameters. I just realized this could be used for all file types not just .swf. OK now I turned it into a more general Object Parameters option with a settings option to turn it on and off.
  • Multi-file downloads: Cleaned up the multi-file download code in preperation for a major rewrite.
  • Serial data field in DB: I propose creating a new database field called serial_data. This field would hold the value of an associative array by using the PHP functions serialize() and unserialize(). The benifit of this would be that we can add new fields to the database without changing the database schema, this makes upgrades much easier for people. And then of course the new object_parameters textarea uses this to store it's values.
  • Image thumbnail support: A first step possibly temporary solution has been implemented. It adds 2 image URL fields with one for the teaser and one for the node view. The data for the fields is stored in the serialized_data table and a settings option to turn the feature on and off has been added. When an image is present in a teaser it is added to the left side with a table and when an image is present on a node it is added on the top.
  • Javascript download logging: Still working on it. This requires creating a javascript function to send data back to the server and I'm not experienced with javascript so I'm still researching this.
  • Form validation changes: The new Forms API in 4.7 disallows changing node values in the video_validate() function. This broke a few of the field validators like filesize and playtime for example. All the code that changes node values before they go into the database have been moved into a seperate function that gets run during video_insert() and video_update().
  • "download video" permission: Download video permission created and check put in _video_download_goto().
  • Forms API: The forms for the block settings had been forgotten about, so they are now updated.



These are the most recent database schema changes. After running this then the nid values have to be copied over to the new vid fields.

ALTER TABLE video ADD vid int(10) unsigned NOT NULL default '0';
ALTER TABLE video DROP PRIMARY KEY, ADD PRIMARY KEY (vid );
ALTER TABLE video ADD serialized_data text NULL default NULL;



Here is some code that updates all the new vid fields. It should either be put in the settings page if possible or in an update.php file.

$result = db_query("SELECT * FROM {video} WHERE vid = '%d'", 0);
while ($node = db_fetch_object($result)) {
  db_query("UPDATE {video} SET vid='%d' WHERE nid='%d'", $node->nid, $node->nid);
  echo '<br>' . "Updated nid $node->nid" . '<br>';
}



With this many changes I'm sure I missed something, what do you think?

Comments

LukeLast’s picture

StatusFileSize
new48.73 KB

Looks like I forgot to actually add the object parameters to the HTML. There's also an issue with single node revisions getting deleted, the nodeapi op revision delete needs to get added to drupal before this will work, which will hopefully be pretty soon. Right now deleted revisions still sit in the database until the entire node is deleted.

fax8’s picture

Is there a reason for changing all functions to use function($node) instead of (&$node) ?

passing $node by reference should be faster becouse everytime function($node) is
called all the object need to be copied by php.

LukeLast’s picture

StatusFileSize
new49.82 KB

Yeah traditionally passing an object by reference should be faster, but PHP uses reference counting so the value is not actually copied unless it is modified.

I initially did it because it's better coding form and because I read this from Zend.
"Contrary to popular belief, this actually reduces performance in most cases, so it's preferable to use the standard pass-by-value behavior."

Here's an article from Zend on the subject.
http://www.zend.com/zend/art/ref-count.php
"Almost no time is consumed when assigning an existing variable to a new variable, because the assigned value of the existing variable is not copied: the value that is assigned to the new variable merely has its reference counter incremented. Again, the improvement in performance is proportional to the size of the assigned value."
"Reference counting is used for all the PHP 4 basic data types: such as integers, booleans, strings, arrays, objects and resources."

So basically all data types are assigned by reference until a value is changed, so I think passing the objects normally by value is they way to go because they shouldn't be changed by the functions.

Does everything else check out? They just added an update system for modules which I'll try to get working and create a video.install file.

deekayen’s picture

I want to upgrade one of my video sites to 4-7 this weekend. What do I need to do for everyone to be happy enough to branch for 4-7?

fax8’s picture

Status: Needs review » Fixed

this features have been commited by Luke to cvs.

this can be set as fixed.

Fabio

Anonymous’s picture

Status: Fixed » Closed (fixed)