Opened 3 months ago
Last modified 3 months ago
#23685 new defect (bug)
Explicitly globalize version variables
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Awaiting Review |
| Component: | Unit Tests | Version: | trunk |
| Severity: | normal | Keywords: | has-patch |
| Cc: |
Description
When WordPress is loaded in a function (e.g. unit tests) the variables initialized at the top level aren't globals, but we expect them to be.
For example, if in a unit test there is no way to access $wp_version. Neither via $wp_version (it's not in the same scope), not via $GLOBALS['wp_version'] (it's not a global).
To fix that we need to explicitly make the version variables global.
See #17749.
Attachments (2)
Change History (4)
nbachiyski — 3 months ago
comment:2
nbachiyski — 3 months ago
Now I understand. In the previous ticket dd32 mentioned this, but I thought of something else. Sorry about the wasted cycles.
Here is a patch, which works for me.
nbachiyski — 3 months ago
Note: See
TracTickets for help on using
tickets.

We sometimes include version.php in local scope inside a function on purpose, so we can get untainted variables (say, for an update check).
So, we would actually want to globalize these variables where this file is included (specifically wp-settings.php).