Recently I've noticed, that the {content_field_*} cck table that stores video field values in my database reached 1.7 GB (which is almost half of the entire database). I've learned about 6012 and gave it a try. Unfortunately I run into problems: not all rows in the table were processed and the batch progress bar stopped at the 99%. It turned out that is because of the batch process itself. Consider contents of the table such as:

Vid, Delta
- 1, 0
- 2, 0
- 2, 1
- 2, 2
- 3, 0

So there are 5 rows in the table and let say that the limit of rows processed in a single call is 3. So in the first call processes: (1, 0), (2, 0), (2, 1) and the second call processes: (3, 0). Row (2, 2) is never processed. Why? Because after the first call current_vid is set to 2, and there is a condition in the query that fetches rows to processes: vid > current_vid. In the case of the second call considered above: vid > 2. The 'progress' variable never reaches the values of 5 (number of rows in the table) so the batch is doomed to the eternal loop.

Also there is a mistake in arguments sent to one of the drupal_write_record() calls: in case of the {content_field_*} table there are two columns in primary key: vid and delta, not just vid (this causes "Duplicate entry" warnings during the update and rows producing this error are not really updated).

I'm trying to fix those two issues in the patch below. Please comment.

CommentFileSizeAuthor
media_youtube_update_6012.patch2.52 KBadr_p

Comments

adr_p’s picture

Actually, I've just realized, that the patch I've sent will not always work. Also, the original code may behave properly sometimes. In short: you are taking into account only situations, when video field may have only single value (thus the data is stored in a {content_type_*} table, which has primary key based on vid column only), while I'm considering only cases in which video filed is configured as multi-value (and the data is kept in a {content_field_*} table, two columns - vid and delta - in primary key).

So it is necessary to improve the patch before applying.