Skip to content

Commit

Permalink
Work around the fact that Contao\Database::getInstance() always creat…
Browse files Browse the repository at this point in the history
…es an instance.

Contao\Database::getInstance() always creates an instance, even when no
driver is configured.
Therefore we must check that the Db is configured properly.
  • Loading branch information
discordier committed Oct 31, 2014
1 parent a914717 commit ac126a0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/MetaModels/BackendIntegration/Boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,20 @@ protected static function initializeContaoObjectStack()
* Check if the database has been correctly configured.
*
* @return bool
*
* @SuppressWarnings(PHPMD.Superglobals)
* @SuppressWarnings(PHPMD.CamelCaseVariableName)
*/
protected static function isDBInitialized()
{
// Work around the fact that Contao\Database::getInstance() always creates an instance, even when no driver is
// configured.
if (empty($GLOBALS['TL_CONFIG']['dbDriver'])) {
false;

This comment has been minimized.

Copy link
@Zeromax

Zeromax Oct 31, 2014

Contributor

@discordier return forgotten..

}

// When coming from install.php or somewhere else when localconfig.php
// has not yet completely been initialized, we will run into an exception here.
// has not yet completely been initialized, we will run into an exception here (see Contao/core#6088).
try {
$objDB = \Database::getInstance();
return $objDB
Expand Down

1 comment on commit ac126a0

@Zeromax
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@discordier Thank you ;)

Please sign in to comment.