Problem/Motivation

On a particular site, config whose original value has a line like

offset: 1

has been modified to instead look like

offset: !!float 1

When you run the config report, this config item shows up as changed (correct), but the diff shows up as empty (no differences, which is incorrect).

Proposed resolution

Figure out why the diff isn't working correctly and fix it.

Remaining tasks

TBD

User interface changes

Diff will work correctly.

API changes

Shouldn't be any.

Data model changes

I don't think so.

Original report...

The attached config is always displayed as changed.
I guess it is because the "!!float" marker.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Pasqualle created an issue. See original summary.

jhodgdon’s picture

That's interesting!

It doesn't look like well-formed YML actually. When I run it through this YML validator
http://www.yamllint.com/
it removes some of the code and I get

--- 
line_height: 1.5
offset: 2.0
unit: em

So that is probably the problem. I think the YAML needs to have the !!float 2 in quotes. I'm not sure what happens when it is read in via Drupal's YML parser?

Pasqualle’s picture

The config seems to work correctly with the ckeditorheight module.

jhodgdon’s picture

What does it look like if you export it -- does it export looking the same as the input YAML file?

Pasqualle’s picture

yes, actually the attached file was created from export

jhodgdon’s picture

OK, thanks for all the information! We'll need to investigate what is happening, look at the diffs that are reported by this module, etc.

Pasqualle’s picture

Tried to find another example for !!float. Found this on in core:
https://cgit.drupalcode.org/drupal/tree/core/modules/options/tests/optio...
but after importing this config, it does not show up as changed. Strange..

jhodgdon’s picture

The thing that looks possibly malformed to me is that there are spaces in the value, but it's not in quotes. I thought that YAML values with spaces in them needed quotes. Maybe not though.

Another thing you could do, since the module is reporting it is changed, is look at the differences the module reports.

jhodgdon’s picture

No, I'm wrong about that. The YAML specs
http://yaml.org/spec/1.2/spec.html
show that you can put scalars after : without quotes.

jhodgdon’s picture

Can you provide steps to reproduce in the issue summary -- in particular, which project/module/theme/etc. would I need to install to see this happening? Thanks!

Pasqualle’s picture

Ok, I have found the issue:
The CKEditorHeight module has its config without !!float.

So the original config is:

offset: 1

Config stored/exported as:

offset: !!float 1

Because of this the config file is listed on the Reports page, even the Config diff page shows no difference.

I guess the Reports page should not list such changed config. Or do you think the original config must be fixed (to include !!float)?

jhodgdon’s picture

Um. So it looks like the stored/exported config in your database is different from the config file in modules/CKEditorHeight/config/install, right? So it should be listed as different -- it sounds like the report is correct? But then you're saying that if you see it in the report and click to the diff, it shows no differences -- if that is true, it sounds like the bug is that no differences are reported?

Or did I misunderstand what you were saying in #11?

Pasqualle’s picture

yes, the only difference is the missing !!float and the diff does not catch that.

jhodgdon’s picture

Title: Config listed as changed » A particular config shows as changed but diff is empty
Issue summary: View changes

Well, that's very interesting. So what we really need to investigate is why that config is not caught by the diff code. Suspicious that the validator I pointed to in #2 also somehow fails to read the !!float...

Fixing issue title/summary.

jhodgdon’s picture

Issue summary: View changes
Status: Active » Needs review
Issue tags: +badcamp 2018
FileSize
858 bytes

I debugged this today, and learned that that !!float in YAML encoding just means that the YAML value is a float 2.0 number in the active config in this example, not an integer 2 number as in the module-provided config.

So, what's happening is that on the report page, the module and active config are marked as different, because it uses === to compare the config, and 2.0 float is not === 2 integer. So, that is the correct answer.

But when you click through to the diff listing, the code in ConfigDiffer.... What it does it (a) normalizes config (which is also done when doing a 'is this the same' comparison) and then (b) converts it to text and then (c) does a diff on the text. But in step (b), when it printed the values for each key, it was just printing the value however PHP would print it, instead of YAML encoding it, so it was printing out "2" (without quotes) for both integer and float, and thus it doesn't show any difference when comparing the text output in (c).

Hope that made sense...

Here's a patch that should fix it (which may clarify what is/was being done). Let's see what the tests say... We may have to adjust some of them for the slightly different formatting. As a note, the Yaml::encode() function handles NULL values, so I took out that elseif too.

Status: Needs review » Needs work

The last submitted patch, 15: 3002165.patch, failed testing. View results

Pasqualle’s picture

Issue summary: View changes

really excellent investigation!

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
1.44 KB

As I suspected might happen, we need a small test update, because we tested formatting and the output format changed a bit with this patch. Here's a new patch (interdiff is the Test part of the patch).

Status: Needs review » Needs work

The last submitted patch, 18: 3002165-with-test-update.patch, failed testing. View results

jhodgdon’s picture

Status: Needs work » Needs review
FileSize
1.68 KB

Well, that wasn't quite right! One more test fix, having to do with formatting our normalized config better...

jhodgdon’s picture

OK, the tests pass this time... Reviews, anyone?

Pasqualle’s picture

Status: Needs review » Reviewed & tested by the community

The problematic diff is now nicely displayed after applying this patch.

jhodgdon’s picture

Great, thanks for testing!

As this is changing the behavior of ConfigDiffer, and some other modules (Features?) use it, I'll leave this at RTBC for a week or so before committing, in case anyone wants to comment/test.

  • jhodgdon committed 91938e0 on 8.x-1.x
    Issue #3002165 by jhodgdon, Pasqualle: A particular config shows as...
jhodgdon’s picture

Status: Reviewed & tested by the community » Fixed

This has waited long enough. Thanks again for all the testing/collaboration on this! Committed.

Status: Fixed » Closed (fixed)

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