So I’ve been working with the cjniche plugin. Overall, it’s a pretty good plugin, but I definitely have some issues with it. I noticed that a few of my requests were getting the dreaded PHP warning:
Warning: Invalid argument supplied for foreach() in /var/www/wouldnt/you/like/to/know/wp-content/ plugins/cjniche/cjniche.php on line 79
Want to see if it’s a wide spread problem on the interwebby? Check out this Google search on the topic.
The line number may vary with yours, I added some extra special customizations to the plugin. Googling around on this, I see constant references to this error relating to this plugin. I also see crazy recommendations like deactivating and reactivating the plugin. Reminds me of the ‘did you reboot your computer’ and if the answer it ‘yes’, you follow up with ‘how many times’. Odd how some things just go away. Well, I wasn’t buying it.
It is true if you add a space to the advertiserIds or dork up your CJ Key you’ll get the same error, but I was experiencing intermittent errors. It would work a few of the times, then not work the other times. That would have NOTHING to do with variable values stored in the database. I did some digging (which is hard with this particular plugin since they encode everything.. really?).Â I was able to get to the root of the problem.
If you’re getting this error every time, the plugin is not receiving a proper XML response CJ and that is why the foreach is blowing up. Unfortunately, the plugin is not checking for a good product set return from CJ and just explodes. Now, if you’re getting this error some of the times, the problem is very similar. I was able to echo the XML returning during a failure and this is what I saw:
[error-message] =>; The server is currently at capacity or down for maintenance. Please try again later.
Wow, now that helps shed some light on the problem for sure. Looks like CJ is having problems. This is my biggest irritation dealing with CJ’s datafeed. I’ve mentioned that in the past that it’s just not reliable. This plugin is nice for something quick and if you’re working with small data sets or small merchants, this probably works really well. If you’re dealing with larger product catalogs, the keyword filtering is obviously going to take longer and probably cause issues with many requests. Now this is an assumption. I’m not sure if yesterday and today are the only two days having problems.. who knows. What I wanted to do with this post was shed some light with the PHP error and this plugin. I definitely see mention of it in many places.
I’ve written some error handling in the plugin to catch vs. explode when this occurs, but I might need to work on a caching solution to fall back on a stored data set if it has trouble.
Leave a reply →