Confirmed Notices admin page becomes inaccessible due to an out-of-memory error on large installations

Painbaker

Well-known member
Licensed customer
Affected version
2.3.13
NoticeRepository::getTemplatesForCriteriaCheck() loads all public master templates as full entities, including their content, just to check template names
Notices admin page becomes completely inaccessible with an Allowed memory size of X bytes exhausted fatal error


Suggested fix: Fetch only template titles only when a notice has a template page criteria

PHP:
protected function isPageCriteriaValid(array $criteria)
    {
        //$templatesCache = $this->getTemplatesForCriteriaCheck();

        foreach ($criteria AS $criterion)
        {
            switch ($criterion['rule'])
            {
                case 'template':
                   
                if (isset($criterion['data']['name']))
                    {
                        return in_array($criterion['data']['name'], $this->getTemplatesForCriteriaCheck());
                    }
                    break;

                    break;

PHP:
protected function getTemplatesForCriteriaCheck()
{
    if ($this->templatesCache === null)
    {
        $this->templatesCache = $this->db()->fetchAllColumn('
            SELECT title
            FROM xf_template
            WHERE type = ? AND style_id = ?
        ', ['public', 0]);
    }

    return $this->templatesCache;
}
 
Last edited:
Back
Top Bottom