Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401]

   1  <?php
   2  /**
   3   * ADOdb Default Error Handler.
   4   *
   5   * This file is part of ADOdb, a Database Abstraction Layer library for PHP.
   6   *
   7   * @package ADOdb
   8   * @link https://adodb.org Project's web site and documentation
   9   * @link https://github.com/ADOdb/ADOdb Source code and issue tracker
  10   *
  11   * The ADOdb Library is dual-licensed, released under both the BSD 3-Clause
  12   * and the GNU Lesser General Public Licence (LGPL) v2.1 or, at your option,
  13   * any later version. This means you can use it in proprietary products.
  14   * See the LICENSE.md file distributed with this source code for details.
  15   * @license BSD-3-Clause
  16   * @license LGPL-2.1-or-later
  17   *
  18   * @copyright 2000-2013 John Lim
  19   * @copyright 2014 Damien Regad, Mark Newnham and the ADOdb community
  20   */
  21  
  22  // added Claudio Bustos  clbustos#entelchile.net
  23  if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
  24  
  25  if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
  26  
  27  /**
  28  * Default Error Handler. This will be called with the following params
  29  *
  30  * @param $dbms	 	 the RDBMS you are connecting to
  31  * @param $fn	 	 the name of the calling function (in uppercase)
  32  * @param $errno	 	 the native error number from the database
  33  * @param $errmsg	 the native error msg from the database
  34  * @param $p1	 	 $fn specific parameter - see below
  35  * @param $p2	 	 $fn specific parameter - see below
  36  * @param $thisConn	 $current connection object - can be false if no connection object created
  37  */
  38  function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
  39  {
  40  	 if (error_reporting() == 0) return; // obey @ protocol
  41  	 switch($fn) {
  42  	 case 'EXECUTE':
  43  	 	 $sql = $p1;
  44  	 	 $inputparams = $p2;
  45  
  46  	 	 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
  47  	 	 break;
  48  
  49  	 case 'PCONNECT':
  50  	 case 'CONNECT':
  51  	 	 $host = $p1;
  52  	 	 $database = $p2;
  53  
  54  	 	 $s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
  55  	 	 break;
  56  	 default:
  57  	 	 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
  58  	 	 break;
  59  	 }
  60  	 /*
  61  	 * Log connection error somewhere
  62  	 *	 0 message is sent to PHP's system logger, using the Operating System's system
  63  	 *	 	 logging mechanism or a file, depending on what the error_log configuration
  64  	 *	 	 directive is set to.
  65  	 *	 1 message is sent by email to the address in the destination parameter.
  66  	 *	 	 This is the only message type where the fourth parameter, extra_headers is used.
  67  	 *	 	 This message type uses the same internal function as mail() does.
  68  	 *	 2 message is sent through the PHP debugging connection.
  69  	 *	 	 This option is only available if remote debugging has been enabled.
  70  	 *	 	 In this case, the destination parameter specifies the host name or IP address
  71  	 *	 	 and optionally, port number, of the socket receiving the debug information.
  72  	 *	 3 message is appended to the file destination
  73  	 */
  74  	 if (defined('ADODB_ERROR_LOG_TYPE')) {
  75  	 	 $t = date('Y-m-d H:i:s');
  76  	 	 if (defined('ADODB_ERROR_LOG_DEST'))
  77  	 	 	 error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
  78  	 	 else
  79  	 	 	 error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
  80  	 }
  81  
  82  
  83  	 //print "<p>$s</p>";
  84  	 trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
  85  }