Skip to content

Commit b908758

Browse files
committed
Count XML errors more gracefully
Towards statedecoded#433.
1 parent b2593f6 commit b908758

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

includes/class.ParserController.inc.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1968,21 +1968,28 @@ function index_laws()
19681968
if (preg_match_all('/' . preg_quote($path, '/') . '(.+)\.xml\:/', $output, $matches) !== FALSE)
19691969
{
19701970

1971-
$invalid_xml = array();
19721971
if (count($matches[1]) > 0)
19731972
{
19741973

1975-
$this->logger->message('preg_match_all did not return an error');
1974+
$invalid_files = 0;
1975+
19761976
foreach ($matches[1] as $match)
19771977
{
19781978

19791979
$key = array_search($match, $files);
1980-
unset($files[$key]);
1980+
if ($key !== FALSE)
1981+
{
1982+
unset($files[$key]);
1983+
$invalid_files++;
1984+
}
19811985

19821986
}
1983-
$this->logger->message('Suppressing the indexing of ' .
1984-
number_format( count($this->invalid_xml) ) . ' laws, for the presence of'
1985-
. ' invalid XML');
1987+
1988+
if ($invalid_files > 0)
1989+
{
1990+
$this->logger->message('Suppressing the indexing of ' .
1991+
number_format($invalid_files) . ' laws, for the presence of invalid XML');
1992+
}
19861993

19871994
}
19881995

0 commit comments

Comments
 (0)