If you happen to have selected a given image for the OG image thumbnail, and then delete that image, OG Meta does not automatically purge that URL from its table. More than a small annoyance, this can cause subsequent node saves to mysteriously fail validation because the image loaded from the OG table does not exist in the set of options presented.

Here's a patch implementing the node_presave hook to harvest the images before saving, and compare to the values that OG Meta has stored. Because of the nature of the node object on save you generally won't get the full file object, but just a stub with the FID. For that reason the harvest_images method will load any files / fields where an FID is present, but a filemime is not, in an attempt to compare them properly.

I've included the code for the D6 version here as well, but have only tested in D7.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drakythe’s picture

Minor issue with this patch. It works fine on its own (in my admittedly minor testing) andopengraph_meta is fine. However when used in conjunction with Webform and the File upload field of Webform, you end up with this:

    Warning: array_flip() [function.array-flip]: Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 178 of C:\xampp\htdocs\opengraph\includes\entity.inc).
    Notice: Array to string conversion in DatabaseStatementBase->execute() (line 2139 of C:\xampp\htdocs\opengraph\includes\database\database.inc).
    Notice: Array to string conversion in DatabaseStatementBase->execute() (line 2139 of C:\xampp\htdocs\opengraph\includes\database\database.inc).
    Notice: Array to string conversion in DatabaseStatementBase->execute() (line 2139 of C:\xampp\htdocs\opengraph\includes\database\database.inc).
    Notice: Array to string conversion in DatabaseStatementBase->execute() (line 2139 of C:\xampp\htdocs\opengraph\includes\database\database.inc).
    PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined: SELECT base.fid AS fid, base.uid AS uid, base.filename AS filename, base.uri AS uri, base.filemime AS filemime, base.filesize AS filesize, base.status AS status, base.timestamp AS timestamp FROM {file_managed} base WHERE (base.fid IN (:db_condition_placeholder_0_#type, :db_condition_placeholder_0_#value, :db_condition_placeholder_0_#input, :db_condition_placeholder_0_#process, :db_condition_placeholder_0_#theme, :db_condition_placeholder_0_#defaults_loaded, :db_condition_placeholder_0_#tree, :db_condition_placeholder_0_#parents, :db_condition_placeholder_0_#array_parents, :db_condition_placeholder_0_#weight, :db_condition_placeholder_0_#processed, :db_condition_placeholder_0_#required, :db_condition_placeholder_0_#attributes, :db_condition_placeholder_0_#title_display, :db_condition_placeholder_0_#id, :db_condition_placeholder_0_#name, :db_condition_placeholder_0_#ajax_processed, :db_condition_placeholder_0_#sorted)) ; Array ( [:db_condition_placeholder_0_#type] => hidden [:db_condition_placeholder_0_#value] => 0 [:db_condition_placeholder_0_#input] => 1 [:db_condition_placeholder_0_#process] => Array ( [0] => ajax_process_form ) [:db_condition_placeholder_0_#theme] => hidden [:db_condition_placeholder_0_#defaults_loaded] => 1 [:db_condition_placeholder_0_#tree] => 1 [:db_condition_placeholder_0_#parents] => Array ( [0] => submitted [1] => file [2] => fid ) [:db_condition_placeholder_0_#array_parents] => Array ( [0] => submitted [1] => file [2] => fid ) [:db_condition_placeholder_0_#weight] => 0.002 [:db_condition_placeholder_0_#processed] => 1 [:db_condition_placeholder_0_#required] => [:db_condition_placeholder_0_#attributes] => Array ( ) [:db_condition_placeholder_0_#title_display] => before [:db_condition_placeholder_0_#id] => edit-submitted-file-fid [:db_condition_placeholder_0_#name] => submitted[file][fid] [:db_condition_placeholder_0_#ajax_processed] => [:db_condition_placeholder_0_#sorted] => 1 ) in DrupalDefaultEntityController->load() (line 196 of C:\xampp\htdocs\opengraph\includes\entity.inc).

This is fairly easy to replicate:

  1. Install Drupal
  2. Install Webform and Opengraph_meta
  3. patch Opengraph_meta
  4. Enable modules
  5. Create a webform with a file upload field
  6. Crash
DaneMacaulay’s picture

Status: Active » Reviewed & tested by the community

Tested and works as expected.
RTBC

DaneMacaulay’s picture

Issue summary: View changes

Updating grammar