Voting does not work if Devel module is activated

gnosis.kv - January 11, 2008 - 06:49
Project:Extra Voting Forms
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:minor
Assigned:Unassigned
Status:closed
Description

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

mercmobily - January 11, 2008 - 07:11
Status:active» postponed (maintainer needs more info)

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

mercmobily - January 11, 2008 - 07:12
Priority:critical» normal

Hi,

Users should be educated on the use of the priority "Critical"

Merc.

#3

gnosis.kv - January 11, 2008 - 07:44
Priority:normal» critical
Status:postponed (maintainer needs more info)» active

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

gnosis.kv - January 11, 2008 - 08:02
Priority:critical» normal
Status:active» postponed (maintainer needs more info)

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

mercmobily - January 11, 2008 - 08:55

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

gnosis.kv - January 11, 2008 - 09:40

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

mercmobily - January 11, 2008 - 09:43

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

gnosis.kv - January 11, 2008 - 10:02

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

mercmobily - January 11, 2008 - 10:23

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

gnosis.kv - January 11, 2008 - 12:57
Status:postponed (maintainer needs more info)» active

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

mercmobily - January 11, 2008 - 13:39
Title:drigg does not work after installation» drigg does not work if Devel module is activated

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

mercmobily - January 11, 2008 - 13:48
Priority:normal» minor

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

mercmobily - January 11, 2008 - 13:55
Title:drigg does not work if Devel module is activated» Voting does not work if Devel module is activated
Project:Drigg» Extra Voting Forms
Version:5.x-1.6» 5.x-1.2

Hi,

Changed to another module (the appropriate one).

#14

gnosis.kv - January 11, 2008 - 14:00
Title:Voting does not work if Devel module is activated» drigg does not work after installation
Project:Extra Voting Forms» Drigg
Version:5.x-1.2» 5.x-1.6
Priority:minor» normal

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

gnosis.kv - January 11, 2008 - 14:11
Priority:normal» minor

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

mercmobily - January 11, 2008 - 23:45
Title:drigg does not work after installation» Voting does not work if Devel module is activated
Project:Drigg» Extra Voting Forms
Version:5.x-1.6» 5.x-1.2

Hi,

Please leave the title as I set it.

Also, the module affected is extra_voting_form, not drigg.

#17

mercmobily - January 12, 2008 - 00:40

Hi,

Fixed in 1.3

Thanks for the patch!

Merc.

#18

mercmobily - January 12, 2008 - 01:09
Status:active» closed

#19

gnosis.kv - January 12, 2008 - 02:33

That's great!

Truly wish you all the best and great success with your drigg project.

#20

Flying Drupalist - May 16, 2009 - 17:26
Version:5.x-1.2» 6.x-1.x-dev
Status:closed» active

This problem is still present in the 6.x dev.

Hopefully the current maintainer would try to fix this.

#21

mercmobily - June 5, 2009 - 03:02

Hi,

I am having a real problem with this.
The main issue is that it *seems* to be a problem with the devel module, more than EVF.
It's really annoying and I want to close it, but I am a little lost.

Merc.

#22

mercmobily - June 5, 2009 - 03:18
Status:active» fixed

Hi,

Got it. Fixed this bugger.
I needed a drupal_set_header("Content-Type: text/json"); before the json return. Yay.

Merc.

#23

mercmobily - June 18, 2009 - 07:38
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.