Jump to content

Errorr 500 in ajax calls, and modules calls


Recommended Posts

salut à tous,

I'm testing my shop, and some errors 500 appears in Firebug, and if i try to call the file in the url, front or backOffice.

In front office :

http://my_url/prestashop/modules/blockcart/blockcart-set-collapse.php?ajax_blockcart_display=expand&rand=1271954906377


the text is red in Firebug, but the cart is ok

Same thing in the backoffice, in the module for example :

http://my_url/prestashop/modules/productcomments/productcommentscriterion.php?id_product=27&id_lang=2

I've add a fonctionnality in this module, in ajax, and when ajax call apperas, error :

http://my_url/prestashop/modules/productcomments/update_comment.php



The shop is in a sub-folder, and i use jquery-1.3.2, and all is allright.

Error in jquery.1.3.2.js line 3633 (xhr.send(s.data);) :

// Send the data
       try {
----->  xhr.send(s.data);
       } catch(e) {
           jQuery.handleError(s, xhr, null, e);
       }



In local uses, http://localhost, all is allright.

Any idea ?

Thanks,

Fabrice

Link to comment
Share on other sites

A 500 error means that a CGI script ended without sending any data. This is something far more common to see with legacy Perl scripts - if you are getting that with a PHP script it presumably means that your script is running as a CGI (as opposed to compiled in module for Apache or whatever web server your host uses) and that a fatal error is happening before any data is actually sent.

If the error is a straight up syntax error, you should be able to find it by running 'php -l [removed]' from the command line. If it is a runtime error of some sort then you might be able to find it by adding an 'echo "DEBUG: ";' statement at the top of the problem script so that some text gets sent before the script dies off. You should also look at the php error logs and see if the error is there (assuming you have access to them).

Cheers

Link to comment
Share on other sites

Hi,

Thanks for help, but I can't read the log, it's not my server :)

So I do that in the end of .htaccess of prestashop (777 for the log file):

# Log errors
php_flag  log_errors on
php_flag  display_errors on
php_value error_log PHP_errors.log



But if I add these lines, i get and another 500 error !... :-S


For example, there an error in this file : modules/blockcart/blockcart-set-collapse.php

If i comment all the code, the error's still there :

<?php
echo "DEBUG";
/*
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
if ( isset($_POST['ajax_blockcart_display']) || isset($_GET['ajax_blockcart_display']))
{
   if (Tools::getValue('ajax_blockcart_display') == 'collapse')
   {
       $cookie->ajax_blockcart_display = 'collapsed';
       die ('collapse status of the blockcart module updated in the cookie');
   }
   if (Tools::getValue('ajax_blockcart_display') == 'expand')
   {
       $cookie->ajax_blockcart_display = 'expanded';
       die ('expand status of the blockcart module updated in the cookie');
   }
   die ('ERROR : bad status setted. Only collapse or expand status of the blockcart module are available.');
}
else die('ERROR : No status setted.');
*/
?>



It's weird...

Fabrice

Link to comment
Share on other sites

If everything gives a 500 error after that .htaccess change then your server does not support the syntax you are trying to use. Remove the new lines from the .htaccess file.

When you edit a file to add a debug, do this at the top and see if it helps:

<?php

ini_set('display_errors',1);
echo 'DEBUG';
flush();
ob_flush();

?>

Cheers

Link to comment
Share on other sites

no, i've remove all the code in the .htaccess file.

Then, I try this

<?php

ini_set(‘display_errors’,1);
echo ‘DEBUG’;
flush();
ob_flush();

?> 

, and there's an error again.
I'm not supposed to call the file directly, but the error don't have to appears, anyway.

F.

Link to comment
Share on other sites

The file in question in 1.2.5 looks like this:

<?php
include(dirname(__FILE__).'/../../config/config.inc.php');
include(dirname(__FILE__).'/../../init.php');
if ( isset($_POST['ajax_blockcart_display']) || isset($_GET['ajax_blockcart_display']))
{
   if (Tools::getValue('ajax_blockcart_display') == 'collapse')
   {
       $cookie->ajax_blockcart_display = 'collapsed';
       die ('collapse status of the blockcart module updated in the cookie');
   }
   if (Tools::getValue('ajax_blockcart_display') == 'expand')
   {
       $cookie->ajax_blockcart_display = 'expanded';
       die ('expand status of the blockcart module updated in the cookie');
   }
   die ('ERROR : bad status setted. Only collapse or expand status of the blockcart module are available.');
}
else die('ERROR : No status setted.');
?>



I see that at least some of your site is working so it is not a case of all PHP files being broken.

Things to try:

1. some hosts will make scripts uncallable if the directory or file is world writable.

2. make a backup and then start by commenting out everything except for a single debug print at the top. Keep uncommenting stuff and reloading until you find the line that triggers the 500 error. Boil down from there.

Cheers

Link to comment
Share on other sites

hi,

All the files and directories in the module directory are in 777. So I make permissions to 755... and, i think it's done :), it's ok...

I'm going to test all the pages who have error, but for now, all is right.

I thank you very much to help me.


Fabrice

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...