Closed (fixed)
Project:
Video
Version:
master
Component:
Code
Priority:
Critical
Category:
Task
Assigned:
Reporter:
Created:
5 Dec 2005 at 09:38 UTC
Updated:
18 Jun 2006 at 22:00 UTC
Jump to comment: Most recent file
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.
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_video_fields() function. This allows the "odd" "even" formatting to actually work.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.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.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()._video_download_goto().
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?
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | video.module_8.patch | 49.82 KB | LukeLast |
| #1 | video.module_7.patch | 48.73 KB | LukeLast |
| video.module_6.patch | 46.19 KB | LukeLast |
Comments
Comment #1
LukeLast commentedLooks 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 deleteneeds 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.Comment #2
fax8 commentedIs 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.
Comment #3
LukeLast commentedYeah 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.
Comment #4
deekayen commentedI 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?
Comment #5
fax8 commentedthis features have been commited by Luke to cvs.
this can be set as fixed.
Fabio
Comment #6
(not verified) commented