Git Product home page Git Product logo

entity_plus's Introduction

Entity Plus

This module wraps in a variety of entity-related functionality from various sources, including:

  • The Entity Metadata Wrapper module from Drupal 7.
  • Various bits from the Entity API module from Drupal 7 which have not (yet) been merged into core. Note that this module renames several functions from the entity_xxx() format to entity_plus_xxx() format to prevent conflict in case some of these functions are eventually merged into core.

This is an API module. You only need to enable it if a module depends on it or you are interested in using it for development.

Installation and Usage:

Current Maintainers

Credits

License

This project is GPL v2 software. See the LICENSE.txt file in this directory for complete text.

entity_plus's People

Contributors

and-e-h avatar argiepiano avatar docwilmot avatar earlyburg avatar fago avatar graham-72 avatar herbdool avatar hosef avatar jayelless avatar joachim-n avatar klausi avatar laryn avatar robertgarrigos avatar vasasa avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

entity_plus's Issues

Scheduling content for publication in future w/ paragraph fields fails.

When scheduling a node w/ a paragraphs field to be published in the future it fails:

gff ~/code/aturnintime/htb (master) 
└─ $ ∴ lando.dev drush cron
Error: Call to undefined function entity_revision_load() in paragraphs_item_revision_load() (line 60 of /app/web/modules/contrib/paragraphs/paragraphs.module).
Drush command terminated abnormally due to an unrecoverable error.                                                                                                                                                                                   [error]

The function entity_revision_load was provided by the entity module in D7. In Backdrop the function is in entity_plus and therefore is namespaced as entity_plus_revision_load.

undefined function X_property_info_callback()

I was enabling some geo-related modules and the site WSOD on me, with this in the logs:

Error: Call to undefined function geofield_property_info_callback() in entity_plus_metadata_field_entity_property_info() (line 30 of /app/modules/entity_plus/modules/field.info.inc).

This brought me also to D7 Entity Issue 1312374 and a patch by Alan D. that prevents the fatal error and sends the error to the watchdog, which seems friendlier.

entity_plus_type_is_fieldable() is not defined

The method invoke of class EntityPlusController in file entity_plus.controller.inc (line 378) calls the function entity_plus_type_is_fieldable(). This function is undefined. This seems to be an oversight when the module was ported from Drupal 7. The Drupal 7 version of entity_plus includes the corresponding function called entity_type_is_fieldable, which is defined in file entity.module.

As a result the field module is never notified when a bundle entity (i.e. entities that define bundles, as in entity_type entities) is inserted, deleted or updated.

Proposed solution: port the Drupal 7 entity_type_is_fieldable function as entity_plus_type_is_fieldable.

Upgrade makes site crash

Hello, I am still using the 1.x-1.0.9 version, because upgrade makes all sites crash, I really tried to gather more information, but I do not see any pattern (e.g. other modules used, settings etc.)
Screenshot 2021-08-15 at 18 40 29
Screenshot 2021-08-15 at 18 56 46

PHP warnings appearing in Log

I'm getting php warnings in my log:

Warning: in_array() expects parameter 2 to be array, boolean given in entity_plus_entity_info_alter() (line 199 of /public_html/modules/entity_plus/entity_plus.module).

Warning: class_implements(): Class BackdropDefaultEntityController does not exist and could not be loaded in entity_plus_entity_info_alter() (line 199 of /public_html/modules/entity_plus/entity_plus.module).

These two notices appear together and only when I'm logged in as admin. Not sure if this is related to another module, but appears to occur on every page I visit.

Best place to document additional hook_entity_info keys and functions introduced by entity_plus

The Drupal 7 contrib module entity, which is the module on which entity_plus is based, introduced all hook_entity_info keys in the file entity.api.php. While many of these keys now have made it into core in Backdrop, there are a few that remained only in entity_plus that are not documented anywhere.

What might be the best place to document? Options: 1) creating a entity_plus.api.php, 2) in the readme file, 3) in the module wiki. Any thoughts? Without this information, it's hard for people to understand the benefits of this module beyond the use of entity_metadata_wrapper().

These are the hook_entity_info keys that, as far as I can tell, are used in entity_plus and not in core:

  • extra fields controller class
  • module
  • entity keys
    --name
    -- status
    -- module
  • view callback
  • deletion callback
  • save callback
  • creation callback
  • form callback (though this is not used anywhere in Drupal's contrib Entity API)
  • plural label

As a side note: it would also be great to create an example module to show the potential of entity_plus and entity_ui, something similar to Drupal 7 Typical Entity Example. Does this exist already in Backdrop?

Warning: Class BackdropDefaultEntityController does not exist

I'm seeing these warning notifications after updating a site to 1.13 (not sure if they were there before that):

Warning: class_implements(): Class BackdropDefaultEntityController does not exist and could not be loaded in entity_plus_entity_info_alter() (line 199 of /path/modules/entity_plus/entity_plus.module).

Warning: in_array() expects parameter 2 to be array, boolean given in entity_plus_entity_info_alter() (line 199 of /path/modules/entity_plus/entity_plus.module).

Getting array warning when enabling

Getting the following when enabling the module on a clean Backdrop installation, no other modules (besides civicrm) enabled:

array_values() expects parameter 1 to be array, null given sessions.php:140

Unsupported operand types

Trying to make a branch of Rules that uses Entity Plus instead of EMW and I hit this:

Error: Unsupported operand types in _entity_plus_defaults_rebuild() (line 672 of /path/modules/entity_plus/entity_plus.module).

Tests

We should set up tests on PRs with GHA and:

  • make sure that the tests are passing in general
  • Add a date related test (see #77)

consecutive invocations of entity_load_multiple in the same page request produce empty array

Function entity_load_multiple() can be used to load all entities of a custom entity type. For example if the custom entity type is called "event", then the syntax to get all event entities is entity_load_multiple('event'). The function returns an array of entity objects. This works as expected when you invoke entity_load_multiple('event') once.

The issue:
But if you invoke entity_load_multiple() more than once in the same page request for the same entity type (for example in different functions in a custom module), Backdrop returns an empty array for any invocation after the first one. This seems to be a logic issue when retrieving the entities cached after the first invocation.

To reproduce: define a custom entity type, create several entities and try to load all entities by invoking entity_load_multiple() more than once in the same page request

Call to a member function label() on null

I upgraded a few modules on a dev site and started getting a maintenance screen with this error: Call to a member function label() on null.

I tracked it down to entity_plus.theme.inc where it's trying to set the $entity variable, but in at least one case that was apparently null. Does that make any sense to you @hosef? For the moment I'm just blocking the whole section in template_preprocess_entity_plus with a if (!empty($variables['elements']['#entity'])) {...

Still getting entity_plus.controller.inc errors

Hi I'm still getting entity_plus issues logged in Backdrop:

Notice: Undefined property: RulesEntityController::$cache in EntityPlusControllerExportable->load() (line 772 of .../backdrop/modules/entity_plus/includes/entity_plus.controller.inc).

The latest update fixed two error/warning messages I was getting after the Backdrop 1.16.x update, but this one's still around. Thanks for sorting those out! :)

Debian 10.4
PHP 7.3.14-1~deb10u1
MariaDB 5.5.5-10.3.22-MariaDB-0+deb10u1
Backdrop 1.16.1
Entity Plus 1.0.6

Function entity_load_single() is undefined

The method render_entity_link in class entity_plus_views_handler_field_entity defined in file entity_plus_views_handler_field_entity.inc invokes the undefined function entity_load_single() in line 162 and 183.

As explained in the Backdrop documentation for the function entity_load, the old Drupal's Entity API function entity_load_single has been replaced in Backdrop by entity_load, and the old Drupal function entity_load has been replace in Backdrop by entity_load_multiple. This means that the old entity_load_single no longer exists in Backdrop.

Proposed solution: rewrite lines 162 and 183 above to invoke entity_load instead.

Undefined property: UcCartItemController::$cache

Getting this type error for a number of different controllers while testing Ubercart:

Notice: Undefined property: UcCartItemController::$cache in EntityPlusController->load() (line 222 of /app/modules/entity_plus/includes/entity_plus.controller.inc).

I believe that it might need to be changed in entity_plus to $this->entityCache which is defined in DefaultEntityController.

Images uploaded into WYSIWYG fields aren't marked permanent

Moving backdrop-contrib/paragraphs#65 over here after confirmation that this is an Entity Plus bug.

Images uploaded into WYSIWYG fields are not marked as permanent files and so they disappear when garbage collection runs.

Confirmed in Paragraphs and Registration, which depend on Entity Plus.

@oadaeh:

I looked at ParagraphsItemController::save() (which was removed in that commit) and compared it with EntityPlusController::save() & EntityStorageControllerInterface::save(). The ParagraphsItemController::save() method is very nearly identical to EntityStorageControllerInterface::save() (there is one addition in ParagraphsItemController::save()) and EntityPlusController::save() has many differences from the other two. Plus, the code in methods that are called from EntityPlusController::save() are also rather different from that which is called from the other to methods.

So, this is an Entity Plus bug and that code needs to be investigated to locate the change that must be made.

Should entity_plus_type just be entity_type?

This looks like potentially the result of an overeager search and replace at some point... @hosef can you verify the PR that's coming shortly? I think there are a bunch of references to entity_plus_type that should just be entity_type...

Move date wrapper code from entity_token to entity_plus

This refers to issue backdrop-contrib/entity_token#7. When Drupal's Entity API was ported to Backdrop, it was split into several modules. The code necessary for entity_metadata_wrapper to be able to get or set the content of date fields ended up in Entity Token for some unknown reason. This forces users to install Entity Token for the sole purpose of enabling metadata access to date fields.

@laryn and I discussed moving this code to Entity Plus in #33. I will be creating PRs for both Entity Plus and Entity Token for this purpose.

Error when creating or editing content

With this module enabled I'm getting a php error whenever I create or edit content. I've seen this on two separate websites and it appears to be related to the Entity and related modules, such as Entity Plus, Entity Reference etc.
Here's a report from my error log:

Error: Call to undefined function geofield_property_info_callback() in entity_plus_metadata_field_entity_property_info() (line 30 of /public_html/modules/entity_plus/modules/field.info.inc).

I've seen different errors reported by different modules (when I was switching modules on and off to find which one was causing the error) but always they have a callback function error and always appear to be an 'entity' module.

Would love to see a fix as I have a site launching soon with a massive need for this module.

Adjust due to `file_entity` being in core

There are a few places where entity_plus_access is referenced but this function doesn't exist and should simply be entity_access. These were likely porting search-and-replace errors.

Bring back i18n_string integration

I'm working to clean up Rules and the i18n_rules submodule extends EntityDefaultI18nStringController -- this doesn't exist in Backdrop. Maybe we should add entity.i18n.inc into Entity Plus from the Entity module for D7?

theme_entity_plus_property is not defined

The function theme_entity_plus_property doesn't seem to be defined anywhere, despite the direction to @see theme_entity_plus_property() in line 13 of entity_plus.theme.inc.

This is function should be the equivalent of Drupal 7's theme_entity_property, which is defined in the file entity.theme.inc. Is there a reason why it's not included in Backdrop's version of Entity API?

error when getting date field from wrapper

I cannot get a date field from a metada wrapper. I got an error of property missing. I can get any other type of field data, but not a date field type

$wrapper = entity_metadata_wrapper('node', $node);
$wrapper->field_description->value() // works fine
$wrapper->field_my_date_field->value() // triggers error field_my_date_field missing

Found anyone else in this situation??

entity_plus_uri function not defined

Line 13 of entity_plus/modules/callbacks.inc reads:

$return = entity_plus_uri($entity_plus_type, $entity);

should read

$return = entity_uri($entity_plus_type, $entity);

Found this while working on a port of SearchAPI for Backdrop, as it threw a method or function not found as it is not declared anywhere that I noticed. Thank you!

Error: Call to undefined function views_ui_build_form_url() in entity_plus_views_handler_area_entity.inc

This error is thrown when trying to add a Rendered Entity to the header or footer of a View:

Error: Call to undefined function views_ui_build_form_url() in entity_plus_views_handler_area_entity->options_form() (line 34 of...

views_ui_build_form_url() existed in Drupal 7, but it was renamed to views_ui_build_form_path() in Backdrop.

How to reproduce the error:
0. Be sure entity_plus is enabled

  1. Create a View
  2. Click "Add" in the "Header" fieldset in the View creation page
  3. Check "Entity: Rendered entity"
  4. Click "Add and configure header"

The Ajax call is aborted. Check the "Recent log messages" to see the error pasted above.

Proposed solution:
Rename the call to views_ui_build_form_url() to views_ui_build_form_path() in line 34 of entity_plus_views_handler_area_entity.inc

Update to Entity Plus 1.0.4 breaks Ubercart cart display.

The following error message is displayed at http://localhost/cart

"Argument 1 passed to backdrop_attributes() must be of the type array, null given, called in /webserver/backdrop/modules/entity_plus/theme/entity_plus.tpl.php on line 33"

Rolling back to Entity Plus 1.0.3 stops the issue and displays the cart properly.

System:
Debian 10.2
PHP 7.3.14-1~deb10u1
Backdrop 1.15
Ubercart 1.0.7-beta
Entity Plus 1.0.4

Errors during upgrade/migration from Drupal 7 ("Fatal error: Class 'EntityPlusControllerExportable' not found"...)

Whilst migrating from Drupal I received the below error:
Fatal error: Class 'EntityPlusControllerExportable' not found in /app/web/core/modules/entity/entity.module

As entity_plus was not enabled, I enabled it via the mysql cli (status=1), just to see if that helped.

Sadly though, this then resulted in the below error:
Call to undefined function entity_metadata_field_text_property_callback()

I am unsure which issue needs to be resolved sadly, but it feels like a migration bug at this point.

Call to undefined function entity_view() ...line 78... /entity_plus/views/plugins/entity_plus_views_plugin_row_entity_view.inc

I am using Entity Plus 1.x-1.0.10 with Search API & Search API Views 1.x-1.0.03. When I configure a new Search Index and create a View of that index type, I receive the fatal error referenced in the title. It is a node search, not custom entities or any other custom code at this point.

Changing that line (78) in /entity_plus/views/plugins/entity_plus_views_plugin_row_entity_view.inc to entity_plus_view() and line 94 from entity_id() to entity_plus_id() seems to resolve the issue.

With Backdrop >= 7.15 we can use entity_plus_language() ???

In

// With Backdrop >= 7.15 we can use entity_plus_language().

// With Backdrop >= 7.15 we can use entity_plus_language().
  if (function_exists('entity_plus_language')) {
    $default_langcode = entity_plus_language($entity_plus_type, $entity);
  }

There doesn't seem to be an entity_plus_language() function so this comment is cryptic. Since it doesn't seem to be in this module nor in core, I'm looking for an alternative.

User roles aren't integers

I'm debugging some tests in the Rules module and came across an error where it was trying to enforce the role as an integer. This must be a carry-over from role IDs in Drupal 7 but since we don't have numeric role IDs anymore this should not be enforced as an integer.

Upgrade process: can we enable Entity Plus if it's not already?

See https://github.com/backdrop-contrib/entity_plus/wiki#migrating-from-drupal-7s-entity-api-module

Rob Feature: I'm thinking that individual modules (such as rules, in my case) should look for the required entity modules and enable them during their update script, if possible.

Rob Feature: that way, if they're at least in the codebase, the rest is seamless.

Is it worth it (at least on some of the more major modules that rely on Entity Plus) to try to enable it by default during upgrade? (e.g. if the module is there, use module_enable('entity_plus'); or something like that). Those individual modules would need to implement this but I'm posting here for now as a centralized point of reference.

cannot update due to missing version

Trying to update entity plus to the latest version, I got a message from paragraph that in needs entity plus version > 1.0.5, even I'm installing entity plus 1.0.12. The list of modules doesn't show entity plus version, as if it couldn't find it.

Replace cache with staticCache

On Simpletests of a module dependent on EP I'm getting dozens of EXCEPTION: Undefined property: EntityPlusController::$cache. This because https://github.com/backdrop/backdrop/pull/2927 was merged in, replacing the cache property with staticCache.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.