Skip to content

Error: Cannot access protected property FieldCollectionItemEntity::$langcode #14

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

Open
danksearle opened this issue May 10, 2023 · 1 comment

Comments

@danksearle
Copy link

I'm migrating a D7 project to Backdrop. A form I have allows the user to create a Field Collection, this worked fine in D7. In Backdrop, this error happens:
Error: Cannot access protected property FieldCollectionItemEntity::$langcode
In the function title_entity_language, the line:
$langcode = $entity->langcode;
Is where the error occurs.

In Drupal 7, that line is different now. It is:
$langcode = entity_language($entity_type, $entity);

@argiepiano
Copy link

argiepiano commented May 10, 2023

The issue at hand is that the FieldCollectionItemEntity class (which extends Entity) uses a private langcode property, which differs from other entities on Backdrop (for example Node uses a public langcode property).

However, FieldCollectionItemEntity does provide a method FieldCollectionItemEntity::langcode() to obtain the langcode from the entity.

The solution here is to modify the code of the Title module to check to see if the property langcode is publicly available, and if not, check to see if there is a langcode() method that should be used instead. Alternatively, the maintainer of Field Collection could perhaps make langcode public.

I see the maintainer of Title is not active currently in the community, but perhaps the @BugSquad can help? (I'm part of the bugsquad).

BTW, entity_language() does not exist in Backdrop.

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