Voting does not work if Devel module is activated
| Project: | Extra Voting Forms |
| Version: | 5.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | minor |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
First of all, thanks very much for this amazing module.
However, after installation, i faced sql (using drigg theme) error
"user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LEFT JOIN drigg_node dn2 ON dn2.dnid = n.nid WHERE ( 1=1 AND !(n.type='drigg' ' at line 1 query: LEFT JOIN drigg_node dn2 ON dn2.dnid = n.nid WHERE ( 1=1 AND !(n.type='drigg' AND dn2.killed=1 ) ) in ....\drupal5\includes\database.mysql.inc on line 172."
In addition, the vote widget does not work either.
If i use other theme, there will not be such sql error msg, the vote form will be normal check point but workable.
In addition, is the installation process too complicated? like the drigg theme, is there anyway to use drupal theme hooks to automatically call the functions required?
I am using drupal5.2 , mysql5.0
Thanks

#1
Hi,
Please only raise ONE issue per report. The installation process is what it needs to be. If you want something simple, install drigg-distr.tgz, aimed at people who are not used to Drupal.
About the problem: it's really strange. I am unable to reproduce the problem. When does it come up? Can you give me precise instructions on how to reproduce it? Which extra modules have you installed?
Can you give me a link to a live site with the problem?
Bye,
Merc.
#2
Hi,
Users should be educated on the use of the priority "Critical"
Merc.
#3
in additon it shows
"
warning: Missing argument 1 for drigg_help() in D:\Inetpub\websites\drupal5\sites\all\modules\voting\drigg\drigg.module on line 8.
"
after click the voting button, it shows "karma error: parseerror"
i am not sure if it caused by conflict with other module. i will go through the code and try to find out the problem this weekend. :)
#4
hi Merc,
thanks for your quick apply.
after comment out the "drigg_db_rewrite_sql“ function, error msg shows "user warning: Query was empty query:"
so seems the system send some empty query somewhere.
#5
Hi,
OK, did you read my message above?
----------------------------------------------------------------
About the problem: it's really strange. I am unable to reproduce the problem. When does it come up? Can you give me precise instructions on how to reproduce it? Which extra modules have you installed?
Can you give me a link to a live site with the problem
-----------------------------------------------------------------
Finally, I need to ask... are you using this on Drupal 5.5?
Bye,
Merc.
#6
Hi Merc,
I am not using drupal 5.5 but 5.2 instead.
Drigg must run on 5.5?
Instead of using ur default theme, i followed ur online install instruction and copied those functions to my current theme.
after doing so, the db error gone.
but the after voting, it still shows "Karma Error: parsererror".
I checked the code, it's from jquery.
if ( status == "success" ) {// Watch for, and catch, XML document parse errors
try {
// process the data (runs the xml through httpData regardless of callback)
data = jQuery.httpData( xml, s.dataType );
} catch(e) {
status = "parsererror";
}
}
actually, the data updating has been done, after refresh the page, the correct voting result will be displayed. the only problem is Ajax failed to update result after voting due to the "parsererror".
#7
Hi,
Did you update jquery.js as explained in the documentation?
If you install firebug, what's the result of the voting query?
Once more: can you please give me a URL where I can see this?
Bye,
Merc.
#8
sorry, i only tested it on my local server.
i have the latest jquery.
the problem is there is some conflict with devel module.
the value send back was
{"karma_aggregate":1} and devel information, "the execution time", "memory"i believe it should be simply "{"karma_aggregate":1}"
#9
Hi,
Do you have the "devel" module enabled?
If so, voting won't work because the return value will get mixed up with the devel module's output.
Bye,
Merc.
#10
Hi Merc,
I see the problem.
To fix it and the right way to return json is
in extra_voting_forms.module
1. in "extra_voting_forms_return" function, dont print the output and exit, but return the string value to "extra_voting_forms_handle".
2. in "extra_voting_forms_handle" function, dont print the output either, but do
exit(extra_voting_forms_return(@params).
in this way, the devel module will not append extra information to your json output.
I have tested it on my server, and it works well.
Cheers!
Welcome further discussion.
#11
Hi,
Sorry, I am not sure I follow you...
I don't get the two points:
---------------------------------------
1. in "extra_voting_forms_return" function, dont print the output and exit, but return the string value to "extra_voting_forms_handle".
2. in "extra_voting_forms_handle" function, dont print the output either, but do
exit(extra_voting_forms_return(@params).
----------------------------------------
Can you please send me a patch?
Thanks,
Merc.
#12
Hi,
I tried to interpret what you wrote, and I must say I don't get it :-)
Are you sure that with "your" way, if there is an error you still get it displayed?
(You can "force" an error in the code)
Reducing the priority to "minor".
Bye,
Merc.
#13
Hi,
Changed to another module (the appropriate one).
#14
Hi Merc,
Here is the updated extra_voting_forms_return and extra_voting_forms_handle function.
By doing so, you can get the clean json without devel info appended.
i hope i made myself clear. :)
function extra_voting_forms_return($form_type,$object,$error,$current_karma){
if($form_type == 'ajax'){
// Adjust the string for Ajax...
if($current_karma===''){
$current_karma='"Undefined"';
}
// Return the right thing to the javascript
if($error != ''){
$output = "{\"karma_aggregate\":$current_karma, \"error\":\"$error\"}";
//print "{\"karma_aggregate\":$current_karma, \"error\":\"$error\"}";
#drupal_set_message($error);
} else {
$output = "{\"karma_aggregate\":$current_karma}";
//print "{\"karma_aggregate\":$current_karma}";
}
//module_invoke_all('exit');
return $output;
} else {
if($error != ''){
drupal_set_message($error,'error');
} else {
drupal_set_message(t('Thank you for voting!'));
}
drupal_goto(referer_uri());
}
}
function extra_voting_forms_handle(){
global $_REQUEST, $user;
// The form has been posted...
if ($_REQUEST['form_type']) {
// Set the incoming variables
$oid = $_REQUEST['oid'];
$otype = $_REQUEST['otype'];
$karma_vote = $_REQUEST['karma_vote'];
$form_type = $_REQUEST['form_type'];
// If otype isn't 'c' or 'n', return to the home page
if($otype != 'c' && $otype != 'n'){
exit(extra_voting_forms_return($form_type,$o,t('Error in the form'),''));
}
// Create the object, and load it
$o= new stdClass();
$o->sk_id = $oid;
$o->sk_type = $otype;
$o=extra_voting_forms_load_object($o);
if(!$o){
exit(extra_voting_forms_return($form_type,$o,t('Error loading the object!'),''));
}
// Check that $form_type is sane. extra_voting_forms_return does NOT
// check it as a parameter
if($form_type != 'ajax' && $form_type != 'form'){
drupal_set_message(t('Error in the parameters!'),'error');
drupal_goto('node/'.$o->nid);
}
// It's a direct form, and the user doesn't
// have voting rights!
if($form_type != 'ajax' && $user->uid == 0){
drupal_goto( extra_voting_forms_anonymous_url(), "destination=".extra_voting_forms_destination($o) );
}
// Give the vote and return. $give_vote_return will return the error
// message (if there was one) or '' if all went OK. This is exactly what
// extra_voting_forms_return expects, which is handy...
list($give_vote_return,$k)=extra_voting_forms_give_vote($o,$karma_vote);
if(! variable_get('extra_voting_forms_display_karma_for_'.$o->sk_type, 0) ){
$k='';
}
drupal_set_header("Content-Type: text/json");
exit(extra_voting_forms_return($form_type,$o,$give_vote_return,$k));
}
}
#15
sorry, mistakenly reset the priority.
the above code is just an example, i have not studied your code thoroughly. I just want to show you my way to send clean json without devel info.
the database error has gone after i changed back to my previous theme, not sure abt what's wrong with your theme functions.
#16
Hi,
Please leave the title as I set it.
Also, the module affected is extra_voting_form, not drigg.
#17
Hi,
Fixed in 1.3
Thanks for the patch!
Merc.
#18
#19
That's great!
Truly wish you all the best and great success with your drigg project.