cubecart / v6

CubeCart Version 6
https://cubecart.com
71 stars 58 forks source link

Code Check: Error Use #3567

Open bhsmither opened 2 months ago

bhsmither commented 2 months ago

In mysqli.class.php, in public function error(), the return is a boolean.

However, in Database->_sqlDebug(), there is a call to $this->error(), the result of it is being used to build a string.

Suggest in error(), change:

From:
return ($this->_db_connect_id->errno) ? true : false;

To:
$this->_errorno = (int)$this->_db_connect_id->errno;
return ((bool)$this->_errorno) ? true : false;

Then, in _sqlDebug(), change:

From:
$this->_error = ($this->error()) ? $this->error().': '.$this->errorInfo() : false;

To:
$this->_error = ($this->error()) ? $this->_errorno . ': '.$this->errorInfo() : false;

This will need to add the class variable protected $_errorno;.

abrookbanks commented 2 months ago

Thanks.

abrookbanks commented 2 months ago

PHP Deprecated: Creation of dynamic property Database::$_errorno is deprecated in /home/{..}/precisionwiresaw.com/public_html/classes/db/mysqli.class.php on line 97

bhsmither commented 2 months ago

I recommend a protected class variable. Private class variables might not be accessible in mysqli.php.

I will have to review who is the parent and who is the child in:

class Database extends Database_Contoller

A parent's private aspects cannot be seen by the children. Is that the same the other way around?

Anyway, that's why I chose Protected - so that the parent and child has access to it equally.

abrookbanks commented 2 months ago

OK thanks.