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

Form settings inaccessible due to abandoned element usage #2299

Open
TomPixeldeluxe opened this issue Feb 20, 2025 · 1 comment
Open

Form settings inaccessible due to abandoned element usage #2299

TomPixeldeluxe opened this issue Feb 20, 2025 · 1 comment

Comments

@TomPixeldeluxe
Copy link

Describe the bug

I'm unsure if this is a Formie issue or a Craft issue, but at some point i found myself unable to edit a specific form. Instead i got the error "Call to a member function getFieldById() on null" in "/var/www/html/vendor/craftcms/cms/src/base/NestedElementTrait.php" at line 305.

After some slight digging i found that the form was apparently being used in an abandoned temporary element and this caused an error in the usage tab of the form settings. I only found this out by commenting out _self.tableColumns, dumping all the element ids, then attempting to find which one was at fault. Eventually i found an inaccessible element that appears to have been abandoned in some way. Should there maybe be a safeguard against something like this?

Steps to reproduce

I can't provide much in the way of reproducing this issue, as i do not know what caused this temporary element to become abandoned. I can say that this element appears to be a matrix block as its associated field layout matched other blocks that we have. I do have a dump of the element, but i don't know if there is much more that i can provide, as most methods for accessing extra information trigger the same error.

craft\elements\Entry {#4126 ▼
-_events: []
-_eventWildcards: []
-_behaviors: array:1 [▶]
-_errors: null
-_validators: null
-_scenario: "default"
#revisionCreatorId: null
#revisionNotes: null
-_canonicalId: null
-_canonical: null
-_canonicalAnySite: null
-_canonicalUid: null
-_outdatedAttributes: null
-_modifiedAttributes: null
-_outdatedFields: null
-_modifiedFields: null
-_initialized: true
-_fieldParamNamePrefix: null
-_normalizedFieldValues: null
-_allDirty: false
-_dirtyAttributes: []
-_savedTitle: null
-_dirtyFields: []
-_nextElement: false
-_prevElement: false
-_parentId: null
-_parent: null
-_hasNewParent: null
-_prevSibling: null
-_nextSibling: null
-_invalidNestedElementIds: []
-_eagerLoadedElements: []
-_lazyEagerLoadedElements: []
-_eagerLoadedElementCounts: []
-_currentRevision: null
-_enabledForSite: true
-_uiLabel: null
-_uiLabelPath: []
-_isFresh: null
-_serializeFields: false
+elementQueryResult: array:1 [▶]
+eagerLoadInfo: null
+id: 158
+tempId: null
+draftId: null
+revisionId: null
+isProvisionalDraft: false
+uid: "169a1232-d403-4a31-bb37-dbe696ca5248"
+siteSettingsId: 158
+fieldLayoutId: null
+structureId: null
+enabled: true
+archived: false
+siteId: 1
+title: null
+slug: "__temp_iwembpypdbpoyrrybemlcrhpltwuksblgylc"
+uri: null
+dateCreated: DateTime @1718622932 {#4127 ▶}
+dateUpdated: DateTime @1734425166 {#4128 ▶}
+dateLastMerged: null
+dateDeleted: null
+deletedWithOwner: null
+root: null
+lft: null
+rgt: null
+level: null
+searchScore: null
+trashed: false
+awaitingFieldValues: false
+propagating: false
+propagatingFrom: null
+propagateAll: false
+newSiteIds: []
+isNewForSite: false
+resaving: false
+duplicateOf: null
+firstSave: false
+mergingCanonicalChanges: false
+updatingFromDerivative: false
+previewing: false
+viewMode: null
+forceSave: false
+hardDelete: false
+sectionId: null
+collapsed: false
+postDate: DateTime @1718622900 {#4129 ▶}
+expiryDate: null
+deletedWithEntryType: false
+deletedWithSection: false
-_authorIds: []
-_authors: null
-_typeId: 12
-_oldTypeId: 12
-_type: null
-primaryOwnerId: 2
-ownerId: null
+fieldId: 10
+sortOrder: null
+saveOwnership: true
+updateSearchIndexForOwner: false
}

Form settings

  • Multi-page form: No
  • Submission Method: Page Reload
  • Client-side Validation: Yes
  • Custom Form Templates: No

Craft CMS version

5.6.4

Plugin version

3.0.20

Multi-site?

yes

Additional context

No response

@engram-design
Copy link
Member

I think we'll just add some handling to this method outside of Twig, which isn't very good at handling fatal errors like this.

Fixed for the next release. To get this early, run composer require verbb/formie:"dev-craft-5 as 3.0.20".

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

2 participants