News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Error in Subs.php, line 714

Started by GigaWatt, January 28, 2021, 07:59:14 PM

Previous topic - Next topic

GigaWatt

Shadav's post reminded me of this error I've been having for a while now... about a year I think. Happens when you've selected to view a certain board, so... I have to clean up the error log every week or so :P :D.

Started happening right after the 2.0.17 upgrade... or the 2.0.16 one... can't remember. Anyhow, the forum was running 2.0.15, then upgraded to 2.0.16, after that to 2.0.17.

http://blahblah.mk/index.php?board=51.0
8: Undefined variable: pageindex
File: /blah/blah/blah/Sources/Subs.php
Line: 714

702: // Show the pages before the current one. (1 ... >6 7< [8] 9 10 ... 15)
703: for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
704: if ($start >= $num_per_page * $nCont)
705: {
706: $tmpStart = $start - $num_per_page * $nCont;
707: $pageindex.= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
708: }
709:
710: // Show the current page. (1 ... 6 7 >[8]< 9 10 ... 15)
711: if (!$start_invalid)
712: $pageindex .= '[<strong>' . ($start / $num_per_page + 1) . '</strong>] ';
713: else
==>714: $pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);
715:
716: // Show the pages after the current one... (1 ... 6 7 [8] >9 10< ... 15)
717: $tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
718: for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
719: if ($start + $num_per_page * $nCont <= $tmpMaxPages)
720: {
721: $tmpStart = $start + $num_per_page * $nCont;
722: $pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
723: }
724:
725: // Show the '...' part near the end. (1 ... 6 7 [8] 9 10 >...< 15)
726: if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
727: $pageindex .= '<span style="font-weight: bold;" onclick="expandPages(this, \'' . ($flexible_start ? strtr($base_url, array('\'' => '\\\'')) : strtr($base_url, array('%' => '%%', '\'' => '\\\'')) . ';start=%1$d') . '\', ' . ($start + $num_per_page * ($PageContiguous + 1)) . ', ' . $tmpMaxPages . ', ' . $num_per_page . ');" onmouseover="this.style.cursor=\'pointer\';"> ... </span>';


Installed mods:

1.  Recount Member Posts 1.1                                   [ Uninstall ]   [ List Files ]   [ Delete ]
2.  Allow Access while in Maintenance Mode 1.2                 [ Uninstall ]   [ List Files ]   [ Delete ]
3.  Contact Page 4.5                                           [ Uninstall ]   [ List Files ]   [ Delete ]
4.  Recent Forum Topics Boardindex 1.0                         [ Uninstall ]   [ List Files ]   [ Delete ]
5.  Moderator and Administrator Comment Tags 1.9               [ Uninstall ]   [ List Files ]   [ Delete ]
6.  SMF 2.0.17 Update 1.0                                      [ Uninstall ]   [ List Files ]   [ Delete ]
7.  MPAAP - Modify Posts At Anytime Permission 1.0.1           [ Uninstall ]   [ List Files ]   [ Delete ]
8.  List Of Users In Forum/Board/Topic 3.0                     [ Uninstall ]   [ List Files ]   [ Delete ]
9.  Annoy User 1.2.4                                           [ Uninstall ]   [ List Files ]   [ Delete ]
10. Previous and Next Links for Page Index 2.1.204             [ Uninstall ]   [ List Files ]   [ Delete ]
11. SMF 2.0.16 Update 1.0                                                      [ List Files ]   [ Delete ]
12. Slash through Banned Usernames 4.0                         [ Uninstall ]   [ List Files ]   [ Delete ]
13. No Download Attachment 1.0                                 [ Uninstall ]   [ List Files ]   [ Delete ]
14. ETNTPT - Edited Time Next To Posted Time 1.0.0             [ Uninstall ]   [ List Files ]   [ Delete ]
15. Better Messages Menu 1.7                                   [ Install Mod ] [ List Files ]   [ Delete ]
16. Hide ip stuff for users 1.05                               [ Uninstall ]   [ List Files ]   [ Delete ]
17. Favicon 1.3                                                [ Uninstall ]   [ List Files ]   [ Delete ]
18. Avatars on Board/MessageIndex 2.0                          [ Uninstall ]   [ List Files ]   [ Delete ]
19. Yet Another YouTube BBCode Tag 4.9                         [ Uninstall ]   [ List Files ]   [ Delete ]
20. Search Sent PMs 2.7                                        [ Uninstall ]   [ List Files ]   [ Delete ]
21. April Fools 1.0.5                                          [ Uninstall ]   [ List Files ]   [ Delete ]
22. SimpleColorizer 1.1                                        [ Install Mod ] [ List Files ]   [ Delete ]
23. Change All Subjects 1.3                                    [ Uninstall ]   [ List Files ]   [ Delete ]
24. PM Quick Reply 1.9                                         [ Uninstall ]   [ List Files ]   [ Delete ]


It's probably a mod I've got installed... or uninstalled and left something :P :D.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

The 20 lines before that are important for this issue...

You should see a section for '// Show the first page' logic, where pageindex is initially set...  That must have been broken somehow...

Compare that whole section to the vanilla file & make sure pageindex is getting set.
A question worth asking is born in experience & driven by necessity. - Fripp

Shambles

Quote10. Previous and Next Links for Page Index 2.1.204

Probably that one. The parser for that mod shows it removing vital code, as shawnb61 has hinted at.

Code (what the mod is removing) Select
// Show the first page. (>1< ... 6 7 [8] 9 10 ... 15)
if ($start > $num_per_page * $PageContiguous)
$pageindex = sprintf($base_link, 0, '1');
else
$pageindex = '';


Inserting a definer line should cure it.

Code (find) Select

// Show the current page. (1 ... 6 7 >[8]< 9 10 ... 15)


Code (add after) Select

$pageindex = '';

GigaWatt

Quote from: shawnb61 on January 28, 2021, 09:04:56 PM
The 20 lines before that are important for this issue...

You should see a section for '// Show the first page' logic, where pageindex is initially set...  That must have been broken somehow...

Done ;).

// "Prev"
if ( !$start_invalid )
{
$tmpStart = $start - $num_per_page;

if ( $start / $num_per_page + 1 > 1 )
{
$pageindex = sprintf($base_link, $tmpStart, $txt['prev page']);

$start > $num_per_page * $PageContiguous and $pageindex .= sprintf($base_link, 0, '1');
}

else
{
$pageindex = $start > $num_per_page * $PageContiguous ? sprintf($base_link, 0, '1') : '';
}
}

// Show the ... after the first page.  (1 >...< 6 7 [8] 9 10 ... 15)
if ($start > $num_per_page * ($PageContiguous + 1))
$pageindex .= '<span style="font-weight: bold;" onclick="' . htmlspecialchars('expandPages(this, ' . JavaScriptEscape(($flexible_start ? $base_url : strtr($base_url, array('%' => '%%')) . ';start=%1$d')) . ', ' . $num_per_page . ', ' . ($start - $num_per_page * $PageContiguous) . ', ' . $num_per_page . ');') . '" onmouseover="this.style.cursor = \'pointer\';"> ... </span>';

// Show the pages before the current one. (1 ... >6 7< [8] 9 10 ... 15)
for ($nCont = $PageContiguous; $nCont >= 1; $nCont--)
if ($start >= $num_per_page * $nCont)
{
$tmpStart = $start - $num_per_page * $nCont;
$pageindex.= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
}

// Show the current page. (1 ... 6 7 >[8]< 9 10 ... 15)
if (!$start_invalid)
$pageindex .= '[<strong>' . ($start / $num_per_page + 1) . '</strong>] ';
else
$pageindex .= sprintf($base_link, $start, $start / $num_per_page + 1);

// Show the pages after the current one... (1 ... 6 7 [8] >9 10< ... 15)
$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;
for ($nCont = 1; $nCont <= $PageContiguous; $nCont++)
if ($start + $num_per_page * $nCont <= $tmpMaxPages)
{
$tmpStart = $start + $num_per_page * $nCont;
$pageindex .= sprintf($base_link, $tmpStart, $tmpStart / $num_per_page + 1);
}

// Show the '...' part near the end. (1 ... 6 7 [8] 9 10 >...< 15)
if ($start + $num_per_page * ($PageContiguous + 1) < $tmpMaxPages)
$pageindex .= '<span style="font-weight: bold;" onclick="expandPages(this, \'' . ($flexible_start ? strtr($base_url, array('\'' => '\\\'')) : strtr($base_url, array('%' => '%%', '\'' => '\\\'')) . ';start=%1$d') . '\', ' . ($start + $num_per_page * ($PageContiguous + 1)) . ', ' . $tmpMaxPages . ', ' . $num_per_page . ');" onmouseover="this.style.cursor=\'pointer\';"> ... </span>';

// Show the last number in the list. (1 ... 6 7 [8] 9 10 ... >15<)
if ($start + $num_per_page * $PageContiguous < $tmpMaxPages)
$pageindex .= sprintf($base_link, $tmpMaxPages, $tmpMaxPages / $num_per_page + 1);

// "Next"
if ( !$start_invalid )
{
$tmpMaxPages = (int) --$max_value / $num_per_page * $num_per_page;

$tmpStart = $start + $num_per_page;

$tmpStart <= $tmpMaxPages and $pageindex .= sprintf($base_link, $tmpStart, $txt['next page']);
}
}

return $pageindex;
}


Quote from: Shambles on January 29, 2021, 04:25:29 AM
Quote10. Previous and Next Links for Page Index 2.1.204

Probably that one. The parser for that mod shows it removing vital code, as shawnb61 has hinted at.

Guessed as much, just wasn't sure ;).

Quote from: Shambles on January 29, 2021, 04:25:29 AM
Code (what the mod is removing) Select
// Show the first page. (>1< ... 6 7 [8] 9 10 ... 15)
if ($start > $num_per_page * $PageContiguous)
$pageindex = sprintf($base_link, 0, '1');
else
$pageindex = '';


Inserting a definer line should cure it.

Code (find) Select

// Show the current page. (1 ... 6 7 >[8]< 9 10 ... 15)


Code (add after) Select

$pageindex = '';


LOL :D, that just shows me the page I've chosen to currently browse with no option to go backward or forward :D.



Quote from: shawnb61 on January 28, 2021, 09:04:56 PM
Compare that whole section to the vanilla file & make sure pageindex is getting set.

The Prev and Next links are the problem, so I'm guessing this should fix it ??? (at the bottom of the code).

Code (before) Select
// "Prev"
if ( !$start_invalid )
{
$tmpStart = $start - $num_per_page;

if ( $start / $num_per_page + 1 > 1 )
{
$pageindex = sprintf($base_link, $tmpStart, $txt['prev page']);

$start > $num_per_page * $PageContiguous and $pageindex .= sprintf($base_link, 0, '1');
}

else
{
$pageindex = $start > $num_per_page * $PageContiguous ? sprintf($base_link, 0, '1') : '';
}
}


Code (after) Select
// "Prev"
if ( !$start_invalid )
{
$tmpStart = $start - $num_per_page;

if ( $start / $num_per_page + 1 > 1 )
{
$pageindex = sprintf($base_link, $tmpStart, $txt['prev page']);

$start > $num_per_page * $PageContiguous and $pageindex .= sprintf($base_link, 0, '1');
}

else
{
$pageindex = $start > $num_per_page * $PageContiguous ? sprintf($base_link, 0, '1') : '';
}
}
else
$pageindex = '';


Should I add the Next link code section?

// "Next"
if ( !$start_invalid )
{
$tmpMaxPages = (int) --$max_value / $num_per_page * $num_per_page;

$tmpStart = $start + $num_per_page;

$tmpStart <= $tmpMaxPages and $pageindex .= sprintf($base_link, $tmpStart, $txt['next page']);
}
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Shambles

Try putting back the code that the mod removed...?

// Show the first page. (>1< ... 6 7 [8] 9 10 ... 15)
if ($start > $num_per_page * $PageContiguous)
$pageindex = sprintf($base_link, 0, '1');
else
$pageindex = '';

GigaWatt

I just uninstalled the mod... seemed simpler that way, since there's also the Next section in Subs.php and there might also be other edits, so... meeeh, I can live without it ;).

Yep, the error went away ;). I'll test it for another day or two, but I just browsed some bards, everything seems to be OK ;).

So, does anybody have any Idea how to fix the mod, or ???... or is there any other mod that does the same (adds Previous/Next page links)?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Shambles

Quote from: GigaWatt
So, does anybody have any Idea how to fix the mod, or ???...

Guess what I'm gonna say now...

GigaWatt

"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Advertisement: