Loading...
 
Skip to main content

Out of memory bug in tiki-edit_templates.php

Status
Open
Subject
Out of memory bug in tiki-edit_templates.php
Version
5.x
Category
  • Error
  • Patch
Feature
Templates (Smarty)
Resolution status
New
Submitted by
WollUser
Lastmod by
WollUser
Rating
(0)
Description

Hi,

I've just been testing Tiki to see if it will suit my needs. Came across the following bug in tiki-edit_templates.php whenever I tried to edit any templates or CCS.

Whenever I tried to click on the Edit Button for templates I got the following error:

PHP Fatal error: Allowed memory size of XXX bytes exhausted (tried to allocate XX bytes) in tiki-5.1/lib/init/initlib.php on line 185

System setup

System: FreeBSD 8.1
Web Server: Apache 2.2.16
Php: 5.3.3

Key issue was when looking for templates to list - around line 112 in tiki-edit_templates.php. The code would get stuck in an endless loop trying to get the files a directory that failed to open, exhausting stack size. The following directories would attempt to be opened:

tiki-5.1/templates - opened OK
tiki-5.1/templatesmodules - failed to open causing loop to get stuck.

The templatesmodules directory would fail to open.

Solution

Key fix is to encase the opendir when listing templates in an if statement. I found that for some reason on FreeBSD if a directory failed to open the readdir loop ran infinitely.

diff on tiki-edit_templates.php

Patch
Copy to clipboard
112,115c112,116 < $h = opendir($smarty->template_dir.$w); < while (($file = readdir($h)) !== false) { < if (substr($file,-4,4) == '.tpl' && ($w != $local || !in_array($file, $files))) { < $files[] = $w.$file; --- > if( $h = opendir($smarty->template_dir.$w) ) { > while (($file = readdir($h)) !== false) { > if (substr($file,-4,4) == '.tpl' && ($w != $local || !in_array($file, $files))) { > $files[] = $w.$file; > } 116a118 > closedir ($h); 118d119 < closedir ($h);
Importance
9 high
Priority
45
Demonstrate Bug on Tiki 19+
Demonstrate Bug (older Tiki versions)
Ticket ID
3527
Created
Friday 27 August, 2010 12:49:13 UTC
by WollUser
LastModif
Friday 27 August, 2010 12:49:13 UTC


Show PHP error messages