provide script and documentation to rebuild the votingapi cache
greggles - February 24, 2009 - 23:07
| Project: | Voting API |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
I found myself in a situation where I needed to rebuild the votingapi_cache table (it got deleted). So, here's a script which will do it and some clean ups to README.txt while we're at it.
| Attachment | Size |
|---|---|
| votingapi_rebuild_cache.php_.txt | 577 bytes |
| votingapi_rebuild_cache.patch | 2.77 KB |

#1
#2
We're using this script on Economist so I'll RTBC it.
I like this change in README: +VotingAPI requires Drupal.
#3
subscribe
#4
subscribe :)
#5
So orginal patch works, but this attached patch is a "I think this is a better approach, no offense" patch. This patch makes the operation Batch API'd and adds a form button to the votingapi settings page. Click the button and rebuild your cache.
I have tested it with a combination of about 100,000 votes on a mixture of nodes, comments, and users
#6
I think the warning that it could take a long time should be on the main form in addition to the confirmation form. People generally ignore text on confirm forms.
Other than that, shell scripts are easier to write and less likely to be run by accident. I'm not sure this needs to be truly "hard to run by accident" so I see this as an improvement. Didn't test or do a thorough review of the code, though..
#7
Also think that i probably should do a batch_set() for each content type. Removes a lot of the bookkeeping in there.
No harm in adding the warning message again.
#8
attached patch does the two afore mentioned things.
1.) adds the message to the button
2.) uses an operation per content_type in the batch api call
Interestingly,
<?php$form['results']['help'] = array(
'#prefix' => '<div>',
'#type' => 'markup',
'#value' => t('This action rebuilds all voting results, and may be a lengthy process.'),
'#attributes' => array('class' => 'description'),
'#suffix' => '</div>',
);
?>
didn't work even though 'markup' is listed to respect #attributes: http://api.drupal.org/api/file/developer/topics/forms_api_reference.html...
@eaton ^^ ?
#9
Hi,
just tried the last patch #8 but He doesn't work for me.
I have in /admin/settings/votingapi/rebuild the button "Rebuild all Voting Results" but when I click on it, the page reload without effects. I don't have anything that confirms any changes.
Anyway Voting results is not rebuilt.
And what about 2.) uses an operation per content_type in the batch api call ?
I can't choose node type.
#10
pretty strange. When you run this query:
SELECT DISTINCT(content_type) FROM votingapi_votedoes it return anything? Is your votingapi_vote table empty?#11
My content type is "fiche"
When I run this query: SELECT DISTINCT(fiche) FROM votingapi_vote, it return me:
Erreur
requête SQL:
SELECT DISTINCT (
fiche
)
FROM votingapi_vote
LIMIT 0 , 30
MySQL a répondu:
#1054 - Unknown column 'fiche' in 'field list'
I'm not a big expert in SQL
#12
right, you need to run this query exactly
SELECT DISTINCT(content_type) FROM votingapi_voteNot
SELECT DISTINCT(fiche) FROM votingapi_vote#13
oh ok, sorry
here the results:
Affichage des enregistrements 0 - 29 (1 306 total, Traitement en 0.0003 sec.)
SELECT DISTINCT (
content_type
)
FROM votingapi_vote
LIMIT 0 , 30
#14
guess its not working still ok.
#15
Nothing new since the last post?
I'm still here to test some patches :) Really needs to rebuild the votingapi cache ^^
#16
o duh! you have to clear your menu cache. try existing patch, and visit admin/build/modules first before hitting that button
/me kicks himself forgetting that
#17
Perfect! This patch is great! I don't know why it didn't work the first time I apllied it...
#18
sweet good to here, marking as reviewed and tested. Im using in other places as well.
#19
Hum that's wird, it didn't work for one vote (maybe more? I haven't see another one yet).
I cleared view cache, performance cache...
What do you call "menu cache"?
you say "and visit admin/build/modules first before hitting that button", I visit admin/build/modules, to do what? Maybe I haven"t carry out all spots before hitting thaht button! lol
#20
ok...
The menu callbacks and urls are cached away to the database. This patch adds a new url, so that cache needs to be rebuilt
By going to admin/build/modules, that cache is rebuilt. You don't have todo anything.
But I use devel module to clear the caches (http://drupal.org/project/devel)
#21
Hum ok, I don't really understand why this vote is still here if the votingapi cache has been rebuilt successfully. Is this vote was hidding somewhere? lol
I've got votes from 3 users to erase before launch my website, it was votes for tests.
I will report you if I have some news. :)
ps: I don't use Devel module.
#22
The patch at #8 worked quite well for me at first glance. Will report if I come accross something strange.