/**
  * @return string
  */
 public static function getDebugTrail()
 {
     tx_rnbase::load('tx_rnbase_util_TYPO3');
     if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) {
         return \TYPO3\CMS\Core\Utility\DebugUtility::debugTrail();
     } else {
         return t3lib_utility_Debug::debugTrail();
     }
 }
 /**
  * Logs a call to a deprecated function.
  * The log message will be taken from the annotation.
  * @return void
  */
 public static function logDeprecatedFunction()
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     // This require_once is needed for deprecation calls
     // thrown early during bootstrap, if the autoloader is
     // not instantiated yet. This can happen for example if
     // ext_localconf triggers a deprecation.
     require_once 'utility/class.t3lib_utility_debug.php';
     $trail = debug_backtrace();
     if ($trail[1]['type']) {
         $function = new ReflectionMethod($trail[1]['class'], $trail[1]['function']);
     } else {
         $function = new ReflectionFunction($trail[1]['function']);
     }
     $msg = '';
     if (preg_match('/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
         $msg = $match[1];
     }
     // trigger PHP error with a short message: <function> is deprecated (called from <source>, defined in <source>)
     $errorMsg = 'Function ' . $trail[1]['function'];
     if ($trail[1]['class']) {
         $errorMsg .= ' of class ' . $trail[1]['class'];
     }
     $errorMsg .= ' is deprecated (called from ' . $trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
     // write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
     $logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
     $logMsg .= '() - ' . $msg . ' - ' . t3lib_utility_Debug::debugTrail();
     $logMsg .= ' (' . substr($function->getFileName(), strlen(PATH_site)) . '#' . $function->getStartLine() . ')';
     self::deprecationLog($logMsg);
 }
 /**
  * Logs a call to a deprecated function.
  * The log message will be taken from the annotation.
  * @return	void
  */
 public static function logDeprecatedFunction()
 {
     if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['enableDeprecationLog']) {
         return;
     }
     $trail = debug_backtrace();
     if ($trail[1]['type']) {
         $function = new ReflectionMethod($trail[1]['class'], $trail[1]['function']);
     } else {
         $function = new ReflectionFunction($trail[1]['function']);
     }
     $msg = '';
     if (preg_match('/@deprecated\\s+(.*)/', $function->getDocComment(), $match)) {
         $msg = $match[1];
     }
     // trigger PHP error with a short message: <function> is deprecated (called from <source>, defined in <source>)
     $errorMsg = 'Function ' . $trail[1]['function'];
     if ($trail[1]['class']) {
         $errorMsg .= ' of class ' . $trail[1]['class'];
     }
     $errorMsg .= ' is deprecated (called from ' . $trail[1]['file'] . '#' . $trail[1]['line'] . ', defined in ' . $function->getFileName() . '#' . $function->getStartLine() . ')';
     // write a longer message to the deprecation log: <function> <annotion> - <trace> (<source>)
     $logMsg = $trail[1]['class'] . $trail[1]['type'] . $trail[1]['function'];
     $logMsg .= '() - ' . $msg . ' - ' . t3lib_utility_Debug::debugTrail();
     $logMsg .= ' (' . substr($function->getFileName(), strlen(PATH_site)) . '#' . $function->getStartLine() . ')';
     self::deprecationLog($logMsg);
 }
 public static function debugTrail()
 {
     $result = FALSE;
     $callingClassName = '\\TYPO3\\CMS\\Core\\Utility\\DebugUtility';
     if (class_exists($callingClassName) && method_exists($callingClassName, 'debugTrail')) {
         $result = call_user_func($callingClassName . '::debugTrail');
     } else {
         if (class_exists('t3lib_utility_Debug') && method_exists('t3lib_utility_Debug', 'debugTrail')) {
             $result = t3lib_utility_Debug::debugTrail();
         } else {
             if (class_exists('t3lib_div') && method_exists('t3lib_div', 'debugTrail')) {
                 $result = t3lib_div::debugTrail();
             }
         }
     }
     return $result;
 }
 /**
  * Explain select queries
  * If $this->explainOutput is set, SELECT queries will be explained here. Only queries with more than one possible result row will be displayed.
  * The output is either printed as raw HTML output or embedded into the TS admin panel (checkbox must be enabled!)
  *
  * TODO: Feature is not DBAL-compliant
  *
  * @param	string		SQL query
  * @param	string		Table(s) from which to select. This is what comes right after "FROM ...". Required value.
  * @param	integer		Number of resulting rows
  * @return	boolean		True if explain was run, false otherwise
  */
 protected function explain($query, $from_table, $row_count)
 {
     if ((int) $this->explainOutput == 1 || (int) $this->explainOutput == 2 && t3lib_div::cmpIP(t3lib_div::getIndpEnv('REMOTE_ADDR'), $GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask'])) {
         // raw HTML output
         $explainMode = 1;
     } elseif ((int) $this->explainOutput == 3 && is_object($GLOBALS['TT'])) {
         // embed the output into the TS admin panel
         $explainMode = 2;
     } else {
         return FALSE;
     }
     $error = $this->sql_error();
     $trail = t3lib_utility_Debug::debugTrail();
     $explain_tables = array();
     $explain_output = array();
     $res = $this->sql_query('EXPLAIN ' . $query, $this->link);
     if (is_resource($res)) {
         while ($tempRow = $this->sql_fetch_assoc($res)) {
             $explain_output[] = $tempRow;
             $explain_tables[] = $tempRow['table'];
         }
         $this->sql_free_result($res);
     }
     $indices_output = array();
     // Notice: Rows are skipped if there is only one result, or if no conditions are set
     if ($explain_output[0]['rows'] > 1 || t3lib_div::inList('ALL', $explain_output[0]['type'])) {
         // only enable output if it's really useful
         $debug = TRUE;
         foreach ($explain_tables as $table) {
             $tableRes = $this->sql_query('SHOW TABLE STATUS LIKE \'' . $table . '\'');
             $isTable = $this->sql_num_rows($tableRes);
             if ($isTable) {
                 $res = $this->sql_query('SHOW INDEX FROM ' . $table, $this->link);
                 if (is_resource($res)) {
                     while ($tempRow = $this->sql_fetch_assoc($res)) {
                         $indices_output[] = $tempRow;
                     }
                     $this->sql_free_result($res);
                 }
             }
             $this->sql_free_result($tableRes);
         }
     } else {
         $debug = FALSE;
     }
     if ($debug) {
         if ($explainMode) {
             $data = array();
             $data['query'] = $query;
             $data['trail'] = $trail;
             $data['row_count'] = $row_count;
             if ($error) {
                 $data['error'] = $error;
             }
             if (count($explain_output)) {
                 $data['explain'] = $explain_output;
             }
             if (count($indices_output)) {
                 $data['indices'] = $indices_output;
             }
             if ($explainMode == 1) {
                 t3lib_utility_Debug::debug($data, 'Tables: ' . $from_table, 'DB SQL EXPLAIN');
             } elseif ($explainMode == 2) {
                 $GLOBALS['TT']->setTSselectQuery($data);
             }
         }
         return TRUE;
     }
     return FALSE;
 }