Search code examples
prestashopprestashop-1.6prestashop-1.5

A letter is displayed after body tag in Prestashop website


I have a prestashop website http://www.myparaweb.com/ which displays a 'l' letter after body tag, it's returned also in the ajax json response after back office loging so that the login is never succeed. I tried to view the theme header.tpl, and the admin header.tpl and i didn't found it there

Attached the code screenshot and the json return with the 'l' in the beginning. I'd like to remove this 'l' letter. Thanksenter image description hereenter image description here

Edit: As i begin to found where the 'l' letter occurs, i debugged the __constructor function in the Dispatcher class

protected function __construct()
{   die("test");
    $this->use_routes = (bool)Configuration::get('PS_REWRITING_SETTINGS');
...
}

This returned the 'l' letter like this

<html><head></head><body>ltest</body></html>

Edit2: i tried to debug into the getInstance function like this

public static function getInstance()
{   die('test');
    if (!self::$instance) {
        self::$instance = new Dispatcher();
    }
    return self::$instance;
}

I got

<html><head></head><body>ltest</body></html>

Solution

  • When looking at the source code the l character appears before your <!DOCTYPE HTML> declaration.

    l<!DOCTYPE HTML>
    <html lang="fr-fr">
        <head>
            <meta charset="utf-8" />
            <title>Default Ciblo theme</title>
    

    As it appears on every page we are sure it's not a Controller but it might be the /classes/controller/FrontController.php classe.

    If I were you, I would debug by printing die("test") at different steps in Prestashop process to find where this character comes from. By starting with the FrontController :

    class FrontControllerCore extends Controller
    {
        public function __construct()
        {
            die("test");
            [...]
        }
    }
    

    Then try with the init() function... Then initContent() and finally displayHeader.

    This might be a long process taking you 1 hour or more of debug but you'll be sure to find the exact place of this bug.


    EDIT: From your bellow comment, we can tell that this bug happens before the controller is called.

    We will then start to debug from the /index.php:

    <?php
    /**
    [...]
    */
    die("test");
    require(dirname(__FILE__).'/config/config.inc.php');
    

    Then:

    <?php
    /**
    [...]
    */
    require(dirname(__FILE__).'/config/config.inc.php');
    die("test");
    Dispatcher::getInstance()->dispatch();
    

    With this you will know if the bug happens before the dispatcher of after. If it happens in the config file, repeat the process in this file for each line to find which include causes this problem.


    EDIT: From your comment bellow, the problem happens after the Dispatcher call so you'll have to dig into /classes/Dispatcher.php. Start by debuging the __cunstructor() function and then dispatch() function.