Sherlock had it right

Once you eliminate the impossible, whatever remains, no matter how improbable, must be the truth.

Sherlock Holmes

Over the years I’ve learned it’s always my fault. If something isn’t doing what I expect it to, then I’ve messed up somewhere – so I look to my code, and the most recent changes, to see where the problem is.

This serves me well, but for once I wasted a lot of time because I simply couldn’t believe it wasn’t my fault. The obvious conclusion to my investigations was that the WordPress function do_action() was messing with the arguments it was being fed, specifically converting an array containing a single object into just the single object. But I thought it was just absurd that such a fundamental WP function could do something so bizarre, so I kept on going over my code. I should have remembered Sherlock, for in the end the answer was spelled out pretty clearly in the do_action() contributor notes. Yup, the function was doing exactly what I couldn’t believe it would, and it’s been a known bug for nearly 2 years.

via GIPHY

Leave a Reply

Your email address will not be published.