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

Add 'source' to the list of reserved names for field handles #4754

Closed
ghost opened this issue Aug 14, 2019 · 2 comments
Closed

Add 'source' to the list of reserved names for field handles #4754

ghost opened this issue Aug 14, 2019 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 14, 2019

Description

I think it is this change in 3.2.9 that breaks fields or matrix sub fields with the handle 'source'

Added craft\base\ElementInterface::getSource().

An instance of craft\elements\Entry or craft\elements\MatrixBlock is returned instead of a field value.

However it is still possible to add fields with this handle, so 'source' should be added to the list of reserved names.

PS.
A wish: the change log description is for sure technically correct, but something like

Actions to be taken: Check your field handles and rename it...

would be very much appreciated.

Steps to reproduce

  1. Add a field/matrix sub field with the handle 'source' , add to field layout and add some content
  2. Output {{ entry.source }} will show the entry title instead of the field value
  3. Output {{ block.source }} will show the id of the matrix block element.

As this will not throw a runtime error, it's a bit tricky to discover.

Additional info

  • Craft version: 3.2.10
  • PHP version:
  • Database driver & version:
  • Plugins & versions:
@brandonkelly
Copy link
Member

Sorry you’re right, we should have called that out. Just added source as a reserved handle for the next release.

@brandonkelly
Copy link
Member

On second thought, given the unexpected break that getSource() caused, I’ve decided to just remove it for the next release, and move that logic over to a new ElementHelper::sourceElement() method.

To get the change early, change your craftcms/cms requirement in composer.json to:

"require": {
  "craftcms/cms": "dev-develop#efab6239d812506fec0878611a3685978baf3b53 as 3.2.10",
  "...": "..."
}

Then run composer update.

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

1 participant