Make WordPress Core

Opened 16 years ago

Closed 14 years ago

Last modified 5 years ago

#4538 closed defect (bug) (wontfix)

Invalid Argument in wp_add_post_tags loop

Reported by: jcwinnie's profile jcwinnie Owned by:
Milestone: Priority: normal
Severity: normal Version: 2.3.2
Component: Import Keywords: foreach get_option utwimp tag2post
Focuses: Cc:


Watch that Third Step

Import Ultimate Tag Warrior

Steps may take a few minutes depending on the size of your database. Please be patient.

Adding Tags to Posts…

Warning: Invalid argument supplied for foreach() in /home/jcwinnie/public_html/wordpress/wp-admin/import/utw.php on line 209

Done! 0 tags where added!

Can you say foreach ( $posts as $this_post ) without $this_post being declared first?

Attachments (1)

rev5767.txt (657 bytes) - added by pgdx 16 years ago.

Download all attachments as: .zip

Change History (10)

#1 @foolswisdom
16 years ago

  • Milestone set to 2.3 (trunk)
  • Version set to 2.3

#2 @pgdx
16 years ago

  • Keywords foreach get_option utwimp tag2post added

Yes, you can say that without declaring it. You may get that error message if the $posts is null.

#3 @pgdx
16 years ago

perhaps one wants to say
foreach ( (array) $posts as $this_post )

16 years ago

#4 @pgdx
16 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

#5 @foolswisdom
16 years ago

  • Milestone 2.3 (trunk) deleted

#6 @crenner
15 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Version changed from 2.3 to 2.3.2

This error is still achievable with large amounts of post and tag data. We had it with about 16k post/tag relationships. The import wizard saves its data between server calls by using the wp_options table. On our server, the write command for that particular variable was failing, because it exceeded our MySQL maximum packet size (default is 1MB). So, the easy solution for those of you with this issue is to up your mysql max_allowed_packet (see ).

The long term solution to this is probably to not use the wp_options table to store potentially large values. And honestly, it's not like this wizard requires any step-by-step interaction with the user, it could be combined into a single script and remove the need for storing values there anyways.

The solution suggested by pgdx (forcing $posts to be cast as an array) doesn't actually help anything, it just removes the error. If $posts is empty or null (as is the case when the option wasn't saved) this will just end up with an array that contains a single null value. No importing would actually happen in this case.

#7 @lloydbudd
15 years ago

  • Milestone set to 2.6

#8 @Denis-de-Bernardy
14 years ago

  • Component changed from Administration to Import
  • Milestone 2.9 deleted
  • Resolution set to wontfix
  • Status changed from reopened to closed

has been rotting for too long

This ticket was mentioned in Slack in #core-editor by noisysocks. View the logs.

5 years ago

Note: See TracTickets for help on using tickets.