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

Cannot create a user with an empty login name

Open NandoSangenetto opened this issue 5 years ago • 9 comments

Hello, I was importing 16 files generated with the wp-cli tool and also I was importing it with the same tool.

All files were imported fine except 2 files the 13th and the 16th.

Those are the errors that occured: image

I tried to go the parsers.php file on the line it mentions but I don't think that the problem resides in this file but in the exporter somehow.

I just want to know what kind of information can lead to this error, to se if I can fix it in the WXR (xml) file and also file an issue about it on the exporter.

NandoSangenetto avatar Feb 19 '20 12:02 NandoSangenetto

On my 467 line I have $a = $this->process_author( $author[1] );.

NandoSangenetto avatar Feb 19 '20 13:02 NandoSangenetto

It only worked when I changed the <wp:author>'s content to be in the same line, like:

<wp:author><wp:author_id>237</wp:author_id><wp:author_login>John Doe</wp:author_login><wp:author_email>[email protected]</wp:author_email><wp:author_display_name><![CDATA[John Doe]]></wp:author_display_name><wp:author_first_name><![CDATA[John]]></wp:author_first_name><wp:author_last_name><![CDATA[Doe]]></wp:author_last_name></wp:author>

NandoSangenetto avatar Feb 19 '20 20:02 NandoSangenetto

Can you share the full XML file which was causing the error?

ocean90 avatar Mar 07 '20 14:03 ocean90

Same here. I had that very same error message:

Cannot create a user with an empty login name

But my XML contained all valid users with proper usernames, so I was very uncertain on the cause.

Spent a whole afternoon researching. Also, on my dev machine the import worked, whereas on the production server did not.

Finally, after enabling:

define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);

A long series of this notice came up on screen during the import:

Notice: Undefined offset: 1 in /var/www/html/wp-content/plugins/wordpress-importer/parsers/class-wxr-parser-regex.php on line 61

The line is:

if ( false !== strpos( $importline, '<wp:author>' ) ) {
	preg_match( '|<wp:author>(.*?)</wp:author>|is', $importline, $author );
>>	$a = $this->process_author( $author[1] ); <<
	$this->authors[$a['author_login']] = $a;
	continue;
}

I put a debug code before it such like this:

if(!isset($author[1])) { echo $importline; exit; }

I relaunched the import and as expected it quitted with this text:

Starting the import process...
<pre>228685:1152 internal error: Huge input lookup

</pre><p><strong>Si è verificato un errore nella lettura di questo file WXR</strong><br />I dettagli sono indicati sopra. L'importatore ora riproverà con un parser diverso...</p><wp:author>

Googling "php Huge input lookup" gave me this thread:

https://wordpress.org/support/topic/fix-for-warning-xml-error-1-internal-error-huge-input-lookup/

Where "britt" guy links this other thread:

https://wordpress.org/support/topic/warning-xml-error-1-internal-error-huge-input-lookup-1/

So I applied the suggested fix in /plugins/wordpress-importer/parsers/class-wxr-parser-simplexml.php line 23 to make it look like:

$success = $dom->loadXML( file_get_contents( $file ), LIBXML_PARSEHUGE );

Relaunched the import and it's running now, no more crash with that subtle message.

note: the size of the XML file itself is ~14MB

DrLightman avatar Mar 19 '20 17:03 DrLightman

@ocean90 ^

DrLightman avatar Mar 31 '20 07:03 DrLightman

It only worked when I changed the <wp:author>'s content to be in the same line, like:

<wp:author><wp:author_id>237</wp:author_id><wp:author_login>John Doe</wp:author_login><wp:author_email>[email protected]</wp:author_email><wp:author_display_name><![CDATA[John Doe]]></wp:author_display_name><wp:author_first_name><![CDATA[John]]></wp:author_first_name><wp:author_last_name><![CDATA[Doe]]></wp:author_last_name></wp:author>

This has been the solution of my problem too. As I had several files to import, and almost 15k articles, I created a small script which may help many of you: it works on Python3 and put all author data on the same line. After editing my files with it, I got my import working perfectly.

You can find it here.

emiliodallatorre avatar May 27 '21 10:05 emiliodallatorre

Why closed? Has it been fixed in official importer?

DrLightman avatar Jun 03 '21 07:06 DrLightman

Not fixed yet, I had the same issue, this solution fixed it for me https://github.com/WordPress/wordpress-importer/issues/66#issuecomment-588432713

Thanks!

luigitek avatar Jul 20 '21 23:07 luigitek

2024 and just had this issue. https://github.com/WordPress/wordpress-importer/issues/66#issuecomment-601303129 this fixed my issue

cwahlfeldt avatar Mar 21 '24 21:03 cwahlfeldt