Skip to content

Commit

Permalink
[4.0] [com_config] convert to prepared statement (#25193)
Browse files Browse the repository at this point in the history
  • Loading branch information
alikon authored and wilsonge committed Jul 23, 2019
1 parent 9fbc0e5 commit 65e3d40
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions administrator/components/com_config/Model/ApplicationModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserHelper;
use Joomla\Database\DatabaseDriver;
use Joomla\Database\ParameterType;
use Joomla\Registry\Registry;
use Joomla\Utilities\ArrayHelper;

Expand Down Expand Up @@ -829,10 +830,11 @@ public function storePermissions($permission = null)
try
{
// Get the asset id by the name of the component.
$query = $this->getDbo()->getQuery(true)
->select($this->getDbo()->quoteName('id'))
->from($this->getDbo()->quoteName('#__assets'))
->where($this->getDbo()->quoteName('name') . ' = ' . $this->getDbo()->quote($permission['component']));
$query = $this->_db->getQuery(true)
->select($this->_db->quoteName('id'))
->from($this->_db->quoteName('#__assets'))
->where($this->_db->quoteName('name') . ' = :component')
->bind(':component', $permission['component']);

$this->_db->setQuery($query);

Expand All @@ -855,18 +857,21 @@ public function storePermissions($permission = null)
$query->clear()
->select($this->_db->quoteName('parent_id'))
->from($this->_db->quoteName('#__assets'))
->where($this->_db->quoteName('id') . ' = ' . $assetId);
->where($this->_db->quoteName('id') . ' = :assetid')
->bind(':assetid', $assetId, ParameterType::INTEGER);

$this->_db->setQuery($query);

$parentAssetId = (int) $this->_db->loadResult();
}

// Get the group parent id of the current group.
$rule = (int) $permission['rule'];
$query->clear()
->select($this->_db->quoteName('parent_id'))
->from($this->_db->quoteName('#__usergroups'))
->where($this->_db->quoteName('id') . ' = ' . (int) $permission['rule']);
->where($this->_db->quoteName('id') . ' = :rule')
->bind(':rule', $rule, ParameterType::INTEGER);

$this->_db->setQuery($query);

Expand All @@ -876,7 +881,8 @@ public function storePermissions($permission = null)
$query->clear()
->select('COUNT(' . $this->_db->quoteName('id') . ')')
->from($this->_db->quoteName('#__usergroups'))
->where($this->_db->quoteName('parent_id') . ' = ' . (int) $permission['rule']);
->where($this->_db->quoteName('parent_id') . ' = :rule')
->bind(':rule', $rule, ParameterType::INTEGER);

$this->_db->setQuery($query);

Expand Down

0 comments on commit 65e3d40

Please sign in to comment.