[wp-trac] [WordPress Trac] #45969: preg_match(): Compilation failed class-wp-block-parser.php line 418

WordPress Trac noreply at wordpress.org
Sun Jan 13 02:44:59 UTC 2019


#45969: preg_match(): Compilation failed class-wp-block-parser.php line 418
--------------------------+-----------------------------
 Reporter:  AndrewNZ      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  5.0.3
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 After updating from WP 4.9.9 to 5.0.3 I received an error on the front
 page of my site.

 Warning: preg_match() [function.preg-match]: Compilation failed:
 unrecognized character after (?< at offset 10 in htdocs/wp-includes/class-
 wp-block-parser.php on line 418

 I have seen a similar error to this error before and found this:
 https://wordpress.org/support/topic/preg_match-compilation-failed-at-wp-
 db-php-on-line-1657/page/3/

 And in the comments I found a link to:
 https://github.com/WordPress/WordPress/commit/fc42c062f1bcaea742fde26068a4cf5fde6d9390

 So following the changes in github I changed Line 413 from this:

 '/<!--\s+(?<closer>\/)?wp:(?<namespace>[a-z][a-z0-9_-]*\/)?(?<name>[a-z][a-z0-9_-]*)\s+(?<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\s+\/?-->).)*+)?}\s+)?(?<void>\/)?-->/s',

 To this:

 '/<!--\s+(?P<closer>\/)?wp:(?P<namespace>[a-z][a-z0-9_-]*\/)?(?P<name>[a-z][a-z0-9_-]*)\s+(?P<attrs>{(?:(?:[^}]+|}+(?=})|(?!}\s+\/?-->).)*+)?}\s+)?(?P<void>\/)?-->/s',

 When I uploaded  class-wp-block-parser.php the error message disappeared.

 I am a newby at PHP, and so I am not sure what adding the cap "P" to the
 code does but it works.

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


More information about the wp-trac mailing list