Make WordPress Core

Opened 17 years ago

Closed 15 years ago

Last modified 6 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:

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

Download all attachments as: .zip

Change History (10)

#1 @foolswisdom
17 years ago

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

#2 @pgdx
17 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
17 years ago

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

@pgdx
17 years ago

#4 @pgdx
17 years ago

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

#5 @foolswisdom
17 years ago

  • Milestone 2.3 (trunk) deleted

#6 @crenner
16 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.

#7 @lloydbudd
16 years ago

  • Milestone set to 2.6

#8 @Denis-de-Bernardy
15 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.


6 years ago

Note: See TracTickets for help on using tickets.