{"action":"closed","number":2035,"pull_request":{"url":"https://api.github.com/repos/php/php-src/pulls/2035","id":78971618,"html_url":"https://github.com/php/php-src/pull/2035","diff_url":"https://github.com/php/php-src/pull/2035.diff","patch_url":"https://github.com/php/php-src/pull/2035.patch","issue_url":"https://api.github.com/repos/php/php-src/issues/2035","number":2035,"state":"closed","locked":false,"title":"adds PREG_NO_UTF8_CHECK flag","user":{"login":"ju1ius","id":218404,"avatar_url":"https://avatars.githubusercontent.com/u/218404?v=3","gravatar_id":"","url":"https://api.github.com/users/ju1ius","html_url":"https://github.com/ju1ius","followers_url":"https://api.github.com/users/ju1ius/followers","following_url":"https://api.github.com/users/ju1ius/following{/other_user}","gists_url":"https://api.github.com/users/ju1ius/gists{/gist_id}","starred_url":"https://api.github.com/users/ju1ius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ju1ius/subscriptions","organizations_url":"https://api.github.com/users/ju1ius/orgs","repos_url":"https://api.github.com/users/ju1ius/repos","events_url":"https://api.github.com/users/ju1ius/events{/privacy}","received_events_url":"https://api.github.com/users/ju1ius/received_events","type":"User","site_admin":false},"body":"Hi,\r\nThis PR is related to [Bug #72685](https://bugs.php.net/bug.php?id=72685).\r\nIt adds a `PREG_NO_UTF8_CHECK` flag to `preg_match`, `preg_match_all` and `preg_split` functions to disable the implicit UTF-8 validity checking performed by PCRE by default when the `/u` option is enabled.\r\n\r\nWithout the ability to disable this check, matching repeatedly against the same input in utf-8 mode yields quadratic performance , instead of linear.\r\n\r\nI'm targetting this branch because it fixes a bug and it is a BC change, but it works on master too.\r\nThis is my first PR to php-src, so feel free to point me in the right direction if needed.\r\n\r\nThanks.\r\n\r\nFollowing is a small PHP script that can be ran against this branch to test the new behavior:\r\n\r\n```php\r\nfunction do_test ($input_size, $flags = 0) {\r\n  $str = str_repeat('a', $input_size);\r\n\r\n  $start = microtime(true);\r\n  $pos = 0;\r\n  while(preg_match('/\\G\\w/', $str, $m, $flags, $pos)) ++$pos;\r\n  $end = microtime(true);\r\n  echo '>>> NO u flag: ', number_format(($end - $start)*1000, 6), 'ms', PHP_EOL;\r\n\r\n  $start = microtime(true);\r\n  $pos = 0;\r\n  while(preg_match('/\\G\\w/u', $str, $m, $flags, $pos)) ++$pos;\r\n  $end = microtime(true);\r\n  echo '>>> WITH u flag: ', number_format(($end - $start)*1000, 6), 'ms', PHP_EOL;\r\n}\r\n\r\necho 'WITHOUT PREG_NO_UTF8_CHECK', PHP_EOL;\r\necho 'Input size = 1e4 ', PHP_EOL;\r\ndo_test(1e4, 0);\r\necho 'Input size = 1e5 ', PHP_EOL;\r\ndo_test(1e5, 0);\r\necho str_repeat('-', 80), PHP_EOL;\r\necho 'WITH PREG_NO_UTF8_CHECK', PHP_EOL;\r\necho 'Input size = 1e4 ', PHP_EOL;\r\ndo_test(1e4, PREG_NO_UTF8_CHECK);\r\necho 'Input size = 1e5 ', PHP_EOL;\r\ndo_test(1e5, PREG_NO_UTF8_CHECK);\r\n```\r\n\r\nSample output:\r\n```\r\nWITHOUT PREG_NO_UTF8_CHECK\r\nInput size = 1e4\r\n>>> NO u flag:    14.562130ms\r\n>>> WITH u flag: 243.849993ms\r\nInput size = 1e5\r\n>>> NO u flag:      111.440897ms\r\n>>> WITH u flag: 23,129.899025ms\r\n--------------------------------------------------------------------------------\r\nWITH PREG_NO_UTF8_CHECK\r\nInput size = 1e4\r\n>>> NO u flag:   11.296988ms\r\n>>> WITH u flag: 11.363029ms\r\nInput size = 1e5\r\n>>> NO u flag:   110.867023ms\r\n>>> WITH u flag: 111.830950ms\r\n```\r\n\r\n\r\n\r\n\r\n","created_at":"2016-07-27T06:30:28Z","updated_at":"2016-08-01T13:06:28Z","closed_at":"2016-08-01T13:06:28Z","merged_at":null,"merge_commit_sha":"f85c7e7ec3e576bd92302c12a2e81feeb807347d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/php/php-src/pulls/2035/commits","review_comments_url":"https://api.github.com/repos/php/php-src/pulls/2035/comments","review_comment_url":"https://api.github.com/repos/php/php-src/pulls/comments{/number}","comments_url":"https://api.github.com/repos/php/php-src/issues/2035/comments","statuses_url":"https://api.github.com/repos/php/php-src/statuses/4928e03267c018a260b671ca5cab5fa855fe8ef7","head":{"label":"ju1ius:pcre_no_utf_check","ref":"pcre_no_utf_check","sha":"4928e03267c018a260b671ca5cab5fa855fe8ef7","user":{"login":"ju1ius","id":218404,"avatar_url":"https://avatars.githubusercontent.com/u/218404?v=3","gravatar_id":"","url":"https://api.github.com/users/ju1ius","html_url":"https://github.com/ju1ius","followers_url":"https://api.github.com/users/ju1ius/followers","following_url":"https://api.github.com/users/ju1ius/following{/other_user}","gists_url":"https://api.github.com/users/ju1ius/gists{/gist_id}","starred_url":"https://api.github.com/users/ju1ius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ju1ius/subscriptions","organizations_url":"https://api.github.com/users/ju1ius/orgs","repos_url":"https://api.github.com/users/ju1ius/repos","events_url":"https://api.github.com/users/ju1ius/events{/privacy}","received_events_url":"https://api.github.com/users/ju1ius/received_events","type":"User","site_admin":false},"repo":{"id":64272546,"name":"php-src","full_name":"ju1ius/php-src","owner":{"login":"ju1ius","id":218404,"avatar_url":"https://avatars.githubusercontent.com/u/218404?v=3","gravatar_id":"","url":"https://api.github.com/users/ju1ius","html_url":"https://github.com/ju1ius","followers_url":"https://api.github.com/users/ju1ius/followers","following_url":"https://api.github.com/users/ju1ius/following{/other_user}","gists_url":"https://api.github.com/users/ju1ius/gists{/gist_id}","starred_url":"https://api.github.com/users/ju1ius/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ju1ius/subscriptions","organizations_url":"https://api.github.com/users/ju1ius/orgs","repos_url":"https://api.github.com/users/ju1ius/repos","events_url":"https://api.github.com/users/ju1ius/events{/privacy}","received_events_url":"https://api.github.com/users/ju1ius/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ju1ius/php-src","description":"The PHP Interpreter","fork":true,"url":"https://api.github.com/repos/ju1ius/php-src","forks_url":"https://api.github.com/repos/ju1ius/php-src/forks","keys_url":"https://api.github.com/repos/ju1ius/php-src/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ju1ius/php-src/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ju1ius/php-src/teams","hooks_url":"https://api.github.com/repos/ju1ius/php-src/hooks","issue_events_url":"https://api.github.com/repos/ju1ius/php-src/issues/events{/number}","events_url":"https://api.github.com/repos/ju1ius/php-src/events","assignees_url":"https://api.github.com/repos/ju1ius/php-src/assignees{/user}","branches_url":"https://api.github.com/repos/ju1ius/php-src/branches{/branch}","tags_url":"https://api.github.com/repos/ju1ius/php-src/tags","blobs_url":"https://api.github.com/repos/ju1ius/php-src/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ju1ius/php-src/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ju1ius/php-src/git/refs{/sha}","trees_url":"https://api.github.com/repos/ju1ius/php-src/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ju1ius/php-src/statuses/{sha}","languages_url":"https://api.github.com/repos/ju1ius/php-src/languages","stargazers_url":"https://api.github.com/repos/ju1ius/php-src/stargazers","contributors_url":"https://api.github.com/repos/ju1ius/php-src/contributors","subscribers_url":"https://api.github.com/repos/ju1ius/php-src/subscribers","subscription_url":"https://api.github.com/repos/ju1ius/php-src/subscription","commits_url":"https://api.github.com/repos/ju1ius/php-src/commits{/sha}","git_commits_url":"https://api.github.com/repos/ju1ius/php-src/git/commits{/sha}","comments_url":"https://api.github.com/repos/ju1ius/php-src/comments{/number}","issue_comment_url":"https://api.github.com/repos/ju1ius/php-src/issues/comments{/number}","contents_url":"https://api.github.com/repos/ju1ius/php-src/contents/{+path}","compare_url":"https://api.github.com/repos/ju1ius/php-src/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ju1ius/php-src/merges","archive_url":"https://api.github.com/repos/ju1ius/php-src/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ju1ius/php-src/downloads","issues_url":"https://api.github.com/repos/ju1ius/php-src/issues{/number}","pulls_url":"https://api.github.com/repos/ju1ius/php-src/pulls{/number}","milestones_url":"https://api.github.com/repos/ju1ius/php-src/milestones{/number}","notifications_url":"https://api.github.com/repos/ju1ius/php-src/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ju1ius/php-src/labels{/name}","releases_url":"https://api.github.com/repos/ju1ius/php-src/releases{/id}","deployments_url":"https://api.github.com/repos/ju1ius/php-src/deployments","created_at":"2016-07-27T03:02:33Z","updated_at":"2016-07-27T03:03:32Z","pushed_at":"2016-08-01T04:35:53Z","git_url":"git://github.com/ju1ius/php-src.git","ssh_url":"git@github.com:ju1ius/php-src.git","clone_url":"https://github.com/ju1ius/php-src.git","svn_url":"https://github.com/ju1ius/php-src","homepage":"http://www.php.net","size":247484,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"php:PHP-5.6","ref":"PHP-5.6","sha":"074b86d8451365c81d3ae76616fb4df1757ddc1f","user":{"login":"php","id":25158,"avatar_url":"https://avatars.githubusercontent.com/u/25158?v=3","gravatar_id":"","url":"https://api.github.com/users/php","html_url":"https://github.com/php","followers_url":"https://api.github.com/users/php/followers","following_url":"https://api.github.com/users/php/following{/other_user}","gists_url":"https://api.github.com/users/php/gists{/gist_id}","starred_url":"https://api.github.com/users/php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php/subscriptions","organizations_url":"https://api.github.com/users/php/orgs","repos_url":"https://api.github.com/users/php/repos","events_url":"https://api.github.com/users/php/events{/privacy}","received_events_url":"https://api.github.com/users/php/received_events","type":"Organization","site_admin":false},"repo":{"id":1903522,"name":"php-src","full_name":"php/php-src","owner":{"login":"php","id":25158,"avatar_url":"https://avatars.githubusercontent.com/u/25158?v=3","gravatar_id":"","url":"https://api.github.com/users/php","html_url":"https://github.com/php","followers_url":"https://api.github.com/users/php/followers","following_url":"https://api.github.com/users/php/following{/other_user}","gists_url":"https://api.github.com/users/php/gists{/gist_id}","starred_url":"https://api.github.com/users/php/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/php/subscriptions","organizations_url":"https://api.github.com/users/php/orgs","repos_url":"https://api.github.com/users/php/repos","events_url":"https://api.github.com/users/php/events{/privacy}","received_events_url":"https://api.github.com/users/php/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/php/php-src","description":"The PHP Interpreter","fork":false,"url":"https://api.github.com/repos/php/php-src","forks_url":"https://api.github.com/repos/php/php-src/forks","keys_url":"https://api.github.com/repos/php/php-src/keys{/key_id}","collaborators_url":"https://api.github.com/repos/php/php-src/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/php/php-src/teams","hooks_url":"https://api.github.com/repos/php/php-src/hooks","issue_events_url":"https://api.github.com/repos/php/php-src/issues/events{/number}","events_url":"https://api.github.com/repos/php/php-src/events","assignees_url":"https://api.github.com/repos/php/php-src/assignees{/user}","branches_url":"https://api.github.com/repos/php/php-src/branches{/branch}","tags_url":"https://api.github.com/repos/php/php-src/tags","blobs_url":"https://api.github.com/repos/php/php-src/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/php/php-src/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/php/php-src/git/refs{/sha}","trees_url":"https://api.github.com/repos/php/php-src/git/trees{/sha}","statuses_url":"https://api.github.com/repos/php/php-src/statuses/{sha}","languages_url":"https://api.github.com/repos/php/php-src/languages","stargazers_url":"https://api.github.com/repos/php/php-src/stargazers","contributors_url":"https://api.github.com/repos/php/php-src/contributors","subscribers_url":"https://api.github.com/repos/php/php-src/subscribers","subscription_url":"https://api.github.com/repos/php/php-src/subscription","commits_url":"https://api.github.com/repos/php/php-src/commits{/sha}","git_commits_url":"https://api.github.com/repos/php/php-src/git/commits{/sha}","comments_url":"https://api.github.com/repos/php/php-src/comments{/number}","issue_comment_url":"https://api.github.com/repos/php/php-src/issues/comments{/number}","contents_url":"https://api.github.com/repos/php/php-src/contents/{+path}","compare_url":"https://api.github.com/repos/php/php-src/compare/{base}...{head}","merges_url":"https://api.github.com/repos/php/php-src/merges","archive_url":"https://api.github.com/repos/php/php-src/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/php/php-src/downloads","issues_url":"https://api.github.com/repos/php/php-src/issues{/number}","pulls_url":"https://api.github.com/repos/php/php-src/pulls{/number}","milestones_url":"https://api.github.com/repos/php/php-src/milestones{/number}","notifications_url":"https://api.github.com/repos/php/php-src/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/php/php-src/labels{/name}","releases_url":"https://api.github.com/repos/php/php-src/releases{/id}","deployments_url":"https://api.github.com/repos/php/php-src/deployments","created_at":"2011-06-16T01:52:25Z","updated_at":"2016-08-01T12:19:16Z","pushed_at":"2016-08-01T12:20:39Z","git_url":"git://github.com/php/php-src.git","ssh_url":"git@github.com:php/php-src.git","clone_url":"https://github.com/php/php-src.git","svn_url":"https://github.com/php/php-src","homepage":"http://www.php.net","size":410376,"stargazers_count":9647,"watchers_count":9647,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3388,"mirror_url":null,"open_issues_count":315,"forks":3388,"open_issues":315,"watchers":9647,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/php/php-src/pulls/2035"},"html":{"href":"https://github.com/php/php-src/pull/2035"},"issue":{"href":"https://api.github.com/repos/php/php-src/issues/2035"},"comments":{"href":"https://api.github.com/repos/php/php-src/issues/2035/comments"},"review_comments":{"href":"https://api.github.com/repos/php/php-src/pulls/2035/comments"},"review_comment":{"href":"https://api.github.com/repos/php/php-src/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/php/php-src/pulls/2035/commits"},"statuses":{"href":"https://api.github.com/repos/php/php-src/statuses/4928e03267c018a260b671ca5cab5fa855fe8ef7"}},"merged":false,"mergeable":true,"mergeable_state":"clean","merged_by":null,"comments":19,"review_comments":1,"commits":2,"additions":68,"deletions":2,"changed_files":5}}
{"actor":{"display_login":"ju1ius"}}