Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]

   1  <?php
   2  /**
   3   * @version   v5.21.0  2021-02-27
   4   * @copyright (c) 2000-2013 John Lim (jlim#natsoft.com). All rights reserved.
   5   * @copyright (c) 2014      Damien Regad, Mark Newnham and the ADOdb community
   6   * Released under both BSD license and Lesser GPL library license.
   7   * Whenever there is any discrepancy between the two licenses,
   8   * the BSD license will take precedence.
   9   *
  10   * Set tabs to 4 for best viewing.
  11   *
  12   * Latest version is available at https://adodb.org/
  13   *
  14  */
  15  
  16  
  17  // added Claudio Bustos  clbustos#entelchile.net
  18  if (!defined('ADODB_ERROR_HANDLER_TYPE')) define('ADODB_ERROR_HANDLER_TYPE',E_USER_ERROR);
  19  
  20  if (!defined('ADODB_ERROR_HANDLER')) define('ADODB_ERROR_HANDLER','ADODB_Error_Handler');
  21  
  22  /**
  23  * Default Error Handler. This will be called with the following params
  24  *
  25  * @param $dbms	 	 the RDBMS you are connecting to
  26  * @param $fn	 	 the name of the calling function (in uppercase)
  27  * @param $errno	 	 the native error number from the database
  28  * @param $errmsg	 the native error msg from the database
  29  * @param $p1	 	 $fn specific parameter - see below
  30  * @param $p2	 	 $fn specific parameter - see below
  31  * @param $thisConn	 $current connection object - can be false if no connection object created
  32  */
  33  function ADODB_Error_Handler($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection)
  34  {
  35  	 if (error_reporting() == 0) return; // obey @ protocol
  36  	 switch($fn) {
  37  	 case 'EXECUTE':
  38  	 	 $sql = $p1;
  39  	 	 $inputparams = $p2;
  40  
  41  	 	 $s = "$dbms error: [$errno: $errmsg] in $fn(\"$sql\")\n";
  42  	 	 break;
  43  
  44  	 case 'PCONNECT':
  45  	 case 'CONNECT':
  46  	 	 $host = $p1;
  47  	 	 $database = $p2;
  48  
  49  	 	 $s = "$dbms error: [$errno: $errmsg] in $fn($host, '****', '****', $database)\n";
  50  	 	 break;
  51  	 default:
  52  	 	 $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n";
  53  	 	 break;
  54  	 }
  55  	 /*
  56  	 * Log connection error somewhere
  57  	 *	 0 message is sent to PHP's system logger, using the Operating System's system
  58  	 *	 	 logging mechanism or a file, depending on what the error_log configuration
  59  	 *	 	 directive is set to.
  60  	 *	 1 message is sent by email to the address in the destination parameter.
  61  	 *	 	 This is the only message type where the fourth parameter, extra_headers is used.
  62  	 *	 	 This message type uses the same internal function as mail() does.
  63  	 *	 2 message is sent through the PHP debugging connection.
  64  	 *	 	 This option is only available if remote debugging has been enabled.
  65  	 *	 	 In this case, the destination parameter specifies the host name or IP address
  66  	 *	 	 and optionally, port number, of the socket receiving the debug information.
  67  	 *	 3 message is appended to the file destination
  68  	 */
  69  	 if (defined('ADODB_ERROR_LOG_TYPE')) {
  70  	 	 $t = date('Y-m-d H:i:s');
  71  	 	 if (defined('ADODB_ERROR_LOG_DEST'))
  72  	 	 	 error_log("($t) $s", ADODB_ERROR_LOG_TYPE, ADODB_ERROR_LOG_DEST);
  73  	 	 else
  74  	 	 	 error_log("($t) $s", ADODB_ERROR_LOG_TYPE);
  75  	 }
  76  
  77  
  78  	 //print "<p>$s</p>";
  79  	 trigger_error($s,ADODB_ERROR_HANDLER_TYPE);
  80  }