New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Statamic adding strange character entries like 0: and 2: to arrays #1594

Closed
anthubbard opened this Issue Sep 13, 2017 · 9 comments

Comments

Projects
None yet
3 participants
@anthubbard

anthubbard commented Sep 13, 2017

Statamic is adding strange character entries in some really weird places in files. I have no idea how it is happening or at what point.

This happened to me - on an array on my index.md (homepage) this was added somehow by statamic (or at least I assume it was, I certainly didn't add it):

feature:
  2:
    file: /assets/images/pages/pexels-photo-261628.jpeg
    text: Contact Us to Book
    link: /contact

That array should be:

feature:
  -
    file: /assets/images/pages/pexels-... etc

I figured it was some random issue, or possibly that I'd somehow done it - but the same thing happened to beckysoll and with possibly worse consequences in her routes.yaml file so it probably is a real issue:

pasted image at 2017_09_12 04_36 pm

V 2.6.6

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Sep 20, 2017

Unfortunately I'm going to need to ask for more details. We'll need to know what caused it.
Seems like maybe there was a Javascript error on the page preventing the array from being properly re-keyed before submitting.

No idea on the route screenshot either. That field is basically just manual entry, even from the CP.

@anthubbard

This comment has been minimized.

anthubbard commented Sep 20, 2017

I know it is vague, but I have no idea how it happened or when or where or why. Sorry. I was just reporting that it happened and I wouldn't have even posted it if the same thing hadn't happened to Becky as well... maybe just leave/close it till someone else runs into the same thing or can actually recreate it.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Sep 22, 2017

Looks like Becky's issue was that there was a --- in her content, causing it to confuse where front matter starts and ends.

I don't know if you are running into a similar problem, @anthubbard

@beckysoll

This comment has been minimized.

beckysoll commented Sep 22, 2017

FWIW, that routes issue was way before the --- issue - for that, i entered the route correctly, saved it, went back later and that was there. Granted i could just think i typed it correctly, and mistyped something - but i'm 100% sure it looked right after i saved it, and didn't start with 0: until i went back in to look at it a few hours later to add another route.

@anthubbard

This comment has been minimized.

anthubbard commented Sep 26, 2017

Alright! I managed to recreate my issue (won't help Becky though) :)

I have a grid setup with another grid inside it:

  header_img:
    display: Heading Image or Slider
    instructions: To make this a slider click the toggle above and add multiple rows
    type: grid
    mode: stacked
    fields:
      img:
        display: Image / Slider File and Size
        type: grid
        min_rows: 1
        max_rows: 1
        fields:
          file:
            type: assets
            display: Image
            container: main
            folder: images
            max_files: 1
          text:
            display: Text Over Image / Slider (optional)
            type: textarea
            height: 100
          link:
            display: Image / Slider Link (optional)
            instructions: "FORMAT - Internal links:'/link' | External links:'http://www.site.com/link'"
            type: text

If I had some rows to the outside grid and add content somewhere in the grid inside them then save the page all is well. If I then add an outside grid but don't put content inside it and save, all is still well. BUT then if I move that outside grid that has no content on the inside grid anywhere up the row list of the outside grids, it changes the - of the grid numbering to a number 0: etc

So this:

header_img:
  - 
    img:
      - 
        text: test3
  - 
    img:
      - 
        text: Test
  - 
    img:
      - 
        text: test2

Becomes:

header_img:
  0:
    img:
      - 
        text: test3
  1:
    img:
      - 
        text: Test
  3:
    img:
      - 
        text: test2

Does that make sense?

PS I'm glad I'm not going crazy...

Ant

@anthubbard

This comment has been minimized.

anthubbard commented Oct 9, 2017

Hi @jasonvarga this is happening a fair bit now - if I have a grid with a couple of rows and delete the content inside the inside grid it then stuffs all the other rows and they don't display. Any word on bugfix?

Obviously there's a simple way around it - tell clients to ensure they have content in their inside grid fields and don't leave them empty (which makes sense anyway) - but that's not always easy in practice.

This is not urgent but would be good if fixed at some point. I hate having to tell clients 'be careful not do X cause it breaks the CMS'.

Cheers,

Ant

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Oct 9, 2017

Change statamic/bundles/Grid/GridFieldtype.php line 52 to return array_values($processed);

Let me know how that goes.

@jasonvarga

This comment has been minimized.

Member

jasonvarga commented Oct 9, 2017

With regards to @beckysoll 's issue:

If you - for whatever reason - have this in your YAML:

  /search:
    template: search
    title: search
  -
    template: tag

It would get re-saved as what was posted in the screenshot.

Maybe an accidental extra character got typed in somehow? Obviously there's no solution in this comment, but I'm just giving you some more info. Maybe it's helpful. ¯\_(ツ)_/¯

@anthubbard

This comment has been minimized.

anthubbard commented Oct 10, 2017

@jasonvarga Yeah that line 52 trick fixed it, thank you for looking into it 👍

@jasonvarga jasonvarga closed this Oct 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment