Fixed bug #8566: Unable to match TS condition when variable is not set
authorDmitry Dulepov <dmitry.dulepov@gmail.com>
Wed, 16 Jul 2008 09:02:25 +0000 (09:02 +0000)
committerDmitry Dulepov <dmitry.dulepov@gmail.com>
Wed, 16 Jul 2008 09:02:25 +0000 (09:02 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3893 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
t3lib/class.t3lib_matchcondition.php

index 1c3c179..897eb97 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2008-07-14  Dmitry Dulepov  <dmitry@typo3.org>
+
+       * Fixed bug #8566: Unable to match TS condition when variable is not set
 
 2008-07-14  Martin Kutschker  <masi@typo3.org>
 
index 499e375..91bcc77 100644 (file)
@@ -411,20 +411,24 @@ class t3lib_matchCondition {
         * @param       string          The string to find in $haystack
         * @return      boolean         Returns true if $needle matches or is found in (according to wildcards) in $haystack. Eg. if $haystack is "Netscape 6.5" and $needle is "Net*" or "Net*ape" then it returns true.
         */
-       function matchWild($haystack,$needle)   {
-               if ($needle && $haystack)       {
-                       if (preg_match('/^\/.+\/$/', $needle))  {       // Regular expression, only "//" is allowed as delimiter
+       function matchWild($haystack, $needle) {
+               $result = false;
+
+               if ($needle) {
+                       if (preg_match('/^\/.+\/$/', $needle)) {
+                               // Regular expression, only "//" is allowed as delimiter
                                $regex = $needle;
                        } else {
-                               $needle = str_replace(array('*','?'), array('###MANY###','###ONE###'), $needle);
-                               $regex = '/^'.preg_quote($needle,'/').'$/';
-                               $regex = str_replace(array('###MANY###','###ONE###'), array('.*','.'), $regex); // Replace the marker with .* to match anything (wildcard)
+                               $needle = str_replace(array('*', '?'), array('###MANY###', '###ONE###'), $needle);
+                               $regex = '/^' . preg_quote($needle, '/') . '$/';
+                               // Replace the marker with .* to match anything (wildcard)
+                               $regex = str_replace(array('###MANY###', '###ONE###'), array('.*' , '.'), $regex);
                        }
 
-                       if (preg_match($regex, $haystack)) return true;
+                       $result = (boolean)preg_match($regex, (string)$haystack);
                }
 
-               return false;
+               return $result;
        }
 
        /**