Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editing Membergroup Page Count Bug #6210

Closed
Butterflysaway opened this issue Aug 2, 2020 · 10 comments · Fixed by #6214
Closed

Editing Membergroup Page Count Bug #6210

Butterflysaway opened this issue Aug 2, 2020 · 10 comments · Fixed by #6214

Comments

@Butterflysaway
Copy link
Contributor

Description

Page count is not shown correctly while editing membergroup

Steps to reproduce

  1. Edit a custom membergroup with a decent amount of members in it
  2. Error gets thrown

Environment (complete as necessary)

  • Version/Git revision: 2.1 latest github
  • Database Type: Mysql
  • Database Version: mariadb
  • PHP Version:7.4

Additional information/references

Error:
Type of error: General
8: A non well formed numeric value encountered
https://website.com/index.php?action=admin;area=membergroups;sa=members;group=33
/website/Sources/Subs.php (Line 753)

Backtrace:
#0: smf_error_handler()
Called from /website/Sources/Subs.php on line 753
#1: constructPageIndex()
Called from /website/Sources/Groups.php on line 403
#2: MembergroupMembers()
Called from /website/Sources/Subs.php on line 5548
#3: call_helper()
Called from /website/Sources/ManageMembergroups.php on line 66
#4: ModifyMembergroups()
Called from /website/Sources/Admin.php on line 498
#5: AdminMain()
Called from /website/index.php on line 173

image

@Butterflysaway
Copy link
Contributor Author

Same error happens on moderation page in viewing groups

Type of error: General
8: A non well formed numeric value encountered
https://website.com/index.php?action=moderate;area=viewgroups;sa=members;group=34;sort=name;start=50
/website/Sources/Subs.php (Line 753)

Backtrace
#0: smf_error_handler()
Called from /webite/Sources/Subs.php on line 753
#1: constructPageIndex()
Called from /webite/Sources/Groups.php on line 403
#2: MembergroupMembers()
Called from /webite/Sources/Subs.php on line 5548
#3: call_helper()
Called from /webite/Sources/Groups.php on line 65
#4: Groups()
Called from /webite/Sources/Subs.php on line 5548
#5: call_helper()
Called from /webite/Sources/ModerationCenter.php on line 239
#6: ModerationMain()
Called from /webite/index.php on line 173

@albertlast
Copy link
Collaborator

Could it be,
that you subs is modified?
because 753 looks different to you mention error:
https://github.com/SimpleMachines/SMF2.1/blob/ed05806bfde57418f2d0ac6a7e95d86068f921d1/Sources/Subs.php#L753

@Butterflysaway
Copy link
Contributor Author

Shouldnt be the issue. I have a few files modified which I converted a few of my old smf 1.1.21 mods to 2.1. None of the files I edited should have caused it.

this is line 753 for me
$tmpMaxPages = (int) (($max_value - 1) / $num_per_page) * $num_per_page;

@Butterflysaway
Copy link
Contributor Author

This is the error with a clean version of subs.php

8: A non well formed numeric value encountered
https://website.com/index.php?action=admin;area=membergroups;sa=members;group=33
/website/Sources/Subs.php (Line 651)

@albertlast
Copy link
Collaborator

@Butterflysaway
Copy link
Contributor Author

Butterflysaway commented Aug 2, 2020

Pretty sure the problem is in

Groups.php line 400
$context['total_members'] = comma_format($context['total_members']);
should be removed or added after the call to constructPageIndex

correct?

@Butterflysaway
Copy link
Contributor Author

Butterflysaway commented Aug 2, 2020

that fixed the problem doing this

Sources/Groups.php

before
$context['total_members'] = comma_format($context['total_members']);

// Create the page index.
$context['page_index'] = constructPageIndex($scripturl . '?action=' . ($context['group']['can_moderate'] ? 'moderate;area=viewgroups' : 'groups') . ';sa=members;group=' . $_REQUEST['group'] . ';sort=' . $context['sort_by'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $context['total_members'], $modSettings['defaultMaxMembers']);

after
// Create the page index.
$context['page_index'] = constructPageIndex($scripturl . '?action=' . ($context['group']['can_moderate'] ? 'moderate;area=viewgroups' : 'groups') . ';sa=members;group=' . $_REQUEST['group'] . ';sort=' . $context['sort_by'] . (isset($_REQUEST['desc']) ? ';desc' : ''), $_REQUEST['start'], $context['total_members'], $modSettings['defaultMaxMembers']);
$context['total_members'] = comma_format($context['total_members']);

Could you make a pr for me, I suck at that.

image

@albertlast
Copy link
Collaborator

well it look like ther could multiple ways how to fix it,
alternative would be to add a casting to the construct page,
adavantage would be when some mods or so use this thing,
they don't need to change ther code:
https://github.com/SimpleMachines/SMF2.1/blob/8104e4328223106289fcb7719f85cb5ce88b1b1a/Sources/Subs.php#L562-L564
to

	// Enforce int parameters to be int
	$max_value = (int) $max_value;
	$num_per_page = (int) $num_per_page;
	$start = (int) $start;

	// Save whether $start was less than 0 or not.
	$start_invalid = $start < 0;

@Butterflysaway
Copy link
Contributor Author

Butterflysaway commented Aug 2, 2020

@albertlast just tried that and it didnt work. Not sure why casting 1,500,000 to (int) doesnt work? I thought that covered formatted string ints like that.

The error message is gone though, however it only shows 1 page for the group.

@Butterflysaway
Copy link
Contributor Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants