[ic] [interchange] Fix for restrict_allow which was being clobbered by default values.

Sam Batschelet samb at endpoint.com
Mon May 9 13:01:08 UTC 2016

On 05/06/2016 05:23 PM, Mike Heins wrote:
> Quoting Jon Jensen (jon at endpoint.com):
>> On Fri, 6 May 2016, Mike Heins wrote:
>> It merges the two sets of restrict_allow values together.
> Hmm. I don't understand the comment then, "was being clobbered by
> default values". This more looks like a fix for the default values
> getting clobbered by the $opt, which I would think is the intention
> of the code.
> In other words, if you set it in $opt it should blow away what's in
> $record, as presumably your setting of the option should indicate that
> you know what's best. .

My understanding is $opt->{restrict_allow} was defined by the
o_default_defined hash or $CGI->{restrict_allow} values.  And as $opt
was always defined, if you set restrict_allow via meta_editor,
$record->{restrict_allow} would never be set by this line.

$opt->{restrict_allow} ||= $record->{restrict_allow};

So perhaps the word clobbered was dramatic, but you could not define
$opt even if it were only the default values with $record.  As Jon said
the patch takes the $opt values and merges them with $record.  This way
you can maintain defaults as well as possible input options.  Certainly
open to better way to handle this.  The commit message would read better
like such?

Fix for $record->{restrict_allow} which was being clobbered by $opt values.

abbreviated logic from how I read this.

my %o_default_defined = (
	mv_update_empty		=> 1,
	restrict_allow		=> 'page area var',

sub editor {
   display({restrict_allow => $opt->{restrict_allow}})

sub resolve_options {
    if ($opt->{cgi} && $CGI->{restrict_allow})
        $opt->{restrict_allow} = $CGI->{restrict_allow}

    # defaults only set if no value exists
    while( my ($k, $v) = each %o_default) {
        $opt->{$k} ||= $v;

sub display {
  # $opt->{restrict_allow} is defined or default now.
  # $record->{restrict_allow} from meta_editor

  # no dice for $record
  $opt->{restrict_allow} ||= $record->{restrict_allow};

Warm Regards,

Sam Batschelet
End Point Corporation

More information about the interchange-users mailing list