I entered a recipe & viewed it.
I clicked on the "MasterCook4" export link, then clicked "back" to return to the recipe view.
When I clicked on the "Recipes" link in the Navigation block, a series of warnings appeared:
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
- Notice: Trying to get property of non-object in merge_template() (line 104 of /var/www/drupal002/sites/all/modules/recipe/includes/recipe_mastercook4.module).
There are 11 warnings above and 11 ingredients in my recipe.
Something similar happens with both the "Plain Text" and "recipeML" export links as well.
Comments
Comment #1
dcam commentedI was able to replicate the bug. It occurs when trying to export a recipe in any of the three mentioned formats when an ingredient has no quantity unit.
The problem is two-fold. It occurs where the export pages try to determine whether to print out the unit abbreviation or the full unit name. The reported bug is caused when the ingredient variable is checked as a stdClass object, when it's actually an array. There's another problem though. This code is expecting the abbreviation to already be set, as it is in theme_recipe_ingredients() in recipe.module.
The problem code:
Proposed solution:
Patch is attached.
Comment #2
jvandervort commentedSide question, how are you getting a recipe without a quantity unit? Bulk import? The single recipe edit screen won't allow a blank unit.
Comment #3
jvandervort commentedThanks for the debugging help, committed fix to dev.
Comment #4
dcam commentedI left the units as the default blank option. It gets saved as an empty string in the database.