r91235 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r91234‎ | r91235 | r91236 >
Date:23:12, 30 June 2011
Author:yaron
Status:deferred
Tags:
Comment:
Follow-up to r91205 - code now checks for both esaped and unescaped versions of field names with apostrophes, because for some reason either one can happen in different circumstances. Also added Stephan Gambke, as an author.
Modified paths:
  • /trunk/extensions/SemanticForms/includes/SF_FormPrinter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/includes/SF_FormPrinter.php
@@ -7,6 +7,7 @@
88 * @author Jeffrey Stuckman
99 * @author Harold Solbrig
1010 * @author Daniel Hansch
 11+ * @author Stephan Gambke
1112 * @file
1213 * @ingroup SF
1314 */
@@ -785,12 +786,23 @@
786787 $field_args['show on select'] = $show_on_select;
787788 // Get the value from the request, if
788789 // it's there, and if it's not an array.
 790+ $escaped_field_name = str_replace( "'", "\'", $field_name );
789791 if ( isset( $template_instance_query_values ) &&
790 - $template_instance_query_values != null &&
791 - is_array( $template_instance_query_values ) &&
792 - array_key_exists( $field_name, $template_instance_query_values ) ) {
793 - $field_query_val = $template_instance_query_values[$field_name];
794 - if ( $form_submitted || ( ! is_null( $field_query_val ) && ! is_array( $field_query_val ) ) ) {
 792+ $template_instance_query_values != null &&
 793+ is_array( $template_instance_query_values ) ) {
 794+ // If the field name contains an
 795+ // apostrophe, the array sometimes
 796+ // has the apostrophe escaped, and
 797+ // sometimes not. For now, just check
 798+ // for both versions.
 799+ // @TODO - figure this out.
 800+ $field_query_val = null;
 801+ if ( array_key_exists( $escaped_field_name, $template_instance_query_values ) ) {
 802+ $field_query_val = $template_instance_query_values[$escaped_field_name];
 803+ } elseif ( array_key_exists( $field_name, $template_instance_query_values ) ) {
 804+ $field_query_val = $template_instance_query_values[$field_name];
 805+ }
 806+ if ( $form_submitted || ( ! empty( $field_query_val ) && ! is_array( $field_query_val ) ) ) {
795807 $cur_value = $field_query_val;
796808 }
797809 } else {

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r91205attempting bugfix (apostrophes in template parameters don't work)foxtrott19:39, 30 June 2011