Fix PHP notice "Undefined offset: 1 in readme-parser.php on line 161".

Let's discard incorrectly formatted "upgrade notice" sections instead of triggering PHP notices.
This commit is contained in:
Yahnis Elsts 2018-01-08 12:49:22 +02:00
parent da42863436
commit f7f63d203d
1 changed files with 5 additions and 2 deletions

View File

@ -157,8 +157,11 @@ class PucReadmeParser {
$upgrade_notice = array();
if ( isset($final_sections['upgrade_notice']) ) {
$split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
for ( $i = 0; $i < count( $split ); $i += 2 )
$upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
if ( count($split) >= 2 ) {
for ( $i = 0; $i < count( $split ); $i += 2 ) {
$upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
}
}
unset( $final_sections['upgrade_notice'] );
}