diff --git a/htdocs/includes/odtphp/Segment.php b/htdocs/includes/odtphp/Segment.php
index 811cf62dadd..b57983321a3 100644
--- a/htdocs/includes/odtphp/Segment.php
+++ b/htdocs/includes/odtphp/Segment.php
@@ -223,16 +223,17 @@ class Segment implements IteratorAggregate, Countable
*/
public function setVars($key, $value, $encode = true, $charset = 'ISO-8859')
{
- if (strpos($this->xml, $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT')) === false) {
+ $tag = $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT');
+
+ if (strpos($this->xml, $tag) === false) {
//throw new SegmentException("var $key not found in {$this->getName()}");
}
- $tag = $this->odf->getConfig('DELIMITER_LEFT') . $key . $this->odf->getConfig('DELIMITER_RIGHT');
-
$this->vars[$tag] = $this->odf->convertVarToOdf($value, $encode, $charset);
return $this;
}
+
/**
* Assign a template variable as a picture
*
diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php
index 80183843b36..6c63da727b7 100644
--- a/htdocs/includes/odtphp/odf.php
+++ b/htdocs/includes/odtphp/odf.php
@@ -122,7 +122,8 @@ class Odf
}
/**
- * Assing a template variable
+ * Assing a template variable into ->vars.
+ * For example, key is {object_date} and value is '2021-01-01'
*
* @param string $key Name of the variable within the template
* @param string $value Replacement value
@@ -134,6 +135,7 @@ class Odf
public function setVars($key, $value, $encode = true, $charset = 'ISO-8859')
{
$tag = $this->config['DELIMITER_LEFT'] . $key . $this->config['DELIMITER_RIGHT'];
+
// TODO Warning string may be:
// {aaa}
// instead of {aaa} so we should enhance this function.