Skip to content

Conversation

cyberalien
Copy link
Contributor

Missing hidden fields in search form (bug added in 3.0.9)

PHPBB3-10319

@@ -4530,6 +4530,11 @@ function page_header($page_title = '', $display_online_list = true, $item_id = 0
{
$s_search_hidden_fields['sid'] = $_SID;
}
for ($i=0; $i<count($_EXTRA_URL); $i++)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use foreach here. Same applies to the other files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

foreach also works on "numbered arrays"

foreach ($_EXTRA_URL as $extra_url) { }

the for loop has several drawbacks:

  1. unnecesarry introduction of a variable $i
  2. calling count() on every iteration (we use sizeof instead of count by the way)
  3. code readability

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add an empty line before the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@bantu
Copy link
Collaborator

bantu commented Dec 8, 2011

Concept-wise this $_EXTRA_URL stuff looks pretty fishy to me.

Missing hidden fields in search form (bug added in 3.0.9)

PHPBB3-10319
@naderman
Copy link
Member

naderman commented Dec 8, 2011

Looks good to me now, I'd merge this into the prep-release branch for 3.0.10 still.

@cyberalien
Copy link
Contributor Author

I agree that it looks fishy. Other way around it is to revert whatever change was added in 3.0.9 that changed all search forms from POST to GET, then this variable wouldn't be needed.

@naderman
Copy link
Member

naderman commented Dec 8, 2011

He was only talking about the variable $i not about $_EXTRA_URL. This is perfectly fine.

Edit: Oh I see Andreas' comment now. Anyway we must keep them GET so search result URLs can be copied, POST is not an option for these forms. I do wonder though if we have GET forms elsewhere that ignore $_EXTRA_URL.

@cyberalien
Copy link
Contributor Author

Nope, only 4 search forms were affected, 1 of them (in search.php) already has correct hidden fields.

@naderman
Copy link
Member

naderman commented Dec 9, 2011

Cherry picked and merged into prep-release-3.0.10

@naderman naderman closed this Dec 9, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants