Jump to content
  • 0

Flux PHP Error


Mystery

Question


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

I seem to be getting an error.. my error log is spitting out this problem:

PHP Notice: Undefined offset: 1 in /...lib/Flux/Template.php on line 287 and when I go to there, this is the code:

list ($key,$val) = explode('=', $line, 2);

The whole code area around this line is:

else {
foreach (explode('&', trim($_SERVER['QUERY_STRING'], '&')) as $line) {
list ($key,$val) = explode('=', $line, 2);
$key = urldecode($key);
$val = urldecode($val);

if ($key != 'module' && $key != 'action') {
$this->urlWithQS .= sprintf('&%s=%s', urlencode($key), urlencode($val));

anyone know how to fix this? o_O

Link to comment
Share on other sites

6 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

Well, this is a poor source.

Look, it's probably the data that wasn't properly handled till this step, so there's no "=" character to explode.

else {
$ArrRandomName = explode('&', trim($_SERVER['QUERY_STRING'], '&')) ;
foreach ($ArrRandomName as $line) {
$ToExplode = explode('=', $line, 2);
$key = isset($ToExplode[0]) ? $ToExplode[0] : null;
$val = isset($ToExplode[1]) ? $ToExplode[1] : null;
$key = urldecode($key);
$val = urldecode($val);
if ($key != 'module' && $key != 'action') {
$this->urlWithQS .= sprintf('&%s=%s', urlencode($key), urlencode($val));

If your code is making all operations correctly and you just want a fix to the notice so you're done.

I just put a improve to performance also. ;D

If "$_SERVER['QUERY_STRING']" is just beeing used in another place, so it could cause a problem at the improved foreach, just turn it back to this ugly one:

else {
foreach (explode('&', trim($_SERVER['QUERY_STRING'], '&')) as $line) {
$ToExplode = explode('=', $line, 2);
$key = isset($ToExplode[0]) ? $ToExplode[0] : null;
$val = isset($ToExplode[1]) ? $ToExplode[1] : null;
$key = urldecode($key);
$val = urldecode($val);
if ($key != 'module' && $key != 'action') {
$this->urlWithQS .= sprintf('&%s=%s', urlencode($key), urlencode($val));

Edited by MarkZD
  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

I got it from the 1.0 Flux version from the SVN listed on rAthena o_o. Thanks! I'll test it this code and see what else I get :>

Edited by Mysterious
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

Sure, I looked into its source now.

You can use the first code block I posted above.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Sure, I looked into its source now.

You can use the first code block I posted above.

Hm, no errors yet. Btw, how exactly does the code improve performance?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

Each time foreach is done explode and trim function were beeing not needed called so they loaded all the time, I just put those values by one call in a variable and it's done.

But the fix is below, where there was a problem at "=" inside explode, beeing passed to list function, as there wasn't more than one value, second variable was beeing forced to get null but php wasn't told to do that, so it throwed a warning message.

I just clarified to php those values could be null, making him check them in a correct way.

Edited by MarkZD
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  94
  • Topics Per Day:  0.02
  • Content Count:  2192
  • Reputation:   252
  • Joined:  11/11/11
  • Last Seen:  

Ah, I get it now. Alright, thanks ;3! Glad there's someone like you on rAthena to help!

Edited by Mysterious
Link to comment
Share on other sites

×
×
  • Create New...