Page MenuHomePhabricator

Two fields having a common part in the name result in a breakage of the definition and the autocomplete of the form
Closed, ResolvedPublic


Author: icarnevale

Given two wiki property pages called "Calls Service" and "Calls service version", both property are property of the instance page "Service",
therefore used in "Template:Service" and "Form:Service" pages.

Here's the text of the Template Text.

Template text:
{| class="wikitable"
!Calls Service

{{#arraymap:{{{field_Calls Service}}};wk_template_var[[Calls Service::wk_template_var]]}}

!Calls service version

{{#arraymap:{{{field_Calls service version}}};wk_template_var[[Calls service version::wk_template_var]]}}

Depending on the order of these fields definition in the template page, two different use cases occur:

  1. If "Calls Service" preceeds "Calls service version", there are no problems, because the parsing function scans sequentially the template text for the first name page,

then for the second page name without hiccups.

  1. If the order of field definitions are inverted with "Calls service version" before "Calls Service", the parsing function scans successfully the first page name, but

the second page name is obfuscated by the first one, and it is systematically ignored, since its character string is 'already' contained in the first one.

The technical reason resides in the function "handlePropertySettingInTemplate()" in "includes/SF_TemplateInForm.php":

$cur_pos = stripos( $templateText, $fieldName );
$templateFields[$cur_pos] = $templateField;

It searches the string position of the field name in the template text, placing the result in an array with the position as key.

A possible workaround solution is to restrict the search for the full fieldName until the '|' character:

$cur_pos = stripos( $templateText, $fieldName.'|' );
$templateFields[$cur_pos] = $templateField;

A better solution may involve a regexp.

Version: unspecified
Severity: normal



Event Timeline

bzimport raised the priority of this task from to Needs Triage.
bzimport set Reference to bz36016.
bzimport created this task.Apr 16 2012, 2:29 PM

Thanks for the suggested fix - before I look into this, I should just note that, if SF every messes up on parsing the template, you can hardcode the relationship between the form input and the property by adding the "property=" parameter to the {{{field}}} tag. So while this bug (and similar ones) are annoying, I wouldn't put them at the level of "critical".

Changing severity from "Critical" to "Normal", based on my comment.

Change 121112 had a related patch set uploaded by Jatin:
Two fields having a common part in the name result in a breakage

Change 121112 merged by jenkins-bot:
Two fields having a common part in the name result in a breakage

This is now finally fixed, thanks to Jatin Mehta adding in the suggested patch. Sorry that it took two years to add in essentially a one-character fix. :(