Skip to content

Commit 67d99a7

Browse files
author
Marius Burkard
committed
- fixed empty template error
1 parent 2e999fa commit 67d99a7

File tree

3 files changed

+19
-21
lines changed

3 files changed

+19
-21
lines changed

interface/lib/classes/tpl.inc.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,12 @@ private function _getData ($tmplfile, $do_eval=false, $tmpl_from_string = false)
858858

859859

860860
if($this->_cache && $this->_checkCache($tmplfile, $tmpl_from_string)) { //* cache exists so lets use it
861-
$data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile));
862-
fclose($fp);
861+
$data = file_get_contents($this->_cachefile);
863862
} else { //* no cache lets parse the file
864863
if($tmpl_from_string == true) {
865864
$data = $tmplfile;
866865
} else {
867-
$data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile));
868-
fclose($fp);
866+
$data = file_get_contents($tmplfile);
869867
}
870868

871869
$regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*';

server/lib/classes/tpl.inc.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,12 @@ private function _getData ($tmplfile, $do_eval=false, $tmpl_from_string = false)
858858

859859

860860
if($this->_cache && $this->_checkCache($tmplfile, $tmpl_from_string)) { //* cache exists so lets use it
861-
$data = fread($fp = fopen($this->_cachefile, 'r'), filesize($this->_cachefile));
862-
fclose($fp);
861+
$data = file_get_contents($this->_cachefile);
863862
} else { //* no cache lets parse the file
864863
if($tmpl_from_string == true) {
865864
$data = $tmplfile;
866865
} else {
867-
$data = fread($fp = fopen($tmplfile, 'r'), filesize($tmplfile));
868-
fclose($fp);
866+
$data = file_get_contents($tmplfile);
869867
}
870868

871869
$regex = '/(<|<\/|{|{\/|<!--|<!--\/){1}\s*';

server/plugins-available/nginx_plugin.inc.php

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,19 +1155,21 @@ function update($event_name, $data) {
11551155
}
11561156

11571157
// use vLib for template logic
1158-
$nginx_directives_new = '';
1159-
$ngx_conf_tpl = new tpl();
1160-
$ngx_conf_tpl_tmp_file = tempnam($conf['temppath'], "ngx");
1161-
file_put_contents($ngx_conf_tpl_tmp_file, $nginx_directives);
1162-
$ngx_conf_tpl->newTemplate($ngx_conf_tpl_tmp_file);
1163-
$ngx_conf_tpl->setVar('use_tcp', $use_tcp);
1164-
$ngx_conf_tpl->setVar('use_socket', $use_socket);
1165-
$ngx_conf_tpl->setVar('fpm_socket', $fpm_socket);
1166-
$ngx_conf_tpl->setVar($vhost_data);
1167-
$nginx_directives_new = $ngx_conf_tpl->grab();
1168-
if(is_file($ngx_conf_tpl_tmp_file)) unlink($ngx_conf_tpl_tmp_file);
1169-
if($nginx_directives_new != '') $nginx_directives = $nginx_directives_new;
1170-
unset($nginx_directives_new);
1158+
if(trim($nginx_directives) != '') {
1159+
$nginx_directives_new = '';
1160+
$ngx_conf_tpl = new tpl();
1161+
$ngx_conf_tpl_tmp_file = tempnam($conf['temppath'], "ngx");
1162+
file_put_contents($ngx_conf_tpl_tmp_file, $nginx_directives);
1163+
$ngx_conf_tpl->newTemplate($ngx_conf_tpl_tmp_file);
1164+
$ngx_conf_tpl->setVar('use_tcp', $use_tcp);
1165+
$ngx_conf_tpl->setVar('use_socket', $use_socket);
1166+
$ngx_conf_tpl->setVar('fpm_socket', $fpm_socket);
1167+
$ngx_conf_tpl->setVar($vhost_data);
1168+
$nginx_directives_new = $ngx_conf_tpl->grab();
1169+
if(is_file($ngx_conf_tpl_tmp_file)) unlink($ngx_conf_tpl_tmp_file);
1170+
if($nginx_directives_new != '') $nginx_directives = $nginx_directives_new;
1171+
unset($nginx_directives_new);
1172+
}
11711173

11721174
// Make sure we only have Unix linebreaks
11731175
$nginx_directives = str_replace("\r\n", "\n", $nginx_directives);

0 commit comments

Comments
 (0)