WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 5 years ago

#4538 closed defect (bug) (wontfix)

Invalid Argument in wp_add_post_tags loop

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

Description

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 7 years ago.

Download all attachments as: .zip

Change History (9)

comment:1 foolswisdom7 years ago

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

comment:2 pgdx7 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.

comment:3 pgdx7 years ago

perhaps one wants to say
<pre>
foreach ( (array) $posts as $this_post )
</pre>

pgdx7 years ago

comment:4 pgdx7 years ago

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

comment:5 foolswisdom7 years ago

  • Milestone 2.3 (trunk) deleted

comment:6 crenner6 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 http://dev.mysql.com/doc/refman/5.0/en/packet-too-large.html ).

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.

comment:7 lloydbudd6 years ago

  • Milestone set to 2.6

comment:8 Denis-de-Bernardy5 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

Note: See TracTickets for help on using tickets.