Make WordPress Core

Opened 8 years ago

Last modified 4 years ago

#37190 new enhancement

Split out function declarations and code executions.

Reported by: stephenharris's profile stephenharris Owned by:
Milestone: Awaiting Review 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 (3)

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


5 years ago

#2 @isabel_brison
5 years 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.

#3 @desrosj
4 years ago

  • Milestone set to Awaiting Review
Note: See TracTickets for help on using tickets.