|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53955 preg_match_all missing results
Submitted: 2011-02-08 09:06 UTC Modified: 2013-02-18 00:34 UTC
From: rick at lavoo dot com Assigned:
Status: No Feedback Package: *Regular Expressions
PHP Version: 5.3.5 OS: FreeBSD 7.2-RELEASE
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
31 + 12 = ?
Subscribe to this entry?

 [2011-02-08 09:06 UTC] rick at lavoo dot com

preg_match_all is missing valid results while running in a loop of documents. There are 12 valid matches per document, but starting from document 5 only 11 results are returned. When the script is run "only" on document 5 or 6 or 7 etc, all 12 results are returned properly.

The script returns no warnings or errors when running in the loop and missing the 12th result.

Test script:
This is an example of the code being used:

    for ($i = 0; $i <= $pages; $i++) {
        shell_exec(" /usr/local/bin/curl -o /tmp/coffee_process_ajax.tmp -b PHPSESSID=$cookie -d \"category_id=$cat&page_index=$i\"");
        $filename = "/tmp/coffee_process_ajax.tmp";
        $handle = fopen($filename, "r");
        $adata = fread($handle, filesize($filename));
        preg_match_all("/<table class=AssetContent>(.*?)<\/table>/", str_replace("\n","",$adata), $ajarray);

Expected result:
The expected result is all 12 results to be returned with and without the loop.

Actual result:
Returns only 11 results starting at $page=4 (the 5th document) while running in the loop. Returns all 12 results for $page=4 when not running in the loop.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2011-02-08 09:10 UTC]
-Status: Open +Status: Feedback
 [2011-02-08 09:10 UTC]
Without a test script we can actually run, we have no way of checking if this is 
actually a bug.

Simplify the script down to a smaller set of documents, embed them in a standalone 
script that we can download somewhere, and we can have a look.
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jan 22 06:03:34 2022 UTC