[-] Installer : ignore port when creating the sender e-mail address #PSCFV-3756

// Improved profiling tool

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@17004 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
dMetzger
2012-08-27 06:47:41 +00:00
parent ef4a9f83ba
commit 4cabe99f19
3 changed files with 47 additions and 33 deletions
+3 -1
View File
@@ -175,9 +175,11 @@ class ToolsCore
* @param boolean $entities * @param boolean $entities
* @return string host * @return string host
*/ */
public static function getHttpHost($http = false, $entities = false) public static function getHttpHost($http = false, $entities = false, $ignore_port = false)
{ {
$host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']); $host = (isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : $_SERVER['HTTP_HOST']);
if ($ignore_port && $pos = strpos($host, ':'))
$host = substr($host, 0, $pos);
if ($entities) if ($entities)
$host = htmlspecialchars($host, ENT_COMPAT, 'UTF-8'); $host = htmlspecialchars($host, ENT_COMPAT, 'UTF-8');
if ($http) if ($http)
+1 -1
View File
@@ -79,7 +79,7 @@ class InstallModelMail extends InstallAbstractModel
$swift = new Swift(new Swift_Connection_NativeMail()); $swift = new Swift(new Swift_Connection_NativeMail());
$message = new Swift_Message($subject, $content, 'text/html'); $message = new Swift_Message($subject, $content, 'text/html');
if (@$swift->send($message, $this->email, 'no-reply@'.Tools::getHttpHost())) if (@$swift->send($message, $this->email, 'no-reply@'.Tools::getHttpHost(false, false, true)))
$result = false; $result = false;
else else
$result = 'Could not send message'; $result = 'Could not send message';
+43 -31
View File
@@ -69,41 +69,53 @@ abstract class Db extends DbCore
*/ */
public function query($sql) public function query($sql)
{ {
$uniqSql = preg_replace('/[0-9]+/', '<span style="color:blue">XX</span>', $sql); $explain = false;
if (!isset($this->uniqQueries[$uniqSql])) if (preg_match('/^\s*explain\s+/i', $sql))
$this->uniqQueries[$uniqSql] = 0; $explain = true;
$this->uniqQueries[$uniqSql]++;
if (!$explain)
// No cache for query
if ($this->disableCache)
$sql = preg_replace('/^select /i', 'SELECT SQL_NO_CACHE ', trim($sql));
// Get tables in quer
preg_match_all('/(from|join)\s+`?'._DB_PREFIX_.'([a-z0-9_-]+)/ui', $sql, $matches);
foreach ($matches[2] as $table)
{ {
if (!isset($this->tables[$table])) $uniqSql = preg_replace('/[0-9]+/', '<span style="color:blue">XX</span>', $sql);
$this->tables[$table] = 0; if (!isset($this->uniqQueries[$uniqSql]))
$this->tables[$table]++; $this->uniqQueries[$uniqSql] = 0;
} $this->uniqQueries[$uniqSql]++;
// Execute query // No cache for query
$start = microtime(true); if ($this->disableCache)
$sql = preg_replace('/^\s*select\s+/i', 'SELECT SQL_NO_CACHE ', trim($sql));
// Get tables in quer
preg_match_all('/(from|join)\s+`?'._DB_PREFIX_.'([a-z0-9_-]+)/ui', $sql, $matches);
foreach ($matches[2] as $table)
{
if (!isset($this->tables[$table]))
$this->tables[$table] = 0;
$this->tables[$table]++;
}
// Execute query
$start = microtime(true);
}
$result = parent::query($sql); $result = parent::query($sql);
$end = microtime(true);
// Save details if (!$explain)
$timeSpent = $end - $start; {
$trace = debug_backtrace(false); $end = microtime(true);
while (preg_match('@[/\\\\]classes[/\\\\]db[/\\\\]@i', $trace[0]['file']))
array_shift($trace); // Save details
$timeSpent = $end - $start;
$this->queries[] = array( $trace = debug_backtrace(false);
'query' => $sql, while (preg_match('@[/\\\\]classes[/\\\\]db[/\\\\]@i', $trace[0]['file']))
'time' => $timeSpent, array_shift($trace);
'file' => $trace[0]['file'],
'line' => $trace[0]['line'], $this->queries[] = array(
); 'query' => $sql,
'time' => $timeSpent,
'file' => $trace[0]['file'],
'line' => $trace[0]['line'],
);
}
return $result; return $result;
} }