Uploaded image for project: 'Islandora'
  1. Islandora
  2. ISLANDORA-2105

If Default XSLT is enabled Forms can not be associated to CMODELS

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 7.x-1.9, 7.x-1.10
    • Fix Version/s: 7.x-1.10
    • Component/s: XML Form Builder
    • Labels:
      None

      Description

      If Default XSLT transformation is enabled, Forms can not longer be associated to CMODELS. The issue happens at
      https://github.com/Islandora/islandora_xml_forms/blame/7.x/builder/includes/associations.form.inc#L126
      Where the PHP Object that gets saved to DB has keys initialised that are not present in the submitted form when default XSLT is enabled in the Form builder. Since the default keys are intersected (instead of used as base keys) he resulting Object lacks the required fields by the MYSQL for that table making the SQL insert fail at https://github.com/Islandora/islandora_xml_forms/blame/7.x/builder/includes/associations.form.inc#L151) with a generic "Failed to add association".

      If, for debugging purpose, we add an $e->getMessage and /or an ::getTraceAsString() to the error object
      could be something like this
      at line 148

      try {
          dpm($object);
          db_insert('xml_form_builder_form_associations')
          ->fields($object)
          ->execute();
          drupal_set_message(t('Successfully added association.'));
        }
        catch (Exception $e) {
          drupal_set_message(t('Failed to add association. @error @trace',  array('@exception' => $e->getMessage(), '@trace' => $e->getTraceAsString())), 'error');
        }
      

      we get something like this.

       @error #0 /var/www/drupal/includes/database/database.inc(2227): PDOStatement->execute(Array) #1 /var/www/drupal/includes/database/database.inc(697): DatabaseStatementBase->execute(Array, Array) #2 /var/www/drupal/includes/database/mysql/query.inc(36): DatabaseConnection->query('INSERT INTO {xm...', Array, Array) #3 /var/www/drupal/sites/all/modules/islandora_xml_forms/builder/includes/associations.form.inc(152): InsertQuery_mysql->execute() #4 /var/www/drupal/includes/form.inc(1520): xml_form_builder_associations_form_submit(Array, Array) #5 /var/www/drupal/includes/form.inc(904): form_execute_handlers('submit', Array, Array) #6 /var/www/drupal/includes/form.inc(386): drupal_process_form('xml_form_builde...', Array, Array) #7 /var/www/drupal/includes/form.inc(131): drupal_build_form('xml_form_builde...', Array) #8 [internal function]: drupal_get_form('xml_form_builde...', 'FSU') #9 /var/www/drupal/includes/menu.inc(527): call_user_func_array('drupal_get_form', Array) #10 /var/www/drupal/index.php(21): menu_execute_active_handler() #11 {main}
      

      Also helps to do a dpm($object) just before the try{} logic to see the missing keys in the to be sql-inserted object

      Pingin Kim Pham as XML Forms release tester and Rosie Le Faive as co-manager to confirm this can replicated.

      This seems to be around for 4-5 years??

        Attachments

          Activity

            People

            • Assignee:
              dpinokrayon Diego Pino Navarro
              Reporter:
              dpinokrayon Diego Pino Navarro
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 day
                1d
                Remaining:
                Remaining Estimate - 1 day
                1d
                Logged:
                Time Spent - Not Specified
                Not Specified