gerhard / glz_custom_fields_public

glz_custom_fields contributors can raise bugs here and vote for features
16 stars 2 forks source link

Use include_once instead of include.for custom scripts #24

Closed maniqui closed 13 years ago

maniqui commented 13 years ago

Hi Gerhard

A fatal error was raised whenever I set the value for two different custom field (type = custom script) to the same path (ie. the same script). I've changed include to include_once glz_custom_script function, and it seems that fixed it. Of course, I don't know if this has any further implication (I hope not!). Here is the full function:

function glz_custom_script($script, $custom, $custom_id, $custom_value) {
  if ( is_file($script) ) {
    include_once($script);
    $custom_function = basename($script, ".php");
    if ( is_callable($custom_function) ) {
      return call_user_func_array($custom_function, array($custom, $custom_id, $custom_value));
    }
    else
      return glz_custom_fields_gTxt('not_callable', array('{function}' => $custom_function, '{file}' => $script));
  }
  else
    return glz_custom_fields_gTxt('not_found', array('{file}' => $script));
}

Hope this helps. Thanks.

gerhard commented 13 years ago

Thanks maniqui for this! As a matter of fact, the v1.2.4 already contains this, it was the most minor fix and it didn't feel like a version bump. Re-downloading the plugin will solve this problem ; ).

maniqui commented 13 years ago

Gerhard, thanks for the prompt reply.

I'm using v1.2.4, but as you notice, I may have a version without the fix. I've tried to download the latest v1.2.4 from link on Google Group, but it seems the link is broken. Could you, please, confirm?

maniqui commented 13 years ago

Hi Gerhard,

I've downloaded latest version (the one you sent by email a few days ago, with some fixes related to styling issues on labels for checkboxes/radios), but this issue seems to still be present there. It still uses "include" instead of "include_once", so it still triggers the fatal error.