Opened 3 months ago

Last modified 3 months ago

#23685 new defect (bug)

Explicitly globalize version variables

Reported by: nbachiyski 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)

globalize-version-vars.diff (357 bytes) - added by nbachiyski 3 months ago.
globalize-version-vars-in-wp-settings.diff (808 bytes) - added by nbachiyski 3 months ago.

Download all attachments as: .zip

Change History (4)

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).

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.

Note: See TracTickets for help on using tickets.