Fix for WordPress XMLRPC 500 Internal Server Error

Posted July 15th, 2009 by derek   Development No Comments »

One of my WordPress-based sites (http://crowdspace.net) was not working when I tried to publish posts containing images from Windows Live Writer.  I was getting a 500 Internal Server Error.

I was able to fix the problem by making a small change to the database.

The Error Message

I enabled Failed Request Tracing in IIS7 to find out what was happening server-side to cause the HTTP 500 error.  I discovered that the PHP script was trying to insert a row into the wp_posts table with a value of -1 in the post_parent column:

WordPress database error Out of range value for column ‘post_parent’ at row 1 for query INSERT INTO `wp_posts` (`post_author`,`post_date`,`post_date_gmt`, `post_content`, `post_content_filtered`, `post_title`, `post_excerpt`, `post_status`, `post_type`, `comment_status`,`ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_parent`,`menu_order`,`post_mime_type`,`guid`) VALUES (’1′,’2009-07-15 14:37:14′,’2009-07-15 17:37:14′,'’,'’,'2827426439_7b744abd30_m.jpg’, ‘’, ‘inherit’, ‘attachment’,'open’,'open’, ‘’, ‘2827426439_7b744abd30_m-jpg’,'’,'’,'2009-07-15 14:37:14′,’2009-07-15 17:37:14′,’-1′, ‘0′, ‘image/jpeg’, ‘http://crowdspace.net/files/2827426439_7b744abd30_m5.jpg’) made by wp_xmlrpc_server->wp_xmlrpc_server, IXR_Server->IXR_Server, IXR_Server->serve, IXR_Server->call, wp_xmlrpc_server->mw_newMediaObject, wp_insert_attachment
ErrorCode 5
ErrorCode
 

Apparently the database didn’t like that…  I investigated further and discovered that the post_parent column in my database was set to BIGINT UNSIGNED.  In other words, that database column could not hold the value -1 (unsigned integers are zero or higher).

Some Sanity Checking

I checked several other WordPress databases that I control and found that post_parent column is not UNSIGNED in any of my other WP databases.

So why the difference?  All my other databases were created with earlier versions of WordPress and upgraded.  The database in question, however, had been created with the latest WordPress release (2.8 at the time).  So I popped open the PHP file that defines the database (schema.php) and discovered:

post_parent bigint(20) unsigned NOT NULL default ‘0′,

What’s Going On Here?

When the XMLRPC script uploads an image (called an attachment in WordPress), it uploads it with a post_parent of -1.  Then after the post is created, the script updates attachments with post_parent=-1 with the actual ID of the freshly created post.

My guess is that a developer on the project decided to update the schema to UNSIGNED because posts do not have negative values for IDs and the post_parent column references a post ID.  Obviously that developer did not realize the special use case in xmlrpc.php.

How Do I Fix This?

Fortunately the workaround is easy.  Just run the following database query to change the data type on the post_parent column:

ALTER TABLE wp_posts CHANGE post_parent post_parent BIGINT;

If you don’t know how to run queries against your MySQL database, well, this is a good time to learn.  I did it at the command line on my 64-bit Windows server:

cd "C:\Program Files (x86)\MySQL\MySQL Server 5.1\bin\"

mysql.exe –u root -p
Enter password: ***********************

Welcome to the MySQL monitor.  Commands end with ; or \g.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the buffer.

mysql> use crowdspace
Database changed
mysql> ALTER TABLE wp_posts CHANGE post_parent post_parent BIGINT;

The process is similar on a Linux box.  I’m going to go out on a limb here and assume that you can figure out how to run mysql on Linux if you’re running your own Linux server.

If you’re using a shared web hosting service, you should be able to use a web interface such as phpMyAdmin to run this command.

That’s all it took to fix the problem for me.  Happy blogging!

Free Ebook Developers Developers Developers Developers

Posted July 9th, 2009 by derek   Development 2 Comments »

Content from Microsoft’s {You Shape} It campaign has been rolled up into the ebook Developers Developers Developers Developers.  Many of the contributors are Microsoft MVPs and/ Microsoft Regional Directors.

It’s a free download and released under a Creative Commons license so share share share!

http://devshaped.com/book

http://devshaped.com/files/developersdevelopers.pdf

In the book:

Working with Brownfield Code by Donald Belcham (Microsoft MVP)

Beyond C# and VB by Ted Neward (Microsoft MVP)

Remaining Valuable to Employers featuring Barry Gervin, Billy Hollis, Bruce Johnson, Scott Howlett, Adam Cogan, and Jonathan Zuck

All I Wanted Was My Data by Barry Gervin (Microsoft Regional Director and MVP)

Efficiency Upgrade by Derek Hatchard (Microsoft Regional Director and MVP)

Getting Started with Continuous Integration by Sondre Bjellås (Microsoft Regional Director and MVP)

On Strike at the Software Factory by Daniel Crenna (Microsoft MVP)

C# Features You Should Be Using by Ted Neward (Microsoft MVP)

Accelerate Your Coding with Code Snippets by Brian Noyes (Microsoft Regional Director and MVP)

Is Silverlight 2 Ready for Business Applications? by Jonas Follesø (Microsoft Regional Director and MVP)

Innovate with Silverlight 2 by Daniel Crenna (Microsoft MVP)

Real World WPF: Rich UI + HD by Gill Cleeren (Microsoft Regional Director and MVP)

Hidden Talents by Peter Jones

Creating Useful Installers with Custom Actions by Christian Jacob

Banking with XML by Peter Jones

Sending Email by Derek Hatchard (Microsoft Regional Director and MVP)

50 JavaScript Tools to Improve Workflow

Posted June 22nd, 2009 by derek   Development No Comments »

A great list of JavaScript tools and resources was recently posted over at Smashing Magazine:

http://www.smashingmagazine.com/2009/06/21/50-fresh-javascript-tools-that-will-improve-your-workflow/

The Difference Between Silverlight and WPF

Posted June 18th, 2009 by derek   Development No Comments »

WPF and Silverlight are both XAML based platforms but there are some important functionality and implementation differences between the two.

For the full scoop on the differences between WPF and Silverlight, download the whitepaper "Programmatic Differences Between Silverlight and WPF" written by the folks at Wintellect.

http://wpfslguidance.codeplex.com/

Funny Microsoft Support Call

Posted May 6th, 2009 by derek   Development No Comments »

<br/><a href="http://video.msn.com/video.aspx?vid=385cfae8-fe7f-4cdc-b61a-1f8e322b526a" target="_new" title="A Microsoft Support Callback">Video: A Microsoft Support Callback</a>

New Developer Comic - Enjoy

Posted April 22nd, 2009 by derek   Development No Comments »

Here’s the first in the series of comics about developers coming from Microsoft:

Build Better Forms (Please)

Posted April 21st, 2009 by derek   Development No Comments »

A simple challenge to all developers building user interfaces:  think for a moment before making a form overly complicated.  The form below is for reverse phone number lookups:

badform

This form contains three fields for what is basically one thing:  a telephone number.  There is some JavaScript in there that bounces focus from one field to the next as you type, which is convenient unless you need to go back to edit the last field.

You know what this form really does?  It offloads data formatting / parsing work to the end user.  It is trivial to write server code that extracts only the digits from a free form telephone field.  There is no good reason to make the user think this hard to enter a phone number.

If you build forms, especially web forms, you need to watch Luke Wroblewski’s session from MIX09.  Despite the unassuming title of "Web Form Design," the session contains a lot of tips about designing forms with users in mind:

http://videos.visitmix.com/MIX09/C17F

Luke’s guidance is infinitely more useful than this little rant of a post and is backed up by data.

Be More Productive: Code Snippets in Visual Studio

Posted February 24th, 2009 by derek   Development No Comments »

Want to be more productive as a developer? There’s some cool stuff you can do with code snippets in Visual Studio. Brian Noyes has a good overview on here, including some things I’m embarrassed to admit that I did not know.

If you’re interested in productivity, you might also be interested in the Visual Studio ASPX Edit Helper, a little tool a whipped up one afternoon and have never updated. :)  (Hey, the source code is there for download if you want to beef it up).

Working with Brownfield Code

Posted February 23rd, 2009 by derek   Development No Comments »

Donald Belcham has a great article and accompanying interview on "Brownfield Development" as part of Microsoft {You Shape} It:

http://devshaped.com/2009/01/working-with-brownfield-code/

http://devshaped.com/2009/01/donald-belcham-on-brownfield-development/

SourceForge Top 25 Favours Windows

Posted February 18th, 2009 by derek   Development No Comments »

This is interesting though not totally surprising:

[O]pen source software is not only available but also more popular on Windows. Note that of the top 25, there were 16 projects available only for Windows and none that were available only for Linux.

http://www.vinodunny.com/blog/post/OSS-for-Windows–SourceForge.aspx

This definitely matches my anecdotal experience. I have rarely looked for something on SourceForge that wasn’t available for Windows.

Comments RSS Login