I’m not an elegant programmer. My stuff is verbose and rarely, if ever “refactored” (meaning I know it’s a term but fuzzy on the meaning).

What follows is a recap of my wandering path in trying to fix someone else’s WordPress plugin. There may be PHP spilling on the screen. You’ve been warned.

This all began because this blog and the multi-site one for Networked Narratives have been really S-L-O-W (cut to chase, the problem was actually with my shared server; Tim Owens did some magic to spiff it up. If your sites are not on Reclaim Hosting, well, no comment beyond Pffffft) .

Things I checked included:

  • Looking for un-needed plugins to remove
  • Optimizing database tables with overhead
  • Installing WordFence to scan for troublesome stuff; found none, un-installed (I’ve been told it is a resource hog)

Then I waded into error logs, specifically the error_log file that sits at the domain root directory (the one on cogdogblog has been piling up since 2013 and weighs in at 340 Mb, I need some error log rotation strategy).

But this I found in rafts of these on the recent lines the agranee.world error log.

Fatal errors cannot be good, right? With some sifting, I see it’s generated in line 342 of the plugin for FWP–SIC–Em. Lovely eh? But I know what it is- its actually a plugin to the Feed WordPress plugin. Feed WordPress is the long standing power behind creating syndication hub sites using RSS to bring in content from different blogs.

I use it sparingly on my home blog to pull in posts I write on my other sites. But it’s the engine for NetNarr’s hub of community written posts from individual blogs.

The FWP–SIC–Em is written by the same person that created Feed WordPress; it’s role is to create a featured image from a syndicated post (usually the first image found) since featured images are not a standard piece of data in an RSS feed. It’s been an elusive goal to find a reliable plugin that does this job well, I seem to have to swap every few years.

I first made sure I had the latest versions of both plugins (check, neither has been updated recently).

Now I think, what if I spend 45 minutes trying to hammer this out? Here is the lines leading up to 342:

The error is suggestion that the object $source is not connecting to a function named setting(). Where does $source come from?

I use by friend BBEdit to search the entire plugin directory for a function name get_syndication_feed_object() and come up empty. I am stumped.

But the answer is the conditional above, testing for existing of a function named is_syndicated(). I’ve used this before, it’s a way to make sure the Feed WordPress plugin is activated, since that’s a function in that plugin. And searching there I do find the function.

Not only that I see how the author uses it elsewhere in the Feed WordPress plugin:

So it seems to make sense to check if something return passes the is_object() test before referencing it. I create a test version of the Feed–SIC-Em plugin and wrap this function around the code near line 342:

I test on my local environment to make sure there are no typos. Then I install it on my arganee.world site. I run the Feed WordPress update a few times, and then run over to the error log. I’m not seeing the error messages anymore!

So I can fix this on my own sites, but shouldn’t the code owner know? I check the Issues area for FWP—SIC-Em and see the last one submitted in 2017 (I see 2 of my own in 2016). None of them have a response from the developer.

Sigh.

Oh well, I’d want to know, so I entered a new issue.

I decided to try submitting my code as a fix, to put in a “pull” request. This makes a copy of the plugin code on my site, where I can make changes. I sort of half messed this up. I did a “pull” but forgot to do a proper commit. How do I know?

Ken Bauer.

Here’s where my GitHub ignorance shows. What the heck is Ken up to?

Hah, he sure picked a weak example to show his class. But I went in to my fork, and submitted it officially to the main plugin.

My GitHubbing is done for the day. Maybe for naught if the developer never responds. But at least I think I found a fix. With a hammer.


Featured Image: Two Pixabay images edited together! Hammer image by Rauschenberger and code image by lmonk72 both shared into the public domain using Creative Commons CC0.

wood handled hammer held over a screen of computer code
If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Profile Picture for Alan Levine aka CogDog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.

Comments

  1. Not for naught. Now I can use your version of this plugin for my own classes, that is the beauty of forking and part of the software engineering process that I communicate to my students.

    This also demonstrates once again The Power of Open!

    Yay team. You rock Alan and we truly appreciate when you pull out the coding hammer.

Leave a Reply

Your email address will not be published. Required fields are marked *