Skip to content

Performace: Order of checks in local_template_import_before_standard_top_of_body_html #2

Description

@mudrd8mz

The function local_template_import_before_standard_top_of_body_html() is executed on every single page load. It is essential that is performs effectively without adding unnecessary load to the server.

For that reason, I would suggest to re-order the early-exit checks so that first are evaluated those that do not need any further processing. For example the if (!strpos($PAGE->url, '/course/view.php')) should be evaluated as a very first one probably, followed by the $COURSE->id check and only then checks involving the capabilities.

Additionally, you may consider to display the popup only if the editing mode is enabled, effectively checking for $PAGE->user_is_editing().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions