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

Empty Flexible content #475

Closed
Senexis opened this issue Jul 7, 2023 · 6 comments
Closed

Empty Flexible content #475

Senexis opened this issue Jul 7, 2023 · 6 comments

Comments

@Senexis
Copy link

Senexis commented Jul 7, 2023

Currently, when viewing pages, the flexible content is empty.

Details

It seems to be caused by the recent changes for compatiblity with Nova 4.26, but I never had any issues in the first place with it, and now that a call to is_a() is replaced from \stdClass to Fluent, the detection for \stdClass instances is broken.

I don't quite know how or why I don't experience issues in Nova 4.26 with version <1.0.9, but I don't. My layouts still are instances of \stdClass, so removing the check from getMappedLayout in HasFlexible seems to break my installation (getMappedLayout returns null). Reverting back to version 1.0.8 fixes the issue and is fully compatible with my usecase in Nova 4.26.

For posterity and sake of completeness:

  • The output of get_class and class_parents are stdClass and [] respectively.
  • I am using protected $casts = ['content' => FlexibleCast::class] to cast the content.
  • This happens in both existing, newly seeded, and newly created pages.
  • I am using custom Layout classes, normally extending the Whitecube\NovaFlexibleContent\Layouts\Layout class, and only having the required fields.
  • Layout classes are registered using ->addLayout([Layout]::class).
  • I am editing a regular resource, not a custom tool like outl1ne/nova-settings.

Proposed fix

The recent commits removed the check for is_a($item, \stdClass) (HasFlexible.php:125 in 1.0.8). This should be added back in the same elseif as Fluent::class, probably (ex. elseif (is_a($item, Fluent::class) || is_a($item, \stdClass::class))). I am not sure (and not feasibly able to test) whether this breaks things for people that are experiencing issues with >=1.0.9 and 4.26, hence I am not able to comfortably Pull Request.

@PieterCappelle
Copy link

Agree, having same issues. Laravel Nova 4.26 and latest version of this module. This breaks the entire module. content is empty after this change.

#469

@mabdullahsari
Copy link
Contributor

This has been fixed with #474. A patch release has to be tagged now.

@Jaspur
Copy link

Jaspur commented Jul 11, 2023

@mabdullahsari that did not fix it. I upgraded from v1.0.8: Upgrading whitecube/nova-flexible-content (v1.0.8 => v1.0.11)

When using v1.0.8 (and "laravel/nova": "4.25.1",):
Scherm­afbeelding 2023-07-11 om 09 10 43

When using v1.0.11 (and "laravel/nova": "4.26.4"):
Scherm­afbeelding 2023-07-11 om 09 10 06

@Senexis
Copy link
Author

Senexis commented Jul 11, 2023

@Jaspur It doesn't have a release yet (it would be 1.0.12). For now, you should be able to use dev-master as the composer version to get the changes.

@kbellpostman
Copy link

Thanks guys!

@toonvandenbos
Copy link
Member

Released in v1.0.12. Thank you for your help everyone!

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

6 participants