This file is indexed.

/usr/share/php/propel/connection/DebugPDOStatement.php is in php-propel-runtime 1.6.9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<?php

/**
 * This file is part of the Propel package.
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 *
 * @license    MIT License
 */

/**
 * PDOStatement that provides some enhanced functionality needed by Propel.
 *
 * Simply adds the ability to count the number of queries executed and log the queries/method calls.
 *
 * @author     Oliver Schonrock <oliver@realtsp.com>
 * @author     Jarno Rantanen <jarno.rantanen@tkk.fi>
 * @since      2007-07-12
 * @package    propel.runtime.connection
 */
class DebugPDOStatement extends PDOStatement
{
    /**
     * The PDO connection from which this instance was created.
     *
     * @var       PropelPDO
     */
    protected $pdo;

    /**
     * Hashmap for resolving the PDO::PARAM_* class constants to their human-readable names.
     * This is only used in logging the binding of variables.
     *
     * @see       self::bindValue()
     * @var       array
     */
    protected static $typeMap = array(
        PDO::PARAM_BOOL => "PDO::PARAM_BOOL",
        PDO::PARAM_INT => "PDO::PARAM_INT",
        PDO::PARAM_STR => "PDO::PARAM_STR",
        PDO::PARAM_LOB => "PDO::PARAM_LOB",
        PDO::PARAM_NULL => "PDO::PARAM_NULL",
    );

    /**
     * @var       array  The values that have been bound
     */
    protected $boundValues = array();

    /**
     * Construct a new statement class with reference to main DebugPDO object from
     * which this instance was created.
     *
     * @param  PropelPDO         $pdo Reference to the parent PDO instance.
     * @return DebugPDOStatement
     */
    protected function __construct(PropelPDO $pdo)
    {
        $this->pdo = $pdo;
    }

    /**
     * @return string
     */
    public function getExecutedQueryString()
    {
        $sql = $this->queryString;
        $matches = array();
        if (preg_match_all('/(:p[0-9]+\b)/', $sql, $matches)) {
            $size = count($matches[1]);
            for ($i = $size-1; $i >= 0; $i--) {
                $pos = $matches[1][$i];
                $sql = str_replace($pos, $this->boundValues[$pos], $sql);
            }
        }

        return $sql;
    }

    /**
     * Executes a prepared statement.  Returns a boolean value indicating success.
     * Overridden for query counting and logging.
     *
     * @param  string  $input_parameters
     * @return boolean
     */
    public function execute($input_parameters = null)
    {
        $debug	= $this->pdo->getDebugSnapshot();
        $return	= parent::execute($input_parameters);

        $sql = $this->getExecutedQueryString();
        $this->pdo->log($sql, null, __METHOD__, $debug);
        $this->pdo->setLastExecutedQuery($sql);
        $this->pdo->incrementQueryCount();

        return $return;
    }

    /**
     * Binds a value to a corresponding named or question mark placeholder in the SQL statement
     * that was use to prepare the statement. Returns a boolean value indicating success.
     *
     * @param integer $pos   Parameter identifier (for determining what to replace in the query).
     * @param mixed   $value The value to bind to the parameter.
     * @param integer $type  Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
     *
     * @return boolean
     */
    public function bindValue($pos, $value, $type = PDO::PARAM_STR)
    {
        $debug    = $this->pdo->getDebugSnapshot();
        $typestr  = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)';
        $return   = parent::bindValue($pos, $value, $type);
        $valuestr = $type == PDO::PARAM_LOB ? '[LOB value]' : var_export($value, true);
        $msg      = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr);

        $this->boundValues[$pos] = $valuestr;

        $this->pdo->log($msg, null, __METHOD__, $debug);

        return $return;
    }

    /**
     * Binds a PHP variable to a corresponding named or question mark placeholder in the SQL statement
     * that was use to prepare the statement. Unlike PDOStatement::bindValue(), the variable is bound
     * as a reference and will only be evaluated at the time that PDOStatement::execute() is called.
     * Returns a boolean value indicating success.
     *
     * @param integer $pos            Parameter identifier (for determining what to replace in the query).
     * @param mixed   $value          The value to bind to the parameter.
     * @param integer $type           Explicit data type for the parameter using the PDO::PARAM_* constants. Defaults to PDO::PARAM_STR.
     * @param integer $length         Length of the data type. To indicate that a parameter is an OUT parameter from a stored procedure, you must explicitly set the length.
     * @param mixed   $driver_options
     *
     * @return boolean
     */
    public function bindParam($pos, &$value, $type = PDO::PARAM_STR, $length = 0, $driver_options = null)
    {
        $debug    = $this->pdo->getDebugSnapshot();
        $typestr  = isset(self::$typeMap[$type]) ? self::$typeMap[$type] : '(default)';
        $return   = parent::bindParam($pos, $value, $type, $length, $driver_options);
        $valuestr = $length > 100 ? '[Large value]' : var_export($value, true);
        $msg      = sprintf('Binding %s at position %s w/ PDO type %s', $valuestr, $pos, $typestr);

        $this->boundValues[$pos] = $valuestr;

        $this->pdo->log($msg, null, __METHOD__, $debug);

        return $return;
    }
}