Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
use Joomla\CMS\Table\Extension;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserHelper;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseFactory;
use Joomla\Database\ParameterType;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
Expand Down Expand Up @@ -322,7 +322,7 @@ public function save($data)
}

try {
$revisedDbo = DatabaseDriver::getInstance($options);
$revisedDbo = (new DatabaseFactory())->getDriver($options['driver'], $options);
$revisedDbo->getVersion();
} catch (\Exception $e) {
$app->enqueueMessage(Text::sprintf('COM_CONFIG_ERROR_DATABASE_NOT_AVAILABLE', $e->getCode(), $e->getMessage()), 'error');
Expand Down
4 changes: 2 additions & 2 deletions installation/src/Helper/DatabaseHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\User\UserHelper;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseFactory;
use Joomla\Database\DatabaseInterface;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Path;
Expand Down Expand Up @@ -113,7 +113,7 @@ public static function getDbo($driver, $host, $user, $password, $database, $pref
}

// Get a database object.
$db = DatabaseDriver::getInstance($options);
$db = (new DatabaseFactory())->getDriver($options['driver'], $options);
}

return $db;
Expand Down
8 changes: 4 additions & 4 deletions installation/src/Model/DatabaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Joomla\CMS\Installation\Helper\DatabaseHelper;
use Joomla\CMS\Language\LanguageHelper;
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseFactory;
use Joomla\Database\DatabaseInterface;
use Joomla\Utilities\ArrayHelper;

Expand Down Expand Up @@ -159,7 +159,7 @@ public function createDatabase(array $options)
];
}

$altDB = DatabaseDriver::getInstance($altDBoptions);
$altDB = (new DatabaseFactory())->getDriver($altDBoptions['driver'], $altDBoptions);

// Check database server parameters
$dbServerCheck = DatabaseHelper::checkDbServerParameters($altDB, $options);
Expand Down Expand Up @@ -321,8 +321,8 @@ public function createTables(string $schema, array $options)
/**
* Method to backup all tables in a database with a given prefix.
*
* @param DatabaseDriver $db DatabaseDriver object.
* @param string $prefix Database table prefix.
* @param DatabaseInterface $db Database object.
* @param string $prefix Database table prefix.
*
* @return boolean True on success.
*
Expand Down
4 changes: 2 additions & 2 deletions libraries/src/Console/SetConfigurationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Console\Command\AbstractCommand;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseFactory;
use Joomla\Registry\Registry;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Input\InputArgument;
Expand Down Expand Up @@ -363,7 +363,7 @@ public function checkDb($options): bool

// Get a database object.
try {
$db = DatabaseDriver::getInstance($settings);
$db = (new DatabaseFactory())->getDriver($settings['driver'], $settings);
$db->getVersion();
} catch (\Exception $e) {
$this->ioStyle->error(
Expand Down
3 changes: 2 additions & 1 deletion libraries/src/Log/Logger/DatabaseLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Log\LogEntry;
use Joomla\CMS\Log\Logger;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseFactory;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -171,6 +172,6 @@ protected function connect()
'prefix' => $this->prefix,
];

$this->db = DatabaseDriver::getInstance($options);
$this->db = (new DatabaseFactory())->getDriver($options['driver'], $options);
}
}
4 changes: 2 additions & 2 deletions libraries/src/Service/Provider/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace Joomla\CMS\Service\Provider;

use Joomla\Database\DatabaseDriver;
use Joomla\Database\DatabaseFactory;
use Joomla\Database\DatabaseInterface;
use Joomla\Database\Mysql\MysqlDriver;
use Joomla\DI\Container;
Expand Down Expand Up @@ -83,7 +84,6 @@ function (Container $container) {
}

$options = [
'driver' => $dbtype,
'host' => $conf->get('host'),
'user' => $conf->get('user'),
'password' => $conf->get('password'),
Expand Down Expand Up @@ -120,7 +120,7 @@ function (Container $container) {
}

try {
$db = DatabaseDriver::getInstance($options);
$db = (new DatabaseFactory())->getDriver($dbtype, $options);
} catch (\RuntimeException $e) {
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
Expand Down
54 changes: 0 additions & 54 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -790,15 +790,6 @@ parameters:
count: 2
path: administrator/components/com_config/src/Model/ApplicationModel.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class Joomla\\Database\\DatabaseDriver\:
3\.0 Use DatabaseFactory\:\:getDriver\(\) instead$#
'''
identifier: staticMethod.deprecated
count: 1
path: administrator/components/com_config/src/Model/ApplicationModel.php

-
message: '#^Instantiated class JConfig not found\.$#'
identifier: class.notFound
Expand Down Expand Up @@ -7976,15 +7967,6 @@ parameters:
count: 1
path: installation/src/Form/Field/Installation/PrefixField.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class Joomla\\Database\\DatabaseDriver\:
3\.0 Use DatabaseFactory\:\:getDriver\(\) instead$#
'''
identifier: staticMethod.deprecated
count: 1
path: installation/src/Helper/DatabaseHelper.php

-
message: '''
#^Call to deprecated method getSession\(\) of class Joomla\\CMS\\Factory\:
Expand Down Expand Up @@ -8032,15 +8014,6 @@ parameters:
count: 3
path: installation/src/Model/ConfigurationModel.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class Joomla\\Database\\DatabaseDriver\:
3\.0 Use DatabaseFactory\:\:getDriver\(\) instead$#
'''
identifier: staticMethod.deprecated
count: 1
path: installation/src/Model/DatabaseModel.php

-
message: '''
#^Call to deprecated method getLanguage\(\) of class Joomla\\CMS\\Factory\:
Expand Down Expand Up @@ -8899,15 +8872,6 @@ parameters:
count: 1
path: libraries/src/Console/RemoveUserFromGroupCommand.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class Joomla\\Database\\DatabaseDriver\:
3\.0 Use DatabaseFactory\:\:getDriver\(\) instead$#
'''
identifier: staticMethod.deprecated
count: 1
path: libraries/src/Console/SetConfigurationCommand.php

-
message: '''
#^Call to deprecated method getLanguage\(\) of class Joomla\\CMS\\Factory\:
Expand Down Expand Up @@ -12044,15 +12008,6 @@ parameters:
count: 1
path: libraries/src/Log/Logger/DatabaseLogger.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class Joomla\\Database\\DatabaseDriver\:
3\.0 Use DatabaseFactory\:\:getDriver\(\) instead$#
'''
identifier: staticMethod.deprecated
count: 1
path: libraries/src/Log/Logger/DatabaseLogger.php

-
message: '''
#^Call to deprecated method getError\(\) of class Joomla\\CMS\\MVC\\Model\\BaseModel\:
Expand Down Expand Up @@ -12938,15 +12893,6 @@ parameters:
count: 1
path: libraries/src/Service/Provider/Console.php

-
message: '''
#^Call to deprecated method getInstance\(\) of class Joomla\\Database\\DatabaseDriver\:
3\.0 Use DatabaseFactory\:\:getDriver\(\) instead$#
'''
identifier: staticMethod.deprecated
count: 1
path: libraries/src/Service/Provider/Database.php

-
message: '''
#^Call to deprecated method getUser\(\) of class Joomla\\CMS\\Factory\:
Expand Down
22 changes: 22 additions & 0 deletions tests/System/integration/cli/Config.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
describe('Test that console command config', () => {
it('can get sitename', () => {
cy.exec(`php ${Cypress.expose('cmsPath')}/cli/joomla.php config:get sitename`)
.its('stdout')
.should('contain', Cypress.expose('sitename'));
});

it('can set sitename', () => {
cy.exec(`php ${Cypress.expose('cmsPath')}/cli/joomla.php config:set sitename="${Cypress.expose('sitename')}"`)
.its('stdout')
.should('contain', '[OK] Configuration set');
});

it('can not set invalid database name', () => {
cy.exec(`php ${Cypress.expose('cmsPath')}/cli/joomla.php config:set db=invalid`, { failOnNonZeroExit: false }).then((result) => {
cy.wrap(result).its('exitCode')
.should('equal', 4);
cy.wrap(result).its('stdout')
.should('contain', '[ERROR] Cannot connect to database');
});
});
});
Loading