On servers that have millions of rows in uc_file_users, update uc_file_update_6005() can take way too long to run its course. I have split the meat of it off into a batch function, which processes 100 row updates per.

Comments

Island Usurper’s picture

Status: Needs review » Needs work

Update functions need to return the $ret array.

Also, I'm not sure what happens when you try to run a batch during a batch, which is how updates are done. However, it looks like update functions can say how long they take with $ret['#finished']. See the second example on http://drewish.com/node/123.

cha0s’s picture

Interesting. :) I was going by the filefield module's implementation of a batch inside an update function. I initially thought it was weird too (batch in batch action), but torgospizza said the update appeared to work on a site (the one with tons of rows...). Anyways, I changed it 'cause this way is actually more elegant, though that passing in of the $sandbox variable and the #finished quirk should be better documented. ;)

cha0s’s picture

Status: Needs work » Needs review

*plonk*

Island Usurper’s picture

So, it didn't break on my test site, but I don't want to commit it until someone runs it on real data. Just in case. :)

Once I get a +1 from somebody, it should be ready to commit.

torgospizza’s picture

+1 from me. We tested on our d6 sandbox which has 1.4 million rows in the uc_file_users table.

Originally it timed out, but with the patch (and a slight tweaking of our max_execution_time) it went without a hitch.

Island Usurper’s picture

Status: Needs review » Fixed

Good deal. Committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.