Template preprocess functions expect classes of the wrapper attributes to be an array.

Issue fork diff-3013553

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Jim.M created an issue. See original summary.

jim.m’s picture

Status: Active » Needs review
StatusFileSize
new3.67 KB

Attaching the patch.

Status: Needs review » Needs work

The last submitted patch, 2: diff-3013553-1.patch, failed testing. View results

jim.m’s picture

Status: Needs work » Needs review
StatusFileSize
new3.67 KB

Add missing newline to the end of patch, seems to fail without it.

Status: Needs review » Needs work

The last submitted patch, 4: diff-3013553-3.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

jim.m’s picture

Test failures are irrelevant to the patch and they actually fail without the patch too. Tested locally with both 8.6 and 8.7.x-dev Drupal core and it results in the same failures without the patch.

alan d.’s picture

Just running the tests against Drupal 8.5, albeit on 11 May 2018 dev past using D8.6 so something fishy could be going on.

alan d.’s picture

Status: Needs work » Reviewed & tested by the community

Looks good, even with the unrelated test failures.

UnifiedFieldsDiffLayout & SplitFieldsDiffLayout may have some issues, some of the codes a bit hard to follow and probably best dealt with separately. I guess this was tested manually, so assumable the inconsistency is handled in the code.

i.e. row class attributes are defined with both scalar and array, then copied into other table rows inconsistently.

      if (!empty($field['#name'])) {
        $field_label_row = [
          'data' => $field['#name'],
          'colspan' => 8,
          'class' => ['field-name'],
        ];
      }
      if (isset($field['#data']['#left_thumbnail'])) {
        $field_diff_rows['#thumbnail'][1] = [
          'data' => $field['#data']['#left_thumbnail'],
          'class' => '',
        ];
      }

// Usage

          // what I would expect to see...
          'right-row-data' => [
            'data' => isset($field_diff_rows[$key][3]['data']) ? $field_diff_rows[$key][3]['data'] : NULL,
            'class' => isset($field_diff_rows[$key][3]['data']) ? $field_diff_rows[$key][3]['class'] : NULL,
          ],
          // but this is common that looks like it would produce a nested array within the classes array??
          'right-row-sign' => [
            'data' => isset($field_diff_rows[$key][2]['data']) ? $field_diff_rows[$key][2]['data'] : NULL,
            'class' => [
              isset($field_diff_rows[$key][2]['class']) ? $field_diff_rows[$key][2]['class'] : NULL,
              // albeit, wtf?
              isset($field_diff_rows[$key][3]['data']) ? $field_diff_rows[$key][3]['class'] : NULL,
            ],
          ],

sasanikolic’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new7.98 KB
new3.67 KB

Here is an improved patch. I looked up for all class definitions in the module and replaced it with the new [] convention.

richardgaunt’s picture

Status: Needs review » Reviewed & tested by the community

Tested and reviewed - working.
The patch changes look reasonable and bringing the module into the convention that attribute class is an array rather than a string.

phenaproxima’s picture

I think my only worry here is that this will break custom code which expects the attributes to be strings, rather than arrays...am I overthinking it, or is that a reasonable concern?

richardgaunt’s picture

I think it's the vice versa, I came looking for and found this patch because it was breaking my custom code.

grimreaper’s picture

Hi,

Encountered a fatal error with #3367502: Fatal error when using the Diff module yesterday due to class attribute not being an array.

I will secure contrib theme but it would be good that this issue is fixed.

Thanks for the patches.

Berdir made their first commit to this issue’s fork.

berdir’s picture

Converted to an MR and rebased, this conflicted pretty heavily with a change that converted to short array syntax.

I slightly changed some of the ternary conditions, so that the fallback is an empty array and not an array with NULL.

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Looks like #2980335: Define CSS classes as an array missed some of these. Rebasing and running fresh pipelines.

acbramley’s picture

acbramley’s picture

  • acbramley committed 6af10c7e on 8.x-1.x authored by Berdir
    Issue #3013553 by Jim.M, Berdir, sasanikolic, acbramley, Alan D.,...

  • acbramley committed e51a5620 on 2.x authored by Berdir
    Issue #3013553 by Jim.M, Berdir, sasanikolic, acbramley, Alan D.,...
acbramley’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.