wordpress-importer icon indicating copy to clipboard operation
wordpress-importer copied to clipboard

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

Open BackuPs opened this issue 3 years ago • 1 comments

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

BackuPs avatar Dec 27 '21 11:12 BackuPs

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.

dd32 avatar Oct 12 '22 08:10 dd32