Skip to:
Content

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#2786 closed task (fixed)

Helper function for getting $wp_rewrite global

Reported by: johnjamesjacoby Owned by: johnjamesjacoby
Milestone: 2.6 Priority: normal
Severity: normal Version:
Component: Tools - Code Improvements Keywords:
Cc:

Description

There are 44 references and global touches to $wp_rewrite in the codebase. Each touch poses the threat of accidental assignments, increasing the risk factor of interacting with its data.

bbPress primarily references $wp_rewrite for:

  • Comparisons to using_permalinks()
  • Using the root variable
  • Using pagination_base to build pagination_links

Change History (6)

#1 @johnjamesjacoby
4 years ago

We should likely do something for other globals, so naming conventions here will be important.

Do we have 1 wrapper, like:

  • bbp_get_global( 'wp_roles' );

Or case-by-case them:

  • bbp_get_wp_roles();

#2 @netweb
4 years ago

  • Milestone changed from 2.6 to 2.7

Punting 2.6 tickets without a patch to 2.7

#3 @johnjamesjacoby
4 years ago

In 5823:

Introduce core/abstraction.php to provide a layer of protection against touching common WordPress global variables directly.

This commit introduces a few new helper functions to protect sensitive global variables, and also introduces the ability to filter and override them explicitly within the scope of the bbPress plugin. These functions will be used in place of existing global touches in future commits.

See #2786.

#4 @johnjamesjacoby
4 years ago

In 5826:

Introduce bbp_get_global_object() to help with verifying & retrieving global variables before interacting with them. See #2786.

#5 @johnjamesjacoby
4 years ago

  • Owner set to johnjamesjacoby
  • Resolution set to fixed
  • Status changed from new to closed

In 5827:

Abstraction: Use bbp_db(), bbp_rewrite() & friends, introduced in r5823 & r5826.

This commit improves the stability of bbPress in the WordPress environment by reducing global variable exposure. It also comes with minimal opcode improvements in some circumstances where $GLOBALS is preferred over defining via global statements.

Some additional surrounding cleanup directly related to functions & methods being altered is also being performed here.

Fixes #2786.

#6 @netweb
4 years ago

  • Milestone changed from 2.7 to 2.6
Note: See TracTickets for help on using tickets.