Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 this issue Dec 27, 2021 · 1 comment

Comments

@BackuPs
Copy link

BackuPs commented Dec 27, 2021

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
Copy link
Member

dd32 commented Oct 12, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants