3

I have strange problem.

Line 61: $this->_currentRoute = Default_Model_Routes::getInstance()->getCurrentRoute();
.......... other code ..........
Line 86: var_dump(isset($this->_currentRoute['url']));
Line 87: var_dump($this->_currentRoute['url']);
Line 88: if ($this->_currentRoute['url'] == $currentUrl)
Line 89:     $navigation[$key]['active'] = true;
Line 90: var_dump($this->_currentRoute);

This is result:

bool(true)
string(62) "cs/Polozka-menu-1/Polozka-menu-1-1/Polozka-menu-1-1-1/Clanek-1"
array(17) {
  ["url"]=>
  string(62) "cs/Polozka-menu-1/Polozka-menu-1-1/Polozka-menu-1-1-1/Clanek-1"
  ["type"]=>
  string(7) "article"
  ............
}

And in the error log:

[09-Mar-2011 19:49:32] PHP Notice:  Undefined index: url in ...file... on line 87
[09-Mar-2011 19:49:32] PHP Notice:  Undefined index: url in ...file... on line 88

Please, if you have any ideas where could be problem or how to fix, tell me. Thank you :)

I have tried another test:

$test = array();
echo $test['lol'];

With this result:

Notice: Undefined index: lol in ...file... on line 92

Somethink really interesting: THIS 'lol' error is displayed in output, BUT the 'url' error IS NOT ! It is only in the log ... why ????? It's same file, line under the 'url' var_dump() ... crazy

Charles
  • 50,943
  • 13
  • 104
  • 142
grongor
  • 1,305
  • 1
  • 13
  • 26

2 Answers2

2

What happens if you assign $this->_currentRoute to a variable first?

$route = $this->_currentRoute;
var_dump(array_key_exists('url', $route));
var_dump(isset($route['url']));
print "PRINTING: ".$route['url'];
die("ENDING ON LINE [".__LINE__."] !!!");

Solved (see comments)

This was unfortunately an issue with Zend Server, or bleeding edge PHP 5.3.3.

Ben DeMott
  • 3,362
  • 1
  • 25
  • 35
  • bool(true), bool(true), cs/Polozka-menu-1/Polozka-menu-1-1/Polozka-menu-1-1-1/Clanek-1 AND exact error saying that index is undefined – grongor Mar 09 '11 at 19:14
  • You are saying it prints out cs/Polozka-men... (which is the url)??? I think your problem may be related to something else, I edited my post - change your code to follow and see what happens. – Ben DeMott Mar 09 '11 at 19:22
  • Yes, it print's everything correctly. I don't think that problem is related to code - it is perfect and simple ... but, where is the problem then ? ... – grongor Mar 09 '11 at 19:24
  • Here is result: bool(true), bool(true), PRINTING: cs/Polozka-menu-1/Polozka-menu-1-1/Polozka-menu-1-1-1/Clanek-1, ENDING ON LINE [90] !!! – grongor Mar 09 '11 at 19:30
  • No error then? - this means the index error is happening somewhere else, or you have a PHP module/shared object or distribution of PHP that is unstable. – Ben DeMott Mar 09 '11 at 19:37
  • nope ... [09-Mar-2011 20:39:15] PHP Notice: Undefined index: url in ...file... on line 89 – grongor Mar 09 '11 at 19:39
  • @GRoNGoR Does it say "...file..." or is it in the exact same file. How are you running it? mod_php, cgi, command line? what version of php? What happens if you enable inline error reporting - to show errors for everything? – Ben DeMott Mar 09 '11 at 19:42
  • ...wow, now I found really fascinating ... if I do $test = array(); echo $test['lol']; ... it will throw undefined index too - BUT in code :) so I have display_errors enable ... I am running it locale - Zend Community Server, PHP version 5.3.3 – grongor Mar 09 '11 at 19:50
  • To be honest with you, we ran Zend Server with PHP 5.3.x - I would say stay away, its a buggy pile. Stick with the mainstream open-source and if you want opcode caching use APC. Try running from the command-line see if it does the same thing (its a separate executable) – Ben DeMott Mar 09 '11 at 19:56
  • ... I don't use it in production - there I use simple Apache && PHP instalation :) ... this is just for "homecooking" - suited with Zend Studio ... I will try cli and post a result – grongor Mar 09 '11 at 20:04
  • I tried php-cli and the error doesn't shows in log ... Sooo most probably it's the Zend's fail ... – grongor Mar 09 '11 at 20:23
  • Open Source wins again! (hehehe) glad you figured out the issue, now hopefully you don't ever get a WSOD (white screen of death). PS if you are a developer doing your own work, try out Python some time - I made the switch for web development two years ago, couldn't be happier. – Ben DeMott Mar 09 '11 at 20:25
  • Thank you for suggestion, but I think that PHP is simply "more supported" ... but I want to learn Java soon :) Thank you for help - I thought that it will be bug in something most probably :) – grongor Mar 09 '11 at 20:28
0

Maybe this is not you errors?
Try to ini_set('display_errors', 1);

And also see method Default_Model_Routes::getInstance()->getCurrentRoute()::__get()

Read this

azat
  • 3,545
  • 1
  • 28
  • 30
  • yes, the really are ... I don't really understand what do you mean by that method ... getCurrentRoute() return simple array - and the index is defined as you can see in my var_dump() ... by the way, if I do var_dump() on 'caption' or 'content' index, it retrieves it correctly too, but alse throws same error ... – grongor Mar 09 '11 at 19:10
  • Try this $this->_currentRoute['url'] = 'test'; var_dump($this->_currentRoute['url']); – azat Mar 09 '11 at 19:55
  • ... this doesn't throw error ... but it doesn't help me neither :D ... it's not problem in 'url' index by the way, problem is within ALL indexies in this array ... they shows, works and exist - but throws error ... *lol* – grongor Mar 09 '11 at 19:59