[wp-trac] [WordPress Trac] #54645: Allow numeric theme name

WordPress Trac noreply at wordpress.org
Fri Dec 17 14:06:03 UTC 2021


#54645: Allow numeric theme name
-------------------------------------------------+-------------------------
 Reporter:  alvastar                             |      Owner:  (none)
     Type:  defect (bug)                         |     Status:  new
 Priority:  normal                               |  Milestone:  Awaiting
                                                 |  Review
Component:  REST API                             |    Version:  5.8.2
 Severity:  normal                               |   Keywords:
  Focuses:  administration, template,            |
  multisite, rest-api                            |
-------------------------------------------------+-------------------------
 What steps should be taken to consistently reproduce the problem?

 * Create a theme with a numeric name or rename an existing one.
 * Activate the theme for your site.

 The theme will not be displayed as active.

 Also, when using the Gutenberg editor, calls to the add_theme_support
 function will not work.

 Possibly the problem is how PHP is converting the keys of the array:

   Strings containing valid decimal ints, unless the number is preceded by
 a + sign, will be cast to the int type. E.g. the key "8" will actually be
 stored under 8. On the other hand "08" will not be cast, as it isn't a
 valid decimal integer.

 Suggested solution to the problem:

 File in wp-icnludes/rest-api/endpoints/class-wp-rest-themes-controller.php
 replace this

 {{{#!php
 /**
  * Helper function to compare two themes.
  *
  * @since 5.7.0
  *
  * @param WP_Theme $theme_a First theme to compare.
  * @param WP_Theme $theme_b Second theme to compare.
  * @return bool
  */
 protected function is_same_theme( $theme_a, $theme_b ) {
         return $theme_a->get_stylesheet() === $theme_b->get_stylesheet();
 }
 }}}


 with this

 {{{#!php
 /**
  * Helper function to compare two themes.
  *
  * @since 5.7.0
  *
  * @param WP_Theme $theme_a First theme to compare.
  * @param WP_Theme $theme_b Second theme to compare.
  * @return bool
  */
 protected function is_same_theme( $theme_a, $theme_b ) {
         return (string)$theme_a->get_stylesheet() ===
 (string)$theme_b->get_stylesheet();
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54645>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list