Quietly and without interruption this week, our whole website moved from a single static server to a load-balanced multi-server environment, giving us even more horsepower and redundancy than before. More
ProcessWire 3.0.131 contains 20 commits with various updates and we’ll cover the most interesting ones here.
WireHttp and support for partial downloads
The WireHttp class had its
sendFile() method updated so that it can now support partial downloads. More specifically, it supports HTTP_RANGE requests, which is what the browser sends to the server to request a byte range from a given file. This can come into play for a lot of different things, like pausing and resuming of downloads, but a very common use case is streaming assets like audios and videos. In fact, it appears that Safari (in particular on iOS devices) won’t play audio or video files without it. Other browers (like Chrome) also appear to take advantage of it when the server indicates support is there.
A client came to me this week looking to deliver audio downloads to customers and these downloads are protected by authentication (and a Stripe transaction). I installed the download capability (using the WireHttp::sendFile method), and it worked great for everyone except the iPhone/iPad users, and they couldn’t get anything. In researching further, I learned there’s no such thing as file downloads in iOS—you have to install files through iTunes on your computer. This came as a big surprise to me, as it seems like a major limitation (I’m an Android user, so would have never guessed you can’t download files to your phone). But it's not an oversight on Apple's part. I think it's instead equal parts of: 1) locking down security, and; 2) maintaining control of asset delivery for profit.
Not all people with iOS devices have computers they are syncing with, so they are left without any ability to download files from the web to their phone. Without the ability to deliver an audio download, we had to figure out how to let them stream it instead. Luckily those iOS devices can stream what they can’t download, but only if you handle their HTTP_RANGE requests. So that’s why WireHttp got partial download support. Now everything is working smoothly with this client and delivery of their downloads.
You don't have to do anything to enable partial download support, as WireHttp::sendFile() now broadcasts to the client that it supports it, and the client browser will take advantage of it when/if appropriate. But if you want to disable it, you can do so with the 'partial' option set to boolean false with the $options argument.
Improvements to the comments Fieldtype and manager
I'm not sure how many of you use ProcessWire's comments features (questions don't often come up), but I personally use them quite a lot, so try and make sure they are working well. This week, the comments Fieldtype and the comments manager received several updates. In the case of the comments manager (ProcessCommentsManager), it was primary updated to look a lot better in the UIkit admin theme.
FieldtypeComments now supports a new “featured” comment status. We’re not using it for anything specifically in the core, but you may find it useful for cases where you are using comments and want to feature certain comments, perhaps to display above others, or highlight in some other fashion. I will likely be updating our default output functions to utilize the featured status in the near future.
FieldtypeComments also got a new
count() method to accompany its existing
find() method. This simply counts the number of comments that match your selector string.
Lastly, the CommentFilterAkismet module was also refactored and improved in several ways. We make use of this module quite a bit here at processwire.com, as we’re getting hundreds of spam comments submitted every day, but Akismet catches them all, so I never even know about it unless I go in and look at the logs.
New $config->sessionForceIP setting
This new setting lets you tell ProcessWire that it shouldn’t use what’s in the $_SERVER[‘REMOTE_ADDR’] to determing the client's IP address, and should instead use the IP address that you give it with this setting. This comes in handy on our new load balancer setup because $_SERVER[‘REMOTE_ADDR’] represents one of 4 load balancer IP addresses rather than the client’s IP address. So we resolve this by adding the following to our /site/config.php file:
$config->sessionForceIP = $_SERVER['HTTP_X_FORWARDED_FOR'];
This is important for things like session fingerprinting, spam filters (like Akismet, mentioned above), logs, and anything else that might consider the client IP address during the request. While it’s a must-have in a load balancer setup like here, it can also be useful for other cases like proxy server setups.
Pro module updates
In case you missed it, last week I posted a brief update in the forums which outlined an update soon coming to FormBuilder: Stripe transaction support. In addition to that, I'm also currently researching the ability to have FormBuilder save submitted form entries into Google Sheets. The ProFields module, RepeaterMatrix also has a major update in progress, and I'll tell you more about that in an upcoming post. Actually, all of the Pro modules have updates in progress, but those mentioned here are the ones that are likely to receive updates this month.
In addition to all of the above, ProcessWire 3.0.131 also contains 10 additional commits focused on resolving issue reports. This process is ongoing. Next week I’m hoping to get into the new PR that Horst recently submitted, adding webp image support to ProcessWire, which sounds amazing. That’s all for this week, I hope that you all have a great weekend. As always, read the ProcessWire Weekly for the latest ProcessWire-related news and updates.
In this week’s post we’ll shift focus a bit and take a look at the latest version of FormBuilder (v38) just released today. It ends up being a fairly major release with a lot of new additions, optimizations and updates. This version of FormBuilder (https://processwire.com/store/form-builder/) is… More