Remove unnecessary function calls for page category and subcategory #116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using xdebug I noticed that the _topMenu() function was using 25% of the time to display the home page.
Looking into that function showed a coding mistake and unnecessary repeated calls of some functions.
$_GET['pi'] is always set which means the assignment on line 92 is never executed, causing the menu sometimes not have any open section.
As an example go to Config > Admins then select an admin. The Config section of the menu is closed instead of remaining open.
Need to compare with an empty string to determine whether the current page is a plugin page.
Related to 1) the pageCategory() function is called for each iteration of a 2-level loop. It can be called only once to find the category of the current page.
The function finds the subcategory for the current page. The processing then tests whether that subcategory is the same as the current menu page.
This can be replaced by simply testing whether the current page belongs to the list of pages for the current menu page, if that exists.
There are two sections of code that refer to the "Account" category - lines 97 and 120 in the original file. I guess this applies to phplist hosted, so I'm not able to test that the changes do not break that.