[wp-trac] [WordPress Trac] #38098: Use common naming for context switching functions / classes

WordPress Trac noreply at wordpress.org
Mon Sep 19 18:42:56 UTC 2016


#38098: Use common naming for context switching functions / classes
--------------------------+------------------------------
 Reporter:  swissspidy    |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by flixos90):

 Replying to [comment:4 swissspidy]:
 > `switch` is a reserved keyword in PHP. Using it as the method name is
 only allowed in PHP 7+ IIRC. It was only an example anyway :-)

 Oops. :)

 > Not sure how likely it is that you want to go to a specific point in the
 stack and how feasible it would be to implement this for locales for
 example. Sounds complex.

 I don't think it's too complex, both the snippet in #37958 and the initial
 patch in #25293 have a possible implementation.
 About the likeliness, this functionality shouldn't exist because a
 developer might wanna restore a certain point, but rather to prevent weird
 bugs when multiple parties (like plugins) are involved. Let's say one
 plugin iterates through sites and then restores back, and then another
 plugin iterates through some sites itself from within the loop of the
 other plugin - if the latter did a global restore then, it would mess up
 the state because the first plugin would already have some sites in the
 stack. Yes, it is unlikely, but not impossible, and it could easily lead
 to errors. It actually might be best not to even offer a way to clear the
 entire stack in order to prevent this problem from happening and instead
 encourage restoring to a certain point.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/38098#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list