N°1001 setup : log all modifications done on the DB in a SQL file (/log/setup-queries-YYYY-MM-DD_HH-mm.sql)

SVN:trunk[5445]
This commit is contained in:
Pierre Goiffon
2018-03-16 10:00:04 +00:00
parent e7b94d3132
commit c66884be0a
2 changed files with 28 additions and 0 deletions

View File

@@ -99,6 +99,7 @@ class RunTimeEnvironment
public function LogQueryCallback($sQuery, $fDuration)
{
$this->log_info(sprintf('%.3fs - query: %s ', $fDuration, $sQuery));
$this->log_db_query($sQuery);
}
/**
@@ -917,6 +918,25 @@ class RunTimeEnvironment
{
SetupPage::log_ok($sText);
}
/**
* Writes queries run by the setup in a SQL file
*
* @param string $sQuery
*
* @since 2.5 #1001 utf8mb4 switch
* @uses \SetupUtils::GetSetupQueriesFilePath()
*/
protected function log_db_query($sQuery)
{
$sSetupQueriesFilePath = SetupUtils::GetSetupQueriesFilePath();
$hSetupQueriesFile = @fopen($sSetupQueriesFilePath, 'a');
if ($hSetupQueriesFile !== false)
{
fwrite($hSetupQueriesFile, "$sQuery\n");
fclose($hSetupQueriesFile);
}
}
public function GetCurrentDataModelVersion()
{

View File

@@ -1821,6 +1821,14 @@ EOF
}
return $aLicenses;
}
/**
* @return string path to the log file where the create and/or alter queries are written
*/
static public function GetSetupQueriesFilePath()
{
return APPROOT.'log/setup-queries-'.strftime('%Y-%m-%d_%H_%M').'.sql';
}
}
/**