For the past couple of days I have continued to look at the problem I wrote about with Google Forms and Checkboxes with PHP 5.4 and PHP 5.5. It turns out, that it really isn’t PHP version related, at least I don’t think so. It is WordPress related as near as I can tell.
As I’ve written before, I love VMware Workstation as it allows you to create virtual machines for very specific purposes, use them as long as needed, then put them away until needed again.
I created an Unbuntu VM to play with Ruby on Rails a couple months ago so I decided to check what version of PHP it had running. Lo and behold, it had PHP 5.5.x running so it was a good platform to further test potential solutions for my checkbox problem. My Windows environment is running PHP 5.3.3 and is still running WordPress 3.6.1 (don’t ask why but it proved to be very useful that it was).
I quickly set up WordPress 3.8 on Ubuntu and sure enough, submitting the form failed. The exact same plugin code on my Windows VM submitted correctly. I continued to dig through my code and eventually into WordPress itself trying to see what was different.
I eventually started looking at the source to wp_remote_post() and decided to identify which transport was being used. On Windows WordPress was using cURL but on Ubuntu it was using Streams. Ah-ha. Since the WordPress HTTP API abstracts the details of the transports away from the application, it shouldn’t matter but it seems to. I continued digging.
Using an advanced feature of WordPress Google Form to control transports, I disabled the cURL transport on the Windows machine and much to my surprise, the form still submitted correctly. Now this is odd. So I then installed cURL on Ubuntu and the form submitted correctly. The good news is there at least appears to be a solution although I’d prefer to not have cURL be a requirement.
Now what was different? I started looking into WordPress’ class-http.php file (which defines the WP_Http class) and noticed that the file on Windows was very different than the file on Ubuntu. Looks like something changed between 3.6.1 and 3.8.1.
I decided to download the 3.6.1 and 3.7.1 releases from the WordPress archive and do some tests on Ubuntu where it is trivial to switch between WordPress releases.
To add a little more information, I did some testing with older versions of WordPress in combination with the http_api_transports to force a specific transport (‘streams’, ‘fsockopen’, and ‘curl’). I found the following results:
|WordPress 3.6.1||WordPress 3.7.1||WordPress 3.8.1|
Something clearly changed with the streams and fsockopen transports between 3.6.1 and 3.7.1. A diff of the class-http.php file shows the change was substantial as the files are significantly different.
At this point I have concluded that my plugin will only work with sites where cURL is available. I will probably release a version which displays a warning on the Dashboard if cURL is not available and that usage of the plugin is not recommended.