Skip to content

preg_replace times out after upgrading to 8.2 when browscap setting is set #12885

@ymTm7KuhCnIjkZAl2x2m2

Description

@ymTm7KuhCnIjkZAl2x2m2

Description

I had this issue after upgrading to 8.2 and I've created this example that shows the issue. My php.ini is exactly the production version with one change: browscap points to the latest lite_php_browscap.ini from browscap.org. I'm using IIS on Windows Server 2022.

The following code:

<?php

$string = 'The quick brown fox jumps over the lazy dog.';
$patterns = array();
$patterns[0] = '/quick/';
$patterns[1] = '/brown/';
$patterns[2] = '/fox/';
$replacements = array();
$replacements[0] = 'slow';
$replacements[1] = 'black';
$replacements[2] = 'bear';

echo preg_replace($patterns, $replacements, $string);

Resulted in this output:

HTTP Error 500.0 - Internal Server Error

But I expected this output instead:

The slow bear jumps over the lazy dog.

In fact, I do get this output if I comment out the browscap setting in php.ini. I also get this result if I remove many lines from the browscap file. I did not see this issue in PHP 8.1.

PHP Version

8.2.13

Operating System

Windows Server 2022

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions