[KyOSS Discuss] Hoping to get some help with a git patch

Chris Rockwell chris at chrisrockwell.com
Tue Nov 5 15:01:59 EST 2013


I'm trying to backport a patch from Drupal 8 to 7 and having issues with
one hunk, can someone shed some light on this for me? My first attempt was
to change the line number from 1730 to 1820 and 1737 to 1827 , which is
where "function _form_test_checkboxes_zero_no_redirect(..)" is in Drupal 7,
no dice though.  I'm confused by the error as it is "error: while searching
for", when that function definition, exactly the same, exists.  BTW: I know
that I can add the function in, git diff, change the patch, and do a pull
request, but I'd like to also know why it's doing this.

The error:
================================================================
error: while searching for:
function _form_test_checkboxes_zero_no_redirect($form, &$form_state) {
  $form_state['redirect'] = FALSE;
}

error: patch failed: modules/simpletest/tests/form_test.module:1730
error: modules/simpletest/tests/form_test.module: patch does not apply
=================================================================

The relevant portion of patch

=================================================================================
@@ -1730,3 +1737,18 @@ function form_test_checkboxes_zero($form,
&$form_state, $json = TRUE) {
 function _form_test_checkboxes_zero_no_redirect($form, &$form_state) {
   $form_state['redirect'] = FALSE;
 }
+
+/**
+ * Builds a form to test the required attribute.
+ */
+function form_test_required_attribute($form, &$form_state) {
+  foreach (array('textfield', 'textarea', 'password') as $type) {
+    $form[$type] = array(
+      '#type' => $type,
+      '#required' => TRUE,
+      '#title' => $type,
+    );
+  }
+
+  return $form;
+}
==================================================================================


The code in Drupal 7, starting at line #1792


==================================================================================
function form_test_checkboxes_zero($form, &$form_state, $json = TRUE) {
  $form['checkbox_off'] = array(
    '#type' => 'checkboxes',
    '#options' => array('foo', 'bar', 'baz'),
  );
  $form['checkbox_zero_default'] = array(
    '#type' => 'checkboxes',
    '#options' => array('foo', 'bar', 'baz'),
    '#default_value' => array(0),
  );
  $form['checkbox_string_zero_default'] = array(
    '#type' => 'checkboxes',
    '#options' => array('foo', 'bar', 'baz'),
    '#default_value' => array('0'),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Save',
  );
  if ($json) {
    $form['#submit'][] = '_form_test_checkbox_submit';
  }
  else {
    $form['#submit'][] = '_form_test_checkboxes_zero_no_redirect';
  }
  return $form;
}

function _form_test_checkboxes_zero_no_redirect($form, &$form_state) {
//[NOTE ADDED: this is line 1820)
  $form_state['redirect'] = FALSE;
}

==================================================================================


-- 
Chris Rockwell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://kyoss.org/pipermail/kyoss-discuss/attachments/20131105/1af0cf34/attachment.html>


More information about the KyOSS-Discuss mailing list