WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 4 months ago

#37190 new enhancement

Split out function declarations and code executions.

Reported by: stephenharris Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Build/Test Tools Keywords: reporter-feedback
Focuses: Cc:

Description

Quite a few php files in the root directory contain function definitions and code executions. This makes it impossible to unit-test those functions. Should we move those function definitions to includes/<file-name>.php and then include them at the top of the root file?

Change History (2)

This ticket was mentioned in Slack in #core by noisysocks. View the logs.


4 months ago

#2 @isabel_brison
4 months ago

  • Component changed from General to Build/Test Tools
  • Keywords reporter-feedback added
  • Type changed from defect (bug) to enhancement

Thanks for reporting this @stephenharris . Could you specify which files you found with mixed function declarations and code execution?

In the interests of not moving code around just for the sake of it, it would be best to only move functions out when writing unit tests for them. Also, in the the process of moving the function out, we'll need to:

  • require_once at the top of the file they're used in for back-compatibility
  • potentially require_once elsewhere during bootstrapping.
Note: See TracTickets for help on using tickets.