WordPress / wordpress-importer

The WordPress Importer
https://wordpress.org/plugins/wordpress-importer/
GNU General Public License v2.0
78 stars 76 forks source link

Warning: Undefined array key 1 in /var/mywebsite/public/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-regex.php on line 64 #118

Open BackuPs opened 2 years ago

BackuPs commented 2 years ago

I am getting this warning message. Warning: Undefined array key 1 in /var/mywebsite/public/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-regex.php on line 64

dd32 commented 1 year ago

Looking at the code responsible here: https://github.com/WordPress/wordpress-importer/blob/master/src/parsers/class-wxr-parser-regex.php#L63-L68

The PHP Warning is suggesting that the line contains <wp:author> but that <wp:author>...</wp:author> is not present on the line being parsed. The regex includes s to include new lines in the middle of the tags, but this parser only parses line-by-line..

I suspect this can be triggered by having an author with a \n in a user field, OR where the author tags exceed 8192 chars, as there's a lot of tags within that tag: https://github.com/WordPress/wordpress-importer/blob/master/src/parsers/class-wxr-parser-regex.php#L210-L217

I guess a fix here is to move the author handling into $multiline_tags, but with the note that $this->{$handler[0]}[] = ... and $this->authors[ $a['author_login'] ] = ... are incompatible right now, so some changes to set a specific key out of the payload would be required.