From d486dafb81822d2acba380da405f022d3d858cc3 Mon Sep 17 00:00:00 2001
From: Benoit Mortier <benoit.mortier@opensides.be>
Date: Fri, 8 Jun 2012 18:04:17 +0200
Subject: [PATCH] Fixes: #1011 smarty3 with gettext generate funky errors :/

---
 contrib/smarty/plugins/block.t.php | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/contrib/smarty/plugins/block.t.php b/contrib/smarty/plugins/block.t.php
index ca7382aeb..39ad2ebaf 100644
--- a/contrib/smarty/plugins/block.t.php
+++ b/contrib/smarty/plugins/block.t.php
@@ -26,7 +26,7 @@
  * @author	Sagi Bashari <sagi@boom.org.il>
  * @copyright 2004-2005 Sagi Bashari
  */
- 
+
 /**
  * Replaces arguments in a string with their values.
  * Arguments are represented by % followed by their number.
@@ -42,7 +42,7 @@ function smarty_gettext_strarg($str)
 
 	for ($i=1; $i < func_num_args(); $i++) {
 		$arg = func_get_arg($i);
-		
+
 		if (is_array($arg)) {
 			foreach ($arg as $aarg) {
 				$tr['%'.++$p] = $aarg;
@@ -51,7 +51,7 @@ function smarty_gettext_strarg($str)
 			$tr['%'.++$p] = $arg;
 		}
 	}
-	
+
 	return strtr($str, $tr);
 }
 
@@ -60,7 +60,7 @@ function smarty_gettext_strarg($str)
  *
  * The block content is the text that should be translated.
  *
- * Any parameter that is sent to the function will be represented as %n in the translation text, 
+ * Any parameter that is sent to the function will be represented as %n in the translation text,
  * where n is 1 for the first parameter. The following parameters are reserved:
  *   - escape - sets escape mode:
  *       - 'html' for HTML escaping, this is the default.
@@ -72,26 +72,29 @@ function smarty_gettext_strarg($str)
  */
 function smarty_block_t($params, $text, &$smarty)
 {
+  if($text === NULL) {
+    return;
+  }
 	$text = stripslashes($text);
-	
+
 	// set escape mode
 	if (isset($params['escape'])) {
 		$escape = $params['escape'];
 		unset($params['escape']);
 	}
-	
+
 	// set plural version
 	if (isset($params['plural'])) {
 		$plural = $params['plural'];
 		unset($params['plural']);
-		
+
 		// set count
 		if (isset($params['count'])) {
 			$count = $params['count'];
 			unset($params['count']);
 		}
 	}
-	
+
 	// use plural if required parameters are set
 	if (isset($count) && isset($plural)) {
 		$text = ngettext($text, $plural, $count);
@@ -119,7 +122,7 @@ function smarty_block_t($params, $text, &$smarty)
 				break;
 		}
 	}
-	
+
 	return $text;
 }
 
-- 
GitLab