PageRenderTime 58ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/runtime/lib/connection/PropelPDO.php

https://github.com/1989gaurav/Propel
PHP | 772 lines | 356 code | 92 blank | 324 comment | 51 complexity | 801ad6866b49c7e92c8fddd6a5887b22 MD5 | raw file
  1. <?php
  2. /**
  3. * This file is part of the Propel package.
  4. * For the full copyright and license information, please view the LICENSE
  5. * file that was distributed with this source code.
  6. *
  7. * @license MIT License
  8. */
  9. /**
  10. * PDO connection subclass that provides the basic fixes to PDO that are required by Propel.
  11. *
  12. * This class was designed to work around the limitation in PDO where attempting to begin
  13. * a transaction when one has already been begun will trigger a PDOException. Propel
  14. * relies on the ability to create nested transactions, even if the underlying layer
  15. * simply ignores these (because it doesn't support nested transactions).
  16. *
  17. * The changes that this class makes to the underlying API include the addition of the
  18. * getNestedTransactionDepth() and isInTransaction() and the fact that beginTransaction()
  19. * will no longer throw a PDOException (or trigger an error) if a transaction is already
  20. * in-progress.
  21. *
  22. * @author Cameron Brunner <cameron.brunner@gmail.com>
  23. * @author Hans Lellelid <hans@xmpl.org>
  24. * @author Christian Abegg <abegg.ch@gmail.com>
  25. * @since 2006-09-22
  26. * @package propel.runtime.connection
  27. */
  28. class PropelPDO extends PDO
  29. {
  30. /**
  31. * Attribute to use to set whether to cache prepared statements.
  32. */
  33. const PROPEL_ATTR_CACHE_PREPARES = -1;
  34. const DEFAULT_SLOW_THRESHOLD = 0.1;
  35. const DEFAULT_ONLYSLOW_ENABLED = false;
  36. /**
  37. * The current transaction depth.
  38. * @var integer
  39. */
  40. protected $nestedTransactionCount = 0;
  41. /**
  42. * Cache of prepared statements (PDOStatement) keyed by md5 of SQL.
  43. *
  44. * @var array [md5(sql) => PDOStatement]
  45. */
  46. protected $preparedStatements = array();
  47. /**
  48. * Whether to cache prepared statements.
  49. *
  50. * @var boolean
  51. */
  52. protected $cachePreparedStatements = false;
  53. /**
  54. * Whether the final commit is possible
  55. * Is false if a nested transaction is rolled back
  56. */
  57. protected $isUncommitable = false;
  58. /**
  59. * Count of queries performed.
  60. *
  61. * @var integer
  62. */
  63. protected $queryCount = 0;
  64. /**
  65. * SQL code of the latest performed query.
  66. *
  67. * @var string
  68. */
  69. protected $lastExecutedQuery;
  70. /**
  71. * Whether or not the debug is enabled
  72. *
  73. * @var boolean
  74. */
  75. public $useDebug = false;
  76. /**
  77. * Configured BasicLogger (or compatible) logger.
  78. *
  79. * @var BasicLogger
  80. */
  81. protected $logger;
  82. /**
  83. * The log level to use for logging.
  84. *
  85. * @var integer
  86. */
  87. private $logLevel = Propel::LOG_DEBUG;
  88. /**
  89. * The runtime configuration
  90. *
  91. * @var PropelConfiguration
  92. */
  93. protected $configuration;
  94. /**
  95. * The default value for runtime config item "debugpdo.logging.methods".
  96. *
  97. * @var array
  98. */
  99. protected static $defaultLogMethods = array(
  100. 'PropelPDO::exec',
  101. 'PropelPDO::query',
  102. 'DebugPDOStatement::execute',
  103. );
  104. /**
  105. * Creates a PropelPDO instance representing a connection to a database.
  106. *.
  107. * If so configured, specifies a custom PDOStatement class and makes an entry
  108. * to the log with the state of this object just after its initialization.
  109. * Add PropelPDO::__construct to $defaultLogMethods to see this message
  110. *
  111. * @param string $dsn Connection DSN.
  112. * @param string $username The user name for the DSN string.
  113. * @param string $password The password for the DSN string.
  114. * @param array $driver_options A key=>value array of driver-specific connection options.
  115. *
  116. * @throws PDOException if there is an error during connection initialization.
  117. */
  118. public function __construct($dsn, $username = null, $password = null, $driver_options = array())
  119. {
  120. if ($this->useDebug) {
  121. $debug = $this->getDebugSnapshot();
  122. }
  123. parent::__construct($dsn, $username, $password, $driver_options);
  124. if ($this->useDebug) {
  125. $this->configureStatementClass('DebugPDOStatement', true);
  126. $this->log('Opening connection', null, __METHOD__, $debug);
  127. }
  128. }
  129. /**
  130. * Inject the runtime configuration
  131. *
  132. * @param PropelConfiguration $configuration
  133. */
  134. public function setConfiguration($configuration)
  135. {
  136. $this->configuration = $configuration;
  137. }
  138. /**
  139. * Get the runtime configuration
  140. *
  141. * @return PropelConfiguration
  142. */
  143. public function getConfiguration()
  144. {
  145. if (null === $this->configuration) {
  146. $this->configuration = Propel::getConfiguration(PropelConfiguration::TYPE_OBJECT);
  147. }
  148. return $this->configuration;
  149. }
  150. /**
  151. * Gets the current transaction depth.
  152. *
  153. * @return integer
  154. */
  155. public function getNestedTransactionCount()
  156. {
  157. return $this->nestedTransactionCount;
  158. }
  159. /**
  160. * Set the current transaction depth.
  161. * @param int $v The new depth.
  162. */
  163. protected function setNestedTransactionCount($v)
  164. {
  165. $this->nestedTransactionCount = $v;
  166. }
  167. /**
  168. * Is this PDO connection currently in-transaction?
  169. * This is equivalent to asking whether the current nested transaction count is greater than 0.
  170. *
  171. * @return boolean
  172. */
  173. public function isInTransaction()
  174. {
  175. return ($this->getNestedTransactionCount() > 0);
  176. }
  177. /**
  178. * Check whether the connection contains a transaction that can be committed.
  179. * To be used in an evironment where Propelexceptions are caught.
  180. *
  181. * @return boolean True if the connection is in a committable transaction
  182. */
  183. public function isCommitable()
  184. {
  185. return $this->isInTransaction() && !$this->isUncommitable;
  186. }
  187. /**
  188. * Overrides PDO::beginTransaction() to prevent errors due to already-in-progress transaction.
  189. *
  190. * @return boolean
  191. */
  192. public function beginTransaction()
  193. {
  194. $return = true;
  195. if (!$this->nestedTransactionCount) {
  196. $return = parent::beginTransaction();
  197. if ($this->useDebug) {
  198. $this->log('Begin transaction', null, __METHOD__);
  199. }
  200. $this->isUncommitable = false;
  201. }
  202. $this->nestedTransactionCount++;
  203. return $return;
  204. }
  205. /**
  206. * Overrides PDO::commit() to only commit the transaction if we are in the outermost
  207. * transaction nesting level.
  208. *
  209. * @return boolean
  210. */
  211. public function commit()
  212. {
  213. $return = true;
  214. $opcount = $this->nestedTransactionCount;
  215. if ($opcount > 0) {
  216. if ($opcount === 1) {
  217. if ($this->isUncommitable) {
  218. throw new PropelException('Cannot commit because a nested transaction was rolled back');
  219. } else {
  220. $return = parent::commit();
  221. if ($this->useDebug) {
  222. $this->log('Commit transaction', null, __METHOD__);
  223. }
  224. }
  225. }
  226. $this->nestedTransactionCount--;
  227. }
  228. return $return;
  229. }
  230. /**
  231. * Overrides PDO::rollBack() to only rollback the transaction if we are in the outermost
  232. * transaction nesting level
  233. *
  234. * @return boolean Whether operation was successful.
  235. */
  236. public function rollBack()
  237. {
  238. $return = true;
  239. $opcount = $this->nestedTransactionCount;
  240. if ($opcount > 0) {
  241. if ($opcount === 1) {
  242. $return = parent::rollBack();
  243. if ($this->useDebug) {
  244. $this->log('Rollback transaction', null, __METHOD__);
  245. }
  246. } else {
  247. $this->isUncommitable = true;
  248. }
  249. $this->nestedTransactionCount--;
  250. }
  251. return $return;
  252. }
  253. /**
  254. * Rollback the whole transaction, even if this is a nested rollback
  255. * and reset the nested transaction count to 0.
  256. *
  257. * @return boolean Whether operation was successful.
  258. */
  259. public function forceRollBack()
  260. {
  261. $return = true;
  262. if ($this->nestedTransactionCount) {
  263. // If we're in a transaction, always roll it back
  264. // regardless of nesting level.
  265. $return = parent::rollBack();
  266. // reset nested transaction count to 0 so that we don't
  267. // try to commit (or rollback) the transaction outside this scope.
  268. $this->nestedTransactionCount = 0;
  269. if ($this->useDebug) {
  270. $this->log('Rollback transaction', null, __METHOD__);
  271. }
  272. }
  273. return $return;
  274. }
  275. /**
  276. * Sets a connection attribute.
  277. *
  278. * This is overridden here to provide support for setting Propel-specific attributes too.
  279. *
  280. * @param integer $attribute The attribute to set (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
  281. * @param mixed $value The attribute value.
  282. */
  283. public function setAttribute($attribute, $value)
  284. {
  285. switch($attribute) {
  286. case self::PROPEL_ATTR_CACHE_PREPARES:
  287. $this->cachePreparedStatements = $value;
  288. break;
  289. default:
  290. parent::setAttribute($attribute, $value);
  291. }
  292. }
  293. /**
  294. * Gets a connection attribute.
  295. *
  296. * This is overridden here to provide support for setting Propel-specific attributes too.
  297. *
  298. * @param integer $attribute The attribute to get (e.g. PropelPDO::PROPEL_ATTR_CACHE_PREPARES).
  299. * @return mixed
  300. */
  301. public function getAttribute($attribute)
  302. {
  303. switch($attribute) {
  304. case self::PROPEL_ATTR_CACHE_PREPARES:
  305. return $this->cachePreparedStatements;
  306. break;
  307. default:
  308. return parent::getAttribute($attribute);
  309. }
  310. }
  311. /**
  312. * Prepares a statement for execution and returns a statement object.
  313. *
  314. * Overrides PDO::prepare() in order to:
  315. * - Add logging and query counting if logging is true.
  316. * - Add query caching support if the PropelPDO::PROPEL_ATTR_CACHE_PREPARES was set to true.
  317. *
  318. * @param string $sql This must be a valid SQL statement for the target database server.
  319. * @param array $driver_options One $array or more key => value pairs to set attribute values
  320. * for the PDOStatement object that this method returns.
  321. *
  322. * @return PDOStatement
  323. */
  324. public function prepare($sql, $driver_options = array())
  325. {
  326. if ($this->useDebug) {
  327. $debug = $this->getDebugSnapshot();
  328. }
  329. if ($this->cachePreparedStatements) {
  330. if (!isset($this->preparedStatements[$sql])) {
  331. $return = parent::prepare($sql, $driver_options);
  332. $this->preparedStatements[$sql] = $return;
  333. } else {
  334. $return = $this->preparedStatements[$sql];
  335. }
  336. } else {
  337. $return = parent::prepare($sql, $driver_options);
  338. }
  339. if ($this->useDebug) {
  340. $this->log($sql, null, __METHOD__, $debug);
  341. }
  342. return $return;
  343. }
  344. /**
  345. * Execute an SQL statement and return the number of affected rows.
  346. * Overrides PDO::exec() to log queries when required
  347. *
  348. * @param string $sql
  349. * @return integer
  350. */
  351. public function exec($sql)
  352. {
  353. if ($this->useDebug) {
  354. $debug = $this->getDebugSnapshot();
  355. }
  356. $return = parent::exec($sql);
  357. if ($this->useDebug) {
  358. $this->log($sql, null, __METHOD__, $debug);
  359. $this->setLastExecutedQuery($sql);
  360. $this->incrementQueryCount();
  361. }
  362. return $return;
  363. }
  364. /**
  365. * Executes an SQL statement, returning a result set as a PDOStatement object.
  366. * Despite its signature here, this method takes a variety of parameters.
  367. *
  368. * Overrides PDO::query() to log queries when required
  369. *
  370. * @see http://php.net/manual/en/pdo.query.php for a description of the possible parameters.
  371. *
  372. * @return PDOStatement
  373. */
  374. public function query()
  375. {
  376. if ($this->useDebug) {
  377. $debug = $this->getDebugSnapshot();
  378. }
  379. $args = func_get_args();
  380. if (version_compare(PHP_VERSION, '5.3', '<')) {
  381. $return = call_user_func_array(array($this, 'parent::query'), $args);
  382. } else {
  383. $return = call_user_func_array('parent::query', $args);
  384. }
  385. if ($this->useDebug) {
  386. $sql = $args[0];
  387. $this->log($sql, null, __METHOD__, $debug);
  388. $this->setLastExecutedQuery($sql);
  389. $this->incrementQueryCount();
  390. }
  391. return $return;
  392. }
  393. /**
  394. * Clears any stored prepared statements for this connection.
  395. */
  396. public function clearStatementCache()
  397. {
  398. $this->preparedStatements = array();
  399. }
  400. /**
  401. * Configures the PDOStatement class for this connection.
  402. *
  403. * @param string $class
  404. * @param boolean $suppressError Whether to suppress an exception if the statement class cannot be set.
  405. *
  406. * @throws PropelException if the statement class cannot be set (and $suppressError is false).
  407. */
  408. protected function configureStatementClass($class = 'PDOStatement', $suppressError = true)
  409. {
  410. // extending PDOStatement is only supported with non-persistent connections
  411. if (!$this->getAttribute(PDO::ATTR_PERSISTENT)) {
  412. $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array($class, array($this)));
  413. } elseif (!$suppressError) {
  414. throw new PropelException('Extending PDOStatement is not supported with persistent connections.');
  415. }
  416. }
  417. /**
  418. * Returns the number of queries this DebugPDO instance has performed on the database connection.
  419. *
  420. * When using DebugPDOStatement as the statement class, any queries by DebugPDOStatement instances
  421. * are counted as well.
  422. *
  423. * @throws PropelException if persistent connection is used (since unable to override PDOStatement in that case).
  424. * @return integer
  425. */
  426. public function getQueryCount()
  427. {
  428. // extending PDOStatement is not supported with persistent connections
  429. if ($this->getAttribute(PDO::ATTR_PERSISTENT)) {
  430. throw new PropelException('Extending PDOStatement is not supported with persistent connections. Count would be inaccurate, because we cannot count the PDOStatment::execute() calls. Either don\'t use persistent connections or don\'t call PropelPDO::getQueryCount()');
  431. }
  432. return $this->queryCount;
  433. }
  434. /**
  435. * Increments the number of queries performed by this DebugPDO instance.
  436. *
  437. * Returns the original number of queries (ie the value of $this->queryCount before calling this method).
  438. *
  439. * @return integer
  440. */
  441. public function incrementQueryCount()
  442. {
  443. $this->queryCount++;
  444. }
  445. /**
  446. * Get the SQL code for the latest query executed by Propel
  447. *
  448. * @return string Executable SQL code
  449. */
  450. public function getLastExecutedQuery()
  451. {
  452. return $this->lastExecutedQuery;
  453. }
  454. /**
  455. * Set the SQL code for the latest query executed by Propel
  456. *
  457. * @param string $query Executable SQL code
  458. */
  459. public function setLastExecutedQuery($query)
  460. {
  461. $this->lastExecutedQuery = $query;
  462. }
  463. /**
  464. * Enable or disable the query debug features
  465. *
  466. * @param boolean $value True to enable debug (default), false to disable it
  467. */
  468. public function useDebug($value = true)
  469. {
  470. if ($value) {
  471. $this->configureStatementClass('DebugPDOStatement', true);
  472. } else {
  473. // reset query logging
  474. $this->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('PDOStatement'));
  475. $this->setLastExecutedQuery('');
  476. $this->queryCount = 0;
  477. }
  478. $this->clearStatementCache();
  479. $this->useDebug = $value;
  480. }
  481. /**
  482. * Sets the logging level to use for logging method calls and SQL statements.
  483. *
  484. * @param integer $level Value of one of the Propel::LOG_* class constants.
  485. */
  486. public function setLogLevel($level)
  487. {
  488. $this->logLevel = $level;
  489. }
  490. /**
  491. * Sets a logger to use.
  492. *
  493. * The logger will be used by this class to log various method calls and their properties.
  494. *
  495. * @param BasicLogger $logger A Logger with an API compatible with BasicLogger (or PEAR Log).
  496. */
  497. public function setLogger($logger)
  498. {
  499. $this->logger = $logger;
  500. }
  501. /**
  502. * Gets the logger in use.
  503. *
  504. * @return BasicLogger A Logger with an API compatible with BasicLogger (or PEAR Log).
  505. */
  506. public function getLogger()
  507. {
  508. return $this->logger;
  509. }
  510. /**
  511. * Logs the method call or SQL using the Propel::log() method or a registered logger class.
  512. *
  513. * @uses self::getLogPrefix()
  514. * @see self::setLogger()
  515. *
  516. * @param string $msg Message to log.
  517. * @param integer $level Log level to use; will use self::setLogLevel() specified level by default.
  518. * @param string $methodName Name of the method whose execution is being logged.
  519. * @param array $debugSnapshot Previous return value from self::getDebugSnapshot().
  520. */
  521. public function log($msg, $level = null, $methodName = null, array $debugSnapshot = null)
  522. {
  523. // If logging has been specifically disabled, this method won't do anything
  524. if (!$this->getLoggingConfig('enabled', true)) {
  525. return;
  526. }
  527. // If the method being logged isn't one of the ones to be logged, bail
  528. if (!in_array($methodName, $this->getLoggingConfig('methods', self::$defaultLogMethods))) {
  529. return;
  530. }
  531. // If a logging level wasn't provided, use the default one
  532. if ($level === null) {
  533. $level = $this->logLevel;
  534. }
  535. // Determine if this query is slow enough to warrant logging
  536. if ($this->getLoggingConfig("onlyslow", self::DEFAULT_ONLYSLOW_ENABLED)) {
  537. $now = $this->getDebugSnapshot();
  538. if ($now['microtime'] - $debugSnapshot['microtime'] < $this->getLoggingConfig("details.slow.threshold", self::DEFAULT_SLOW_THRESHOLD)) return;
  539. }
  540. // If the necessary additional parameters were given, get the debug log prefix for the log line
  541. if ($methodName && $debugSnapshot) {
  542. $msg = $this->getLogPrefix($methodName, $debugSnapshot) . $msg;
  543. }
  544. // We won't log empty messages
  545. if (!$msg) {
  546. return;
  547. }
  548. // Delegate the actual logging forward
  549. if ($this->logger) {
  550. $this->logger->log($msg, $level);
  551. } else {
  552. Propel::log($msg, $level);
  553. }
  554. }
  555. /**
  556. * Returns a snapshot of the current values of some functions useful in debugging.
  557. *
  558. * @return array
  559. */
  560. public function getDebugSnapshot()
  561. {
  562. if ($this->useDebug) {
  563. return array(
  564. 'microtime' => microtime(true),
  565. 'memory_get_usage' => memory_get_usage($this->getLoggingConfig('realmemoryusage', false)),
  566. 'memory_get_peak_usage' => memory_get_peak_usage($this->getLoggingConfig('realmemoryusage', false)),
  567. );
  568. } else {
  569. throw new PropelException('Should not get debug snapshot when not debugging');
  570. }
  571. }
  572. /**
  573. * Returns a named configuration item from the Propel runtime configuration, from under the
  574. * 'debugpdo.logging' prefix. If such a configuration setting hasn't been set, the given default
  575. * value will be returned.
  576. *
  577. * @param string $key Key for which to return the value.
  578. * @param mixed $defaultValue Default value to apply if config item hasn't been set.
  579. *
  580. * @return mixed
  581. */
  582. protected function getLoggingConfig($key, $defaultValue)
  583. {
  584. return $this->getConfiguration()->getParameter("debugpdo.logging.$key", $defaultValue);
  585. }
  586. /**
  587. * Returns a prefix that may be prepended to a log line, containing debug information according
  588. * to the current configuration.
  589. *
  590. * Uses a given $debugSnapshot to calculate how much time has passed since the call to self::getDebugSnapshot(),
  591. * how much the memory consumption by PHP has changed etc.
  592. *
  593. * @see self::getDebugSnapshot()
  594. *
  595. * @param string $methodName Name of the method whose execution is being logged.
  596. * @param array $debugSnapshot A previous return value from self::getDebugSnapshot().
  597. *
  598. * @return string
  599. */
  600. protected function getLogPrefix($methodName, $debugSnapshot)
  601. {
  602. $config = $this->getConfiguration()->getParameters();
  603. if (!isset($config['debugpdo']['logging']['details'])) {
  604. return '';
  605. }
  606. $prefix = '';
  607. $logDetails = $config['debugpdo']['logging']['details'];
  608. $now = $this->getDebugSnapshot();
  609. $innerGlue = $this->getLoggingConfig('innerglue', ': ');
  610. $outerGlue = $this->getLoggingConfig('outerglue', ' | ');
  611. // Iterate through each detail that has been configured to be enabled
  612. foreach ($logDetails as $detailName => $details) {
  613. if (!$this->getLoggingConfig("details.$detailName.enabled", false)) {
  614. continue;
  615. }
  616. switch ($detailName) {
  617. case 'slow';
  618. $value = $now['microtime'] - $debugSnapshot['microtime'] >= $this->getLoggingConfig('details.slow.threshold', self::DEFAULT_SLOW_THRESHOLD) ? 'YES' : ' NO';
  619. break;
  620. case 'time':
  621. $value = number_format($now['microtime'] - $debugSnapshot['microtime'], $this->getLoggingConfig('details.time.precision', 3)) . ' sec';
  622. $value = str_pad($value, $this->getLoggingConfig('details.time.pad', 10), ' ', STR_PAD_LEFT);
  623. break;
  624. case 'mem':
  625. $value = self::getReadableBytes($now['memory_get_usage'], $this->getLoggingConfig('details.mem.precision', 1));
  626. $value = str_pad($value, $this->getLoggingConfig('details.mem.pad', 9), ' ', STR_PAD_LEFT);
  627. break;
  628. case 'memdelta':
  629. $value = $now['memory_get_usage'] - $debugSnapshot['memory_get_usage'];
  630. $value = ($value > 0 ? '+' : '') . self::getReadableBytes($value, $this->getLoggingConfig('details.memdelta.precision', 1));
  631. $value = str_pad($value, $this->getLoggingConfig('details.memdelta.pad', 10), ' ', STR_PAD_LEFT);
  632. break;
  633. case 'mempeak':
  634. $value = self::getReadableBytes($now['memory_get_peak_usage'], $this->getLoggingConfig('details.mempeak.precision', 1));
  635. $value = str_pad($value, $this->getLoggingConfig('details.mempeak.pad', 9), ' ', STR_PAD_LEFT);
  636. break;
  637. case 'querycount':
  638. $value = str_pad($this->getQueryCount(), $this->getLoggingConfig('details.querycount.pad', 2), ' ', STR_PAD_LEFT);
  639. break;
  640. case 'method':
  641. $value = str_pad($methodName, $this->getLoggingConfig('details.method.pad', 28), ' ', STR_PAD_RIGHT);
  642. break;
  643. default:
  644. $value = 'n/a';
  645. break;
  646. }
  647. $prefix .= $detailName . $innerGlue . $value . $outerGlue;
  648. }
  649. return $prefix;
  650. }
  651. /**
  652. * Returns a human-readable representation of the given byte count.
  653. *
  654. * @param integer $bytes Byte count to convert.
  655. * @param integer $precision How many decimals to include.
  656. *
  657. * @return string
  658. */
  659. protected function getReadableBytes($bytes, $precision)
  660. {
  661. $suffix = array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
  662. $total = count($suffix);
  663. for ($i = 0; $bytes > 1024 && $i < $total; $i++) {
  664. $bytes /= 1024;
  665. }
  666. return number_format($bytes, $precision) . ' ' . $suffix[$i];
  667. }
  668. /**
  669. * If so configured, makes an entry to the log of the state of this object just prior to its destruction.
  670. * Add PropelPDO::__destruct to $defaultLogMethods to see this message
  671. *
  672. * @see self::log()
  673. */
  674. public function __destruct()
  675. {
  676. if ($this->useDebug) {
  677. $this->log('Closing connection', null, __METHOD__, $this->getDebugSnapshot());
  678. }
  679. }
  680. }