thedude
Well-known member
library/XenGallery/Listener.php
1.03 & 1.04
$_permissionCache (line 9) appears to have been intended to cache XFMG permission values because templateCreate gets called several times during any particular XF page load. However the caching part may have fallen by the wayside if you examine XenGallery_Listener::templateCreate (line 16).
I've hacked Listener.php to implement the caching so XFMG permissions aren't re-checked for each templateCreate call.
My altered version of Listener.php, based on 1.04, is attached and here's a explanation of my changes...
I've added the following variable to cache the array that gets added onto $params in templateCreate
In templateCreate, I check if $_templateParamCache has been set yet
In templateCreate, the second foreach loop is replaced by
After the closing brace for the initial $_templateParamCache check, there's
The array addition above respects existing keys and won't overwrite them.
1.03 & 1.04
$_permissionCache (line 9) appears to have been intended to cache XFMG permission values because templateCreate gets called several times during any particular XF page load. However the caching part may have fallen by the wayside if you examine XenGallery_Listener::templateCreate (line 16).
I've hacked Listener.php to implement the caching so XFMG permissions aren't re-checked for each templateCreate call.
My altered version of Listener.php, based on 1.04, is attached and here's a explanation of my changes...
I've added the following variable to cache the array that gets added onto $params in templateCreate
Code:
protected static $_templateParamCache = array();
In templateCreate, I check if $_templateParamCache has been set yet
Code:
if (empty(self::$_templateParamCache))
{
In templateCreate, the second foreach loop is replaced by
Code:
foreach ($preparedPermissions AS $permission)
{
self::$_templateParamCache[$permission['id']] = $permission['value'];
}
After the closing brace for the initial $_templateParamCache check, there's
Code:
$params += self::$_templateParamCache;