@@ -945,7 +945,7 @@ protected function createRequest($component, $destination, array $args, $mode)
945945 $ current = $ current && $ args [self ::SIGNAL_KEY ] === $ this ->getParameter (self ::SIGNAL_KEY );
946946 }
947947 if (($ mode === 'redirect ' || $ mode === 'forward ' ) && $ this ->hasFlashSession ()) {
948- $ args [self ::FLASH_KEY ] = $ this ->getParameter ( self :: FLASH_KEY );
948+ $ args [self ::FLASH_KEY ] = $ this ->getFlashKey ( );
949949 }
950950
951951 $ this ->lastCreatedRequest = new Application \Request (
@@ -1103,7 +1103,7 @@ public function restoreRequest($key)
11031103 unset($ session [$ key ]);
11041104 $ request ->setFlag (Application \Request::RESTORED , TRUE );
11051105 $ params = $ request ->getParameters ();
1106- $ params [self ::FLASH_KEY ] = $ this ->getParameter ( self :: FLASH_KEY );
1106+ $ params [self ::FLASH_KEY ] = $ this ->getFlashKey ( );
11071107 $ request ->setParameters ($ params );
11081108 $ this ->sendResponse (new Responses \ForwardResponse ($ request ));
11091109 }
@@ -1282,14 +1282,27 @@ public function popGlobalParameters($id)
12821282 /********************* flash session ****************d*g**/
12831283
12841284
1285+ /**
1286+ * @return string|NULL
1287+ */
1288+ private function getFlashKey ()
1289+ {
1290+ $ flashKey = $ this ->getParameter (self ::FLASH_KEY );
1291+ return is_string ($ flashKey ) && $ flashKey !== ''
1292+ ? $ flashKey
1293+ : NULL ;
1294+ }
1295+
1296+
12851297 /**
12861298 * Checks if a flash session namespace exists.
12871299 * @return bool
12881300 */
12891301 public function hasFlashSession ()
12901302 {
1291- return !empty ($ this ->params [self ::FLASH_KEY ])
1292- && $ this ->getSession ()->hasSection ('Nette.Application.Flash/ ' . $ this ->params [self ::FLASH_KEY ]);
1303+ $ flashKey = $ this ->getFlashKey ();
1304+ return $ flashKey !== NULL
1305+ && $ this ->getSession ()->hasSection ('Nette.Application.Flash/ ' . $ flashKey );
12931306 }
12941307
12951308
@@ -1299,10 +1312,11 @@ public function hasFlashSession()
12991312 */
13001313 public function getFlashSession ()
13011314 {
1302- if (empty ($ this ->params [self ::FLASH_KEY ])) {
1303- $ this ->params [self ::FLASH_KEY ] = Nette \Utils \Random::generate (4 );
1315+ $ flashKey = $ this ->getFlashKey ();
1316+ if ($ flashKey === NULL ) {
1317+ $ this ->params [self ::FLASH_KEY ] = $ flashKey = Nette \Utils \Random::generate (4 );
13041318 }
1305- return $ this ->getSession ('Nette.Application.Flash/ ' . $ this -> params [ self :: FLASH_KEY ] );
1319+ return $ this ->getSession ('Nette.Application.Flash/ ' . $ flashKey );
13061320 }
13071321
13081322
0 commit comments