SVG Loading
mmartel-opinionsystem opened this issue · 3 comments
Since PHP 7.2 (probably 7+), getting this error when loading SVGs:
Error:
count(): Parameter must be an array or an object that implements Countable
on line 259 in lib/php-svg-lib/src/Svg/Document.php
My code to implement an SVG in DomPDF:
<img src="image/certificat_adhesion/top_ribbon_portrait.svg" id="top_ribbon">
Image show up in PDF, but creates php error log entries due to error.
This is the problem:
Line 259:
if (count($this->attributes)) {
Should be:
if (count($attributes)) {
very similar issue:
PHP Notice: Undefined offset: 0 in .../phenx/php-svg-lib/src/Svg/Tag/AbstractTag.php on line 146
PHP Warning: count(): Parameter must be an array or an object that implements Countable in .../phenx/php-svg-lib/src/Svg/Tag/AbstractTag.php on line 146
caused by preg_match_all
that doesn't match and
...
146 if (count($match[0])) {
...
on line 259 in lib/php-svg-lib/src/Svg/Document.php, adding the following check
...
259 if (isset($this->attributes) && count($this->attributes)) {
...
before doing php count check should be done on variable first.