Problem/Motivation
The properties defined in data_entity_entity_property_info() don't have proper types assigned.
Proposed resolution
Reuse the code from the Entity module (_entity_metadata_convert_schema_type()) to assign the types.
Remaining tasks
Review patch #5
User interface changes
None.
API changes
Original report by @acouch
hook_entity_property_info() offers 'type' key which some modules use though was most likely not originally added to data_entity_entity_property_info() since this was added for feeds.
Missing the type throws an exception in search_api: http://drupalcode.org/project/search_api.git/blob/refs/heads/7.x-1.x:/in...
Comments
Comment #1
acouch commentedAttached is a patch. I made the double and float number types as text to be conservative. I'm not sure what the repercussions for name an 'integer' for a number that has decimals etc.
Comment #2
joachim commentedLooks good, though is there any way we can make use of / extend _entity_metadata_convert_schema_type()?
Comment #3
manyk commentedThis really needs fixing. Search Facets/ Search API fails without this patch.
Comment #4
joachim commentedSee my comment #2.
Comment #5
das-peter commentedHow about this approach.
Looks like
_entity_metadata_convert_schema_type()does pretty much what we need as base. We can decorate the data then with the metadata available.Comment #6
das-peter commentedI just went totally crazy and extended the patch.
It enhances the integration with the entity module.
Comment #7
joachim commented> I just went totally crazy and extended the patch.
That's not really helpful I'm afraid... if patches are to be reviewed and committed, they need to stay focussed on the topic of the issue. Smaller patches that are easier to understand stand a better chance of getting committed. File new issues for further work!
Comment #8
das-peter commentedThe patch in #5 still contains the minimal version - this one is good to and should be pretty easy to review.
Comment #9
das-peter commentedWorking with the patched module revealed some issues when clearing / rebuilding caches.
Attached is an updated version of both patches.
The minimal version to re-use the schema property conversion from the entity module as well as the one that fully integrates with entity properties and provides abstract types as well.
Comment #10
joachim commentedThis is more the approach I was thinking of -- using EntityAPI's _entity_metadata_convert_schema_type() to convert schema API types to EntityAPI property types.
I don't think we need to use the rest of EntityAPI's schema conversion: first, we don't put anything terribly useful into our hook_schema(), so having it processed and given back to us doesn't give us anything useful either. Second, as you found, there's caching issues.
One point against this approach is that _entity_metadata_convert_schema_type() is a module-private function (by the Drupal convention of starting with an underscore), so ideally shouldn't be used by other modules. However, I think at this stage we can say that Data module probably isn't going to make it out of alpha on D7, so I don't think we should worry too much about that ;)
Comment #11
theorichel commentedAfter applying this patch, I get this message:
Notice: Undefined property: SearchApiServer::$entity_type in entity_data_entity_load() (line 101 of /home/theorich/public_html/sites/all/modules/entity_data/entity_data.module).
Have no idea what it means and it may be a result of my being a search_api newbie
Comment #12
joachim commentedI was using SearchAPI with this patch to give it a spin and it was working ok.
Is there an 'entity_type' field on your data table? What type is is declared as in the table schema?
Comment #13
theorichel commentedThanks.
Schema: The table consist of 9 fields of which the first 'IDAccess'is the primary key. The term entity is not mentioned here. But on the Tab Entity-type this same field ('IDAccess') is set as as Entity ID field. Table is defined as Entity Type.
The Tab Configure Entity Form marks all fields as required and one field ('Title') as label.
I have installed an Entity Browser-module and it tells me that the table is an entity type (Fieldable, 1 bundle, 0 view modes).
Hope this answers your question.
Comment #14
joachim commentedMy patch removes the declaration of any properties for which we can't find a type, as they're technically broken anyway.
Can you check your entity properties before and after the patch? (Use Devel Contrib to inspect them.)
Comment #15
theorichel commentedI hope this is what you are looking for. 'Entity info' with Devel. With patch or without however makes no difference. This is the list:
label (String, 8 characters ) Foodnews
controller class (String, 20 characters ) DataEntityController
base table (String, 8 characters ) foodnews
fieldable (Boolean) TRUE
entity keys (Array, 4 elements)
bundles (Array, 1 element)
view modes (Array, 0 elements)
uri callback (String, 15 characters ) data_entity_uri | (Callback) data_entity_uri();
module (String, 11 characters ) data_entity
views controller class (Boolean) FALSE
static cache (Boolean) TRUE
field cache (Boolean) TRUE
load hook (String, 18 characters ) data_foodnews_load
translation (Array, 0 elements)
base table field types (Array, 9 elements)
schema_fields_sql (Array, 1 element)
configuration (Boolean) FALSE
Comment #16
joachim commentedThanks, but , it's entity properties info I wanted, rather than entity info. You'll need Devel Contrib module for that: http://drupal.org/project/devel_contrib - use the -dev version.
Comment #17
theorichel commentedI am sorry. Have installed the Contrib -dev module (and its Generate partners), but I cannot find it. Entity Info yes, Entity Metadata yes, but not Entity Properties Info
Comment #18
theorichel commentedHa it was part of the metadata (this is without patch):
comment (Array, 2 elements)
data_foodnews (Array, 1 element)
file (Array, 1 element)
node (Array, 2 elements)
search_api_autocomplete_search (Array, 1 element)
search_api_index (Array, 1 element)
search_api_server (Array, 1 element)
site (Array, 1 element)
taxonomy_term (Array, 1 element)
taxonomy_vocabulary (Array, 1 element)
user (Array, 1 element)
Comment #19
theorichel commentedThis is the patched one. It looks like the patch made no difference
comment (Array, 2 elements)
data_foodnews (Array, 1 element)
file (Array, 1 element)
node (Array, 2 elements)
search_api_autocomplete_search (Array, 1 element)
search_api_index (Array, 1 element)
search_api_server (Array, 1 element)
site (Array, 1 element)
taxonomy_term (Array, 1 element)
taxonomy_vocabulary (Array, 1 element)
user (Array, 1 element)
FYI, a copy of my patched module:
Comment #20
joachim commentedOk you've got the right one. Sorry for the confusion with the name of it.
What I need though is the sub-array inside that for your entity type's properties so:
Root -> your entity type -> properties
Comment #21
theorichel commentedI was so happy that I had found it that i turned blind. Well I suppose that this is what you were looking for:
properties (Array, 11 elements)
IDAccess (Array, 6 elements)
Kastnr (Array, 6 elements)
Titel (Array, 6 elements)
Aut (Array, 6 elements)
Jaar (Array, 6 elements)
Ref (Array, 6 elements)
Tref (Array, 6 elements)
Txt (Array, 6 elements)
Taal (Array, 6 elements)
feed_nid (Array, 4 elements)
feed_node (Array, 4 elements)
I could go deeper. These are the properties of IDAccess:
label (String, 8 characters ) IDAccess
description (String, 21 characters ) Field of type serial.
type (String, 7 characters ) integer
getter callback (String, 28 characters ) entity_property_verbatim_get | (Callback) entity_property_verbatim_get();
setter callback (String, 28 characters ) entity_property_verbatim_set | (Callback) entity_property_verbatim_set();
schema field (String, 8 characters ) IDAccess
Comment #22
theorichel commentedAnd this is the unpatched one:
properties (Array, 11 elements)
IDAccess (Array, 6 elements)
Kastnr (Array, 6 elements)
Titel (Array, 6 elements)
Aut (Array, 6 elements)
Jaar (Array, 6 elements)
Ref (Array, 6 elements)
Tref (Array, 6 elements)
Txt (Array, 6 elements)
Taal (Array, 6 elements)
feed_nid (Array, 4 elements)
feed_node (Array, 4 elements)
And again IDAccess:
IDAccess (Array, 6 elements)
label (String, 8 characters ) IDAccess
description (String, 21 characters ) Field of type serial.
type (String, 7 characters ) integer
getter callback (String, 28 characters ) entity_property_verbatim_get | (Callback) entity_property_verbatim_get();
setter callback (String, 28 characters ) entity_property_verbatim_set | (Callback) entity_property_verbatim_set();
schema field (String, 8 characters ) IDAccess
Comment #23
theorichel commentedThat latter one was done with the patched file. I'll try again.
Comment #24
theorichel commentedproperties (Array, 11 elements)
IDAccess (Array, 5 elements)
Kastnr (Array, 5 elements)
Titel (Array, 5 elements)
Aut (Array, 5 elements)
Jaar (Array, 5 elements)
Ref (Array, 5 elements)
Tref (Array, 5 elements)
Txt (Array, 5 elements)
Taal (Array, 5 elements)
feed_nid (Array, 4 elements)
feed_node (Array, 4 elements)
And IDAccess, which misses éntity property', and the others probably as well.
IDAccess (Array, 5 elements)
label (String, 8 characters ) IDAccess
description (String, 21 characters ) Field of type serial.
getter callback (String, 28 characters ) entity_property_verbatim_get | (Callback) entity_property_verbatim_get();
setter callback (String, 28 characters ) entity_property_verbatim_set | (Callback) entity_property_verbatim_set();
schema field (String, 8 characters ) IDAccess
Comment #25
joachim commentedI'm finding it hard to follow.
Does the patch cause any properties to vanish? You should be looking under root -> Your entity -> properties.
Comment #26
jerry commentedWorking fine here. Let's RTBC it.
Comment #28
joachim commentedThanks!