Hi, I noticed I got a couple of notices after upgrading through drush:

Notice: Undefined variable: term_id in media_browser_plus_get_media_root_folder() (line 1500 of  */contrib/media_browser_plus/media_browser_plus.module).
Notice: Trying to get property of non-object in media_browser_plus_field_attach_presave() (line 1386 of  */contrib/media_browser_plus/media_browser_plus.module).

Running 7.15, and the error is only on the 2.x-dev branch.

Comments

das-peter’s picture

Status: Active » Fixed

The code definitely has a flaw - but I'm not sure of more debugging is necessary to check what actually causes the notice in the drush case. Would be nice to know if there was any other negative effect besides the notice.
However, I've changed the code to be "fault tolerant": http://drupalcode.org/project/media_browser_plus.git/commit/3d5e432

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

pdcarto’s picture

Status: Closed (fixed) » Active

I was still seeing the problem - numerous errors following feed import.

I was able to make it go away by setting $autocreate to TRUE in the call to media_browser_plus_get_media_root_folder() on line 1449 of media_browser_plus.module:
$root = media_browser_plus_get_media_root_folder(TRUE);

Not sure if that's totally inappropriate!

das-peter’s picture

Well, if you call media_browser_plus_get_media_root_folder() with $autocreate = TRUE it's likely that every time creates a new taxonomy term in the related vocabulary.
That's not really the idea.
For me it sounds like an issue with the installation. The vocabulary or the root term couldn't be create and now every time someone uses media browser plus it fails.
The reason the error persists even with $autocreate = TRUE is that the user maybe doesn't have the permission to create taxonomy terms.
So if someone is still experiencing this issue it would be great if this scenario could be considered.

Kimitri’s picture

This issue still exists in the latest dev. I'm seeing some problems in media_browser_plus_field_attach_presave:

$root = media_browser_plus_get_media_root_folder();
$entity->field_folder = array();
$entity->field_folder[LANGUAGE_NONE] = array(array('tid' => $root->tid));

The problem is that when the media_browser_plus_get_media_root_folder is called without passing the autocreate parameter as TRUE, the root folder may not exist and the return value will not be an object. The media_browser_plus_get_media_root_folder function checks if the media root folder exists in which case it will not create a new one. So, passing TRUE to this function will fix things.

However, I don't think this is the way to go. To me it would be a better way to make the hook_field_attach_presave check if the $root is an object and that it has a property called tid instead of just assuming that things are that way.

mr.baileys’s picture

Issue summary: View changes
Status: Active » Closed (duplicate)

@Kimitri: I think this should have resolved by #1968690: Unable to load the media root folder term. Could you check? If the problem persists, please reopen this issue.