-
-
Save dannevang/eab27a6c44846a4650be to your computer and use it in GitHub Desktop.
Performance improvement for Magento Patch SUPEE-6788
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: app/code/core/Mage/Admin/Model/Variable.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- app/code/core/Mage/Admin/Model/Variable.php (revision 2bd128c1f190cd9ea63269824f09789199565251) | |
+++ app/code/core/Mage/Admin/Model/Variable.php (revision ) | |
@@ -30,6 +30,13 @@ | |
class Mage_Admin_Model_Variable extends Mage_Core_Model_Abstract | |
{ | |
/** | |
+ * List of loaded variables | |
+ * | |
+ * @var array | |
+ */ | |
+ static protected $_variables = array(); | |
+ | |
+ /** | |
* Initialize variable model | |
*/ | |
protected function _construct() | |
@@ -71,10 +78,12 @@ | |
*/ | |
public function isPathAllowed($path) | |
{ | |
- /** @var Mage_Admin_Model_Resource_Variable_Collection $collection */ | |
- $collection = Mage::getResourceModel('admin/variable_collection'); | |
- $collection->addFieldToFilter('variable_name', array('eq' => $path)) | |
- ->addFieldToFilter('is_allowed', array('eq' => 1)); | |
- return $collection->load()->count(); | |
+ if (array_key_exists($path, self::$_variables)) { | |
+ return self::$_variables[$path]; | |
+ } | |
+ $result = $this->_getResource()->isPathAllowed($path); | |
+ self::$_variables[$path] = $result; | |
+ | |
+ return $result; | |
} | |
} | |
Index: app/code/core/Mage/Admin/Model/Resource/Variable.php | |
IDEA additional info: | |
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP | |
<+>UTF-8 | |
=================================================================== | |
--- app/code/core/Mage/Admin/Model/Resource/Variable.php (revision 2bd128c1f190cd9ea63269824f09789199565251) | |
+++ app/code/core/Mage/Admin/Model/Resource/Variable.php (revision ) | |
@@ -40,4 +40,24 @@ | |
{ | |
$this->_init('admin/permission_variable', 'variable_id'); | |
} | |
+ | |
+ /** | |
+ * Check is config directive with given path can be parsed via configDirective method | |
+ * | |
+ * @param string $path | |
+ * @return int | |
+ */ | |
+ public function isPathAllowed($path) | |
+ { | |
+ $adapter = $this->_getReadAdapter(); | |
+ $select = $adapter->select() | |
+ ->from($this->getMainTable(), 'COUNT(1)') | |
+ ->where('variable_name = :variable') | |
+ ->where('is_allowed = 1'); | |
+ $bind = array( | |
+ ':variable' => $path, | |
+ ); | |
+ | |
+ return $adapter->fetchOne($select, $bind); | |
+ } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment