Skip to content

Only load status_config.php CSS when necessary#1833

Merged
dregad merged 2 commits intomantisbt:masterfrom
dregad:status-config-css-when-needed
Jul 28, 2022
Merged

Only load status_config.php CSS when necessary#1833
dregad merged 2 commits intomantisbt:masterfrom
dregad:status-config-css-when-needed

Conversation

@dregad
Copy link
Copy Markdown
Member

@dregad dregad commented Jul 10, 2022

As mentioned in #1831 (comment)

Fixes #30773

@dregad dregad self-assigned this Jul 10, 2022
@atrol
Copy link
Copy Markdown
Member

atrol commented Jul 17, 2022

@dregad do we still need this ugly special handling in status_config.php after your change?

if( $t_referer_page == auth_login_page() ) {
	# custom status colors not needed.
	http_caching_headers( false );
	exit;
}

switch( $t_referer_page ) {
	case AUTH_PAGE_USERNAME:
	case AUTH_PAGE_CREDENTIAL:
	case 'signup_page.php':
	case 'lost_pwd_page.php':
	case 'account_update.php':
		# We don't need custom status colors on login page, and this is
		# actually causing an error since we're not authenticated yet.
		http_caching_headers( false );
		exit;
}

@dregad
Copy link
Copy Markdown
Member Author

dregad commented Jul 20, 2022

do we still need this ugly special handling in status_config.php after your change?

Possibly not. I'll check.

dregad added 2 commits July 20, 2022 17:12
The dynamic CSS for status colors was included in relationship_api.php
and bug_group_action_api.php, which caused status_config.php to be
loaded for every MantisBT page even though it is not needed for many of
them.

This moves the require_css() call to the individual files that require
the specific color classes.

NOTE: This could introduce regression issues for Plugins relying on the
status_config.php CSS to be loaded by MantisBT core.
- Affected plugins: relying on html_get_status_css_* functions
- Symptoms: The status indicators are displayed in black instead of the
  expected color
- Solution: add `require_css( 'status_config.php' );` to the relevant
  plugin pages or in the EVENT_LAYOUT_RESOURCES hook, as appropriate.

Fixes #30773
The logic to load the dynamic CSS only for certain pages based on
HTTP_REFERER is no longer needed, as the script is only called when it
is actually needed

Issue #30773

Signed-off-by: Damien Regad <dregad@mantisbt.org>
@dregad dregad force-pushed the status-config-css-when-needed branch from cac399f to fe94f64 Compare July 20, 2022 15:52
@dregad
Copy link
Copy Markdown
Member Author

dregad commented Jul 20, 2022

@atrol I removed the code and performed some testing, did not notice any regressions.

@dregad dregad merged commit aed33fb into mantisbt:master Jul 28, 2022
@dregad dregad deleted the status-config-css-when-needed branch July 28, 2022 10:15
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