Changeset 2691


Ignore:
Timestamp:
5/25/2012 2:25:13 AM (2 years ago)
Author:
lowjoel
Message:

Factorise GetReportIDFromExceptionIDs out from QueryStatus? since Upload will use it too.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/website/scripts/blackbox/upload.php

    r2690 r2691  
    6363} 
    6464 
     65function GetReportIDFromExceptionIDs(array $exceptionIDs) 
     66{ 
     67    $ids = implode(', ', $exceptionIDs); 
     68    $pdo = new Database(); 
     69    $result = $pdo->query(sprintf('SELECT ReportID, COUNT(ID) as Matches FROM blackbox_exceptions 
     70        WHERE ID IN (%s) GROUP BY ReportID ORDER BY Matches DESC', $ids)); 
     71 
     72    if ($result->rowCount() > 0) 
     73    { 
     74        $row = $result->fetch(); 
     75        return $row['ReportID']; 
     76    } 
     77 
     78    return null; 
     79} 
     80 
    6581function QueryStatus($stackTrace) 
    6682{ 
     
    6884    $reportID = false; 
    6985    $exceptionIDs = array(); 
    70     $pdo = new Database(); 
    7186     
    7287    foreach ($stackTrace as $exceptionDepth => $exception) 
     
    90105    if ($status == 'exists' && count($exceptionIDs) > 0) 
    91106    { 
    92         $ids = implode(', ', $exceptionIDs); 
    93         $result = $pdo->query(sprintf('SELECT ReportID, COUNT(ID) as Matches FROM blackbox_exceptions 
    94             WHERE ID IN (%s) GROUP BY ReportID ORDER BY Matches DESC', $ids)); 
    95         if ($result->rowCount() > 0) 
    96         { 
    97             $row = $result->fetch(); 
    98             $reportID = $row['ReportID']; 
    99  
     107        $reportID = GetReportIDFromExceptionIDs($exceptionIDs); 
     108        if ($reportID !== null) 
     109        { 
    100110            printf('<?xml version="1.0"?> 
    101111<crashReport status="exists" id="%s" />', htmlspecialchars($status), $reportID); 
Note: See TracChangeset for help on using the changeset viewer.