From 64c6fa8f56872cdbb4584782ce5c24e13a3cc5ca Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Tue, 28 Nov 2023 21:22:35 +0100 Subject: [PATCH] Prevent deprecation warnings due to null strings. Fixes #11. --- includes/PubmedParser_Article.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/includes/PubmedParser_Article.php b/includes/PubmedParser_Article.php index a9d8778..2d5cb8b 100644 --- a/includes/PubmedParser_Article.php +++ b/includes/PubmedParser_Article.php @@ -116,7 +116,7 @@ private function parse( \XMLReader $reader ) { } break; case 'AbstractText': - $label = strip_tags( $reader->getAttribute( 'Label' ) ); + $label = strip_tags( $reader->getAttribute( 'Label' ?? '' ) ); $label = trim( preg_replace( '/\s\s+/', ' ', $label ) ); $content = strip_tags( $reader->readInnerXML() ); $content = trim( preg_replace( '/\s\s+/', ' ', $content ) ); @@ -226,8 +226,10 @@ function journalCaps() { /// Returns the first page of the article. function firstPage() { - $fp = explode('-', $this->pages); - return $fp[0]; + if ( $this->pages ) { + $fp = explode('-', $this->pages); + return $fp[0]; + } } function journalAbbrevNoPeriods() {