Simple Vocab stopped working

I am on version 2.2.2 and have installed the Simple Vocab plugin which has been working without issues. However, yesterday when I went to add an image, I got the error: Notice: Trying to get property of non-object in /home/mdharves/public_html/plugins/SimpleVocab/libraries/SimpleVocab/Controller/Plugin/SelectFilter.php on line 72
when I go to the Plugins tab, it says:

Simple Vocab
Version 2.0.1 by Roy Rosenzweig Center for History and New Media
A simple way to create controlled vocabularies.
Get support

This is not a valid plugin.

I have tried downloading the latest version and uploading it to the Plugin directory but I still have the same error.

The really strange thing is that the SimpleVocab does still work without issue. I can go there and add a controlled vocabulary and it works fine. It is when I try to add an Image that it gets unhappy.

I fixed the Plugin issue of saying not a valid plugin - it was from where I had another copy to try and figure out what was wrong with the error and didn't want to mess up any files.

However, I am still getting the error when I try to add an Image.

hmm...so far, I can't reproduce this, though I can see what might be happening in the code.

Which elements are you using Simple Vocab on, and from what element sets?

It's not too surprising that SimpleVocab is still working without issue. The Notice level of the warning is something that PHP is grumbling about, but generally doesn't directly cause a failure. In most production servers, PHP is set to just ignore Notices.

I have a controlled vocabulary on two elements: 1 in Dublin Core -> Type which has one entry Still Image and the other is a collection I created called Plants and it has 1 controlled vocabulary for Season of Spring, Summer, Fall, Winter

I tried removing all the controlled vocabulary entries but I still get the same error.

Even though it still allows me to go through the motions of Adding an Image the file is never actually uploaded.

The only additional thing that I did between when it was working the not working was install the DropBox plugin, not sure if that makes a difference.

Ah. I missed that the files weren't being uploaded.

It's possible that this is a conflict between SimpleVocab and Dropbox that we haven't seen before. Could try deactivating Dropbox to see if that fixes it, which might help us sort out what SimpleVocab complains about.

I'll try duplicating with a setup like yours

The files are uploaded - I must have done something stupid when I was testing it before that the image didn't get uploaded (I may have chose a file too large) but I just tested again (with Dropbox active) and the images do get uploaded. Sorry about that.

I deactivated Dropbox but the error still appears when I click the Add an Image button.

Still can't reproduce it so I haven't tested that this works, but making the following change _should_ work based on what you describe.

In the offending file, plugins/SimpleVocab/libraries/SimpleVocab/Controller/Plugin/SelectFilter.php go to line 72. It should look like:

add_filter(array('ElementInput', 'Item', $elementSet->name, $element->name),
                               array($this, 'filterElementInput'));

Change it so that it is inside this if-statement:

if ($element && $elementSet) {
       add_filter(array('ElementInput', 'Item', $elementSet->name, $element->name),
                  array($this, 'filterElementInput'));
}

Hope that does the trick.

It is the oddest thing, when I logged in this morning to take another look at the problem to see if I could figure it out, it was all working properly (no errors), even though nothing changed. I am not sure if it was some type of cache problem or what but I will your suggested fix, just in case the error appears again, I will add the if-statement and see if it fixes it. I am just not sure what went wrong the error disappeared just as quickly as it appeared. Thank you for all your work though.

Odd things do sometimes happen! Could be a change in server configuration behind the scenes, too.