riess82 Posted April 23, 2020 Share Posted April 23, 2020 Dear community. I am trying to create a module that checks backoffice-logins against an ldap database. My startingpoint is Employee.php function getByEmail() and I will integrate my ldap_bind there. BUT I am stuck before getting properly started because I can't find a way to debug php variables. HOW can i debug php variables? I have tried various versions of exit(), print(), etc. none of which worked. I do not care much if the debug output goes to console, the apache webserver logs or the html, just as long as I have a way of some output directly from the php function. Thank you in advance. Link to comment Share on other sites More sharing options...
joseantgv Posted April 23, 2020 Share Posted April 23, 2020 Try with: dump($variable); die; Link to comment Share on other sites More sharing options...
riess82 Posted April 23, 2020 Author Share Posted April 23, 2020 No output, I tried dump($this); die; just before the return, then also tried dump('asdf'); but no output in html, Browser console or apache error log. The code is executed, the login stops and the page does not refresh, but no output. In case it is important, I am on version 1.7.6.1 now. Link to comment Share on other sites More sharing options...
joseantgv Posted April 23, 2020 Share Posted April 23, 2020 Could you copy your code? Link to comment Share on other sites More sharing options...
riess82 Posted April 23, 2020 Author Share Posted April 23, 2020 <?php #override/classes/Employee.php /** * 2007-2019 PrestaShop and Contributors * * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * https://opensource.org/licenses/OSL-3.0 * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to https://www.prestashop.com for more information. * * @author PrestaShop SA <[email protected]> * @copyright 2007-2019 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ use PrestaShop\PrestaShop\Adapter\CoreException; use PrestaShop\PrestaShop\Adapter\ServiceLocator; use PrestaShop\PrestaShop\Core\Crypto\Hashing; /** * Class EmployeeCore. */ class Employee extends EmployeeCore { /** * Return employee instance from its e-mail (optionally check password). * * @param string $email e-mail * @param string $plaintextPassword Password is also checked if specified * @param bool $activeOnly Filter employee by active status * * @return bool|Employee|EmployeeCore Employee instance * `false` if not found */ public function getByEmail($email, $plaintextPassword = null, $activeOnly = true) { if (!Validate::isEmail($email) || ($plaintextPassword != null && !Validate::isPlaintextPassword($plaintextPassword))) { die(Tools::displayError()); } $sql = new DbQuery(); $sql->select('e.*'); $sql->from('employee', 'e'); $sql->where('e.`email` = \'' . pSQL($email) . '\''); if ($activeOnly) { $sql->where('e.`active` = 1'); } $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->getRow($sql); if (!$result) { return false; } /** @var Hashing $crypto */ $crypto = ServiceLocator::get(Hashing::class); $passwordHash = $result['passwd']; $shouldCheckPassword = null !== $plaintextPassword; #ldap start if ($shouldCheckPassword && !$crypto->checkHash($plaintextPassword, $passwordHash)) { return false; } $this->id = $result['id_employee']; $this->id_profile = $result['id_profile']; foreach ($result as $key => $value) { if (property_exists($this, $key)) { $this->{$key} = $value; } } if ($shouldCheckPassword && !$crypto->isFirstHash($plaintextPassword, $passwordHash)) { $this->passwd = $crypto->hash($plaintextPassword); $this->update(); } dump('asdf'); die; return $this; } } Link to comment Share on other sites More sharing options...
joseantgv Posted April 23, 2020 Share Posted April 23, 2020 The code stops at die; ? If you add the debug at the beginning, is it displayed? Link to comment Share on other sites More sharing options...
riess82 Posted April 23, 2020 Author Share Posted April 23, 2020 I believe it stops at die; Hard to say without any output ^^ I have tried this at the beginning of the function now, simply because I have no idea how to do it correctly : dump('asdf2'); VarDumper::dump('asdf2'); Still no output. 1 Link to comment Share on other sites More sharing options...
riess82 Posted April 23, 2020 Author Share Posted April 23, 2020 UPDATE: I did manage to get some output. But I hope there is a better way. I added in defines.inc.php @ini_set('log_errors', 'on'); @ini_set('error_log', 'syslog'); and then was able to use error_log("text here"); I would still be happy if someone could point out a better way. Link to comment Share on other sites More sharing options...
joseantgv Posted April 23, 2020 Share Posted April 23, 2020 I would say that you code is not executed. Have you removed file /var/cache/prod/class_index.php or /var/cache/dev/class_index.php? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now