This code spits out errors on cron runs due to abuse of t().

function salesforce_api_object_to_fieldmap_fields($object)  {
  $fieldmap_object = array(
    'label' => t($object->label),
    'fields' => array()
  );

There's no reason to use t() here at all as nothing is available to translate. Attached patches for 7.x-2.x and 6.x-2.x remove it.

CommentFileSizeAuthor
rmt-6.x-2.x.patch528 bytesSborsody
rmt-7.x-2.x.patch528 bytesSborsody

Comments

EvanDonovan’s picture

If I'm understanding correctly, this is not translatable since it is a variable. Makes sense to remove the use of t() then.

EvanDonovan’s picture

Status: Active » Needs review
kostajh’s picture

@Sborsody: Thanks for the patch, that makes sense. Can you let me know what errors you get on cron run?

Does $object->label need to be passed through check_plain()?

Sborsody’s picture

Hi,
The error was:

warning: strtr() [function.strtr]: The second argument is not an array in ..../includes/common.inc on line 945.

This was followed by about 5 copies of:

warning: Invalid argument supplied for foreach() in .../sites/all/modules/salesforce/salesforce_api/salesforce_api.module on line 833.

This was appearing on a site running the 6.x-2.x-alpha2 release. I don't have the actual data that $object->label contained, unfortunately. Theoretically it is an xsd:string label sanitized by SF *shrug*. I was thinking too of a check_plain call here, but, and correct me if I'm wrong, the code in question appears to be preparing data to be stored. The check functions are supposed to be used on output/display.

kostajh’s picture

Status: Needs review » Patch (to be ported)

This is committed to 6.x-2.x-dev, thanks! http://drupalcode.org/project/salesforce.git/commit/8a5b16f

EvanDonovan’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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