Guaranteeing unique hash in StringStack
authorAlexander Ebert <ebert@woltlab.com>
Thu, 9 May 2013 13:28:20 +0000 (15:28 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 9 May 2013 13:28:20 +0000 (15:28 +0200)
Fixes #1260

wcfsetup/install/files/lib/util/StringStack.class.php

index cd52da0bedb4d00f3013aca7294a96134fc5e0bf..ab221ac5d29e8c8fd1923433853eceb3d96250ea 100644 (file)
@@ -5,13 +5,19 @@ namespace wcf\util;
  * Replaces quoted strings in a text.
  * 
  * @author     Marcel Werk
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @package    com.woltlab.wcf
  * @subpackage util
  * @category   Community Framework
  */
 final class StringStack {
+       /**
+        * hash index
+        * @var integer
+        */
+       protected static $i = 0;
+       
        /**
         * local string stack
         * @var array<string>
@@ -26,7 +32,7 @@ final class StringStack {
         * @return      string          $hash
         */
        public static function pushToStringStack($string, $type = 'default', $delimiter = '@@') {
-               $hash = $delimiter.StringUtil::getHash(uniqid(microtime()).$string).$delimiter;
+               $hash = $delimiter.StringUtil::getHash(self::$i++ . uniqid(microtime()) . $string).$delimiter;
                
                if (!isset(self::$stringStack[$type])) {
                        self::$stringStack[$type] = array();