Welcome to my blog
As I discover new things in my field and solve troublesome problems, I will attempt to document my finds here.
As I discover new things in my field and solve troublesome problems, I will attempt to document my finds here.
As I discover new things in my field and solve troublesome problems, I will attempt to document my finds here.
Providing custom web application and web service API development with hourly bill rates, or fixed project estimates. Solutions are developed using flexible, tested tools, and scalable platforms to best meet defined requirements. Specializing is back-end, secure, web interfaces for small to high loads based on horizontally scalable architectures.
For details on my preferred choice of software, tools, and supporting services, see my description of my web application stack.
Today, on a production system errors started arising from a Django based application that made use of PostGIS features. All SQL queries that included any geo data were failing. This was on PostgreSQL 9.6 on Centos 7.
I was recently working on an website using an abandoned plugin whose functionality I needed. I noticed however, that all rewritten URLs defined by the plugin return HTTP 200
regardless of if the references resource existed. I tracked the issue down to the code in the parse_request
action handler doing nothing after failing to find the resource. So it needed to trigger/raise the 404 status, and to do so was as simple as setting $query->query_vars['error'] = '404';
. See an example snippet bellow.
add_action( 'parse_request', 'custom_parse_request' ); function custom_parse_request( $query ) { $query_item_exists = false; // implement code to lookup item based on query if ( $query_item_exists ) { // handle changes to query } else { // trigger 404 response $query->query_vars['error'] = '404'; } }
After this change, WordPress correctly returned HTTP 404
when the resource did not exist, and the 404.php
was correctly used.