Skip to content
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

Field layout changes not applying properly across environments #5952

Closed
chrisleversuch opened this issue Apr 21, 2020 · 5 comments
Closed

Field layout changes not applying properly across environments #5952

chrisleversuch opened this issue Apr 21, 2020 · 5 comments

Comments

@chrisleversuch
Copy link

Description

I added an existing field to an existing entry type and everything seemed fine (UI and project.yaml as expected). But after pushing the changes to my staging environment, I couldn't see the field when creating a new entry. In the same commit I modified a matrix field (adding 1 item, removing another) and that worked fine. This is the first time I've changed a field layout since upgrading from 3.4.12.

I tried clearing caches (through admin and CLI) and running ./craft project-config/sync but no change. Also tried ./craft project-config/rebuild and pushing to staging but no change.

I took a db dump from staging and loaded it locally - this resulted in the field no longer appearing on the new entry page. When I looked at the field layout the field wasn't shown even though it's in the project.yaml file. I then edited the layout and re-added the field and the new entry screen started working again - the only change to project.yaml was an updated dateModified. I also tried restoring the database again and saving the layout without re-adding the field - this resulted in the field being removed from the project.yaml.

Github suggested #4231 as a similar issue - I can't run ./craft project-config/sync --force=1 on my staging environment as it's read-only but running it locally made some changes (I ran it 5 times and it kept making more changes to the project.yaml). This didn't fix the staging environment though.

Steps to reproduce

  1. Edit entry type and add field to layout
  2. Push changes to a different environment
  3. Sync changes
  4. Notice field isn't visible in UI

Additional info

  • Craft version: Initially 3.4.15, then upgraded to 3.4.16
  • PHP version: 7.4.4 (dev), 7.4.2 (staging)
  • Database driver & version: MySQL 5.5.5
  • Plugins & versions:
    • Embedded Assets 2.2.1
    • Feed Me 4.2.2
    • Freeform 3.6.7
    • Imager v2.4.0
    • Inventory 2.1.0
    • Redactor 2.6.1
    • Retour 3.1.37
    • SEOmatic 3.2.51
    • XML Sitemap 1.2.0
@andris-sevcenko
Copy link
Contributor

@chrisleversuch That's odd. Can you, please, get in touch via support@craftcms.com? If possible, send over a DB dump of the staging site, the composer.lock file, the composer.json file, and the project.yaml file that's causing you problems.

Running ./craft project-config/sync --force=1 should not be modifying your project.yaml file, so that's something we definitely want to look into.

@chrisleversuch
Copy link
Author

@andris-sevcenko I've sent those over.

@timmyomahony
Copy link

timmyomahony commented Apr 23, 2020

I think I'm experiencing the same issue. Another dev on our team added a global set and pushed the changes to the staging server. Both his env and the staging env both have the global set.

I pulled down those changes (which I can see are present in the project.yaml) but they haven't been applied to my local project after performing:

./craft migrate/all
./craft project-config/sync
./craft clear-caches/all

When I visit a page that relies on those globals I get a twig error

Variable "foo" does not exist.

I've dumped the database from staging to my local machine and used ./craft restore/db to restore, but the problem persists locally.

I tried running ./craft project-config/sync --force=1 but get the error:

Applying changes from project.yaml ... error: Trying to get property 'trashed' of non-object

Here's the strangest part, when I restore via a pgsql -U user -d database < ~/dump.sql everything works again (including the project-sync command).

These are the exact same database dumps I'm using, but it only works when I restore manually as opposed to via the command.

I have a feeling there might be 2 separate issues at play here:

  1. Fields not getting created correctly from project.yaml
  2. Database restore not functioning correctly

Edit: It turns out the manual restore only fixed one of the missing fields. I noticed that a different entry was missing another field from the interface (again, that field is in the DB and in the project.yaml and visible in the entry's entry type page). I tried clearning the caches and it didn't help.

Running ./craft project-config/sync --force=1 fixed the issue this time.

@andris-sevcenko
Copy link
Contributor

@timmyomahony that doesn't seem to be the same issue. Can you, please, create a new issue and add the version of Craft you're using?

@chrisleversuch
Copy link
Author

Clearing caches (empty the storage/runtime/cache folder) and then running ./craft project-config/sync --force has fixed the issue. This time I didn't get an error on staging about needing to write the project.yaml, I guess because I cleared cached immediately before running the command whereas previously I'd viewed the control panel between the 2 steps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants