No callback on comment submit

albataur

Joined: 2011-01-04
Posts: 7
Posted: Tue, 2011-01-04 12:55

Hello !

I'm using gallery3. I have a problem when I try to add some comments. Nothing appends when I click on submit button (no errors, no confirm).
However ajax query seems to be ok. Here is the JSON response I can see with firebug when I post an incomplete comment (name and email missing) :

{"result":"error","form":"<form action=\"\/index.php\/comments\/create\/3830\" method=\"post\" id=\"g-comment-form\"><input type="hidden" name="g3sid" value=removed for public display />\n<input type=\"hidden\" name=\"csrf\" value=\"7d4358ea17a195d26e3c747eb0bfd3b9\"  \/>  <fieldset>\n    <legend>Ajouter un commentaire<\/legend>\n    <ul>\n      <li class=\"g-error\">\n        <label for=\"name\" >Nom<\/label>\n        <input type=\"text\" id=\"g-author\" name=\"name\" value=\"\" class=\"textbox\"  \/>\n        <p class=\"g-message g-error\">\n          Vous devez saisir votre nom\n        <\/p>\n      <\/li>\n      <li class=\"g-error\">\n        <label for=\"email\" >Email (cach\u00e9)<\/label>\n        <input type=\"text\" id=\"g-email\" name=\"email\" value=\"\" class=\"textbox\"  \/>\n        <p class=\"g-message g-error\">\n          Vous devez saisir une adresse email valide\n        <\/p>\n      <\/li>\n      <li>\n        <label for=\"url\" >Site web (cach\u00e9)<\/label>\n        <input type=\"text\" id=\"g-url\" name=\"url\" value=\"\" class=\"textbox\"  \/>\n      <\/li>\n      <li>\n        <label for=\"text\" >Commentaire<\/label>\n        <textarea id=\"g-text\" name=\"text\" rows=\"\" cols=\"\" class=\"textarea\" >fgdfg<\/textarea>\n      <\/li>\n      <li>\n        <input type=\"submit\" value=\"Ajouter\" class=\"ui-state-default ui-corner-all\"  \/>\n      <\/li>\n    <\/ul>\n    <input type=\"hidden\" name=\"item_id\" value=\"3830\"  \/>\n  <\/fieldset>\n<\/form>"}

I tried to add some alerts into the callback function, but it seems to be never called :

 $("#g-comments form").ajaxForm({
    dataType: "json",
    success: function(data) {
      	alert('pouet1');
      if (data.result == "success") {
        $("#g-comments #g-comment-detail ul").append(data.view);
        $("#g-comments #g-comment-detail ul li:last").effect("highlight", {color: "#cfc"}, 8000);
        $("#g-comment-form").hide(2000).remove();
        $("#g-no-comments").hide(2000);
      } else {
      	alert('pouet');
        if (data.form) {
          $("#g-comments form").replaceWith(data.form);
          ajaxify_comment_form();
        }
      }
    }
  });

I don't know JQuery so it's difficult for me to debug this. You can look at this on http://photos.alexis-bataille.com/index.php/Photos-Etretat-2010/P1030589 .

Thanks !

 
albataur

Joined: 2011-01-04
Posts: 7
Posted: Tue, 2011-01-04 15:29

I think I'm not the only one to have this problem : http://gallery.menalto.com/node/100032

 
albataur

Joined: 2011-01-04
Posts: 7
Posted: Wed, 2011-01-05 12:25

No idea ?

 
albataur

Joined: 2011-01-04
Posts: 7
Posted: Wed, 2011-01-05 12:48

Ok I think I found why callback isn't called.
JSON response is incorrect. It's missing some backslashes before " :

{
"result":"error",
"form":"<form action=\"\/index.php\/comments\/create\/3830\" method=\"post\" id=\"g-comment-form\"><input type="hidden" name="g3sid" value=removed for public display />\n<input type=\"hidden\" ...
}

I'll try to found where I can correct it.

 
albataur

Joined: 2011-01-04
Posts: 7
Posted: Thu, 2011-01-06 21:35

I browsed almost every files for finding where is added this field ... unsuccessful.
Must I add a bug in the bug tracker ?

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Sat, 2011-01-08 07:56

Ah, you're getting bitten by this: https://sourceforge.net/apps/trac/gallery/ticket/1316
This is a very bad PHP setting, it silently munges the HTML that we generate. I've added a fix in 3.0.1 to warn admins when this setting is on, but in the meantime turn it off and you'll be fine.
---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!

 
albataur

Joined: 2011-01-04
Posts: 7
Posted: Sat, 2011-01-08 14:15

Wow indeed, it was this ! Thank you !
I understand why I spent so long time for finding in the code where it was added ... unsuccessful.

Nevertheless, I tried to put this setting off in htaccess :

  php_value post_max_size 	     100M
  php_flag session.use_trans_sid	Off
</IfModule>

But it didn't work (gallery is on a shared host). Any idea ?

Finally I setted it in index.php


ini_set("session.use_trans_sid", false);

Anyway, thank you for your help !

 
bharat
bharat's picture

Joined: 2002-05-21
Posts: 7994
Posted: Tue, 2011-01-11 00:20

@albataur: I have committed your suggested fix to 3.0.1 -- thanks!
---
Problems? Check gallery3/var/logs
file a bug/feature ticket | upgrade to the latest code! | hacking G3? join us on IRC!