Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In theory, you may not always be working with the default database. #19474

Merged
merged 1 commit into from
Mar 17, 2018
Merged
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
8 changes: 5 additions & 3 deletions administrator/components/com_banners/tables/banner.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,14 +173,16 @@ public function bind($array, $ignore = array())
*/
public function store($updateNulls = false)
{
$db = $this->getDbo();

if (empty($this->id))
{
$purchaseType = $this->purchase_type;

if ($purchaseType < 0 && $this->cid)
{
/** @var BannersTableClient $client */
$client = JTable::getInstance('Client', 'BannersTable');
$client = JTable::getInstance('Client', 'BannersTable', array('dbo' => $db));
$client->load($this->cid);
$purchaseType = $client->purchase_type;
}
Expand Down Expand Up @@ -220,7 +222,7 @@ public function store($updateNulls = false)
{
// Get the old row
/** @var BannersTableBanner $oldrow */
$oldrow = JTable::getInstance('Banner', 'BannersTable');
$oldrow = JTable::getInstance('Banner', 'BannersTable', array('dbo' => $db));

if (!$oldrow->load($this->id) && $oldrow->getError())
{
Expand All @@ -229,7 +231,7 @@ public function store($updateNulls = false)

// Verify that the alias is unique
/** @var BannersTableBanner $table */
$table = JTable::getInstance('Banner', 'BannersTable');
$table = JTable::getInstance('Banner', 'BannersTable', array('dbo' => $db));

if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_contact/tables/contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function store($updateNulls = false)
$this->webpage = JStringPunycode::urlToPunycode($this->webpage);

// Verify that the alias is unique
$table = JTable::getInstance('Contact', 'ContactTable');
$table = JTable::getInstance('Contact', 'ContactTable', array('dbo' => $this->_db));

if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_finder/tables/filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function store($updateNulls = false)
}

// Verify that the alias is unique
$table = JTable::getInstance('Filter', 'FinderTable');
$table = JTable::getInstance('Filter', 'FinderTable', array('dbo' => $this->_db));

if ($table->load(array('alias' => $this->alias)) && ($table->filter_id != $this->filter_id || $this->filter_id == 0))
{
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_newsfeeds/tables/newsfeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public function store($updateNulls = false)
}

// Verify that the alias is unique
$table = JTable::getInstance('Newsfeed', 'NewsfeedsTable');
$table = JTable::getInstance('Newsfeed', 'NewsfeedsTable', array('dbo' => $this->_db));

if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_users/tables/note.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function store($updateNulls = false)
if (!((int) $this->review_time))
{
// Null date.
$this->review_time = JFactory::getDbo()->getNullDate();
$this->review_time = $this->_db->getNullDate();
}

if (empty($this->id))
Expand Down
2 changes: 1 addition & 1 deletion libraries/src/Table/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function check()
protected function getDefaultAssetValues($component)
{
// Need to find the asset id by the name of the component.
$db = \JFactory::getDbo();
$db = $this->getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('id'))
->from($db->quoteName('#__assets'))
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Table/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ public function check()
*/
public function store($updateNulls = false)
{
$db = \JFactory::getDbo();
$db = $this->getDbo();

// Verify that the alias is unique
$table = Table::getInstance('Menu', 'JTable', array('dbo' => $this->getDbo()));
$table = Table::getInstance('Menu', 'JTable', array('dbo' => $db));

$originalAlias = trim($this->alias);
$this->alias = !$originalAlias ? $this->title : $originalAlias;
Expand Down Expand Up @@ -227,7 +227,7 @@ public function store($updateNulls = false)
// The alias already exists. Enqueue an error message.
if ($error)
{
$menuTypeTable = Table::getInstance('MenuType', 'JTable', array('dbo' => $this->getDbo()));
$menuTypeTable = Table::getInstance('MenuType', 'JTable', array('dbo' => $db));
$menuTypeTable->load(array('menutype' => $table->menutype));
$this->setError(\JText::sprintf('JLIB_DATABASE_ERROR_MENU_UNIQUE_ALIAS', $this->alias, $table->title, $menuTypeTable->title));

Expand Down