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

Validation error for using global $PAGE in block classes #240

Open
eduardokraus opened this issue Sep 10, 2024 · 0 comments
Open

Validation error for using global $PAGE in block classes #240

eduardokraus opened this issue Sep 10, 2024 · 0 comments

Comments

@eduardokraus
Copy link

I created a class called block_type, and when running the code checker, I received the following error message:

global $PAGE cannot be used in block classes. Use $this->page.

Captura de Tela 2024-09-10 às 20 22 13

Steps to reproduce:

  1. Create a block class (e.g., block_type).
  2. Try using global $PAGE within the class.
  3. Run the code checker.

Expected behavior:

The code checker should allow the use of global $PAGE in appropriate contexts or provide a clearer message on how to adjust the code.

Current behavior:

The checker throws an error suggesting the use of $this->page without adequately explaining the situations where this should be applied.

Environment:

  • Moodle version: 4.3
  • Local Code Checker version: 2024070500

Possible solution:

It would be helpful to review the checker's logic to recognize the context where global $PAGE might be necessary or to better document when $this->page should be used.

Thank you!

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

No branches or pull requests

1 participant