Reported by devel Generate trying to generate content for node of type group content

Comments

ezra-g’s picture

I'm troubleshooting similar behavior at #1851766: Error when bulk deleting content.

Printing $node at the top of node_save() shows that $node->field_og_group_ref[und][0][target_id] is set to 'group' rather than a target ID or being blank.

ezra-g’s picture

Title: EntityMalformedException: Missing bundle property on entity type node, line 7633 \includes\common.inc » Invalid field value with devel_generate
Project: Organic Groups » Entity reference
Version: 7.x-2.x-dev » 7.x-1.x-dev
Component: og.module » Code

This seems to be coming from _entityreference_devel_generate():

$referencable_entity = entityreference_get_selection_handler($field, $instance)->getReferencableEntities();

Returns an array such as:

array('group' => array(1 => 'boston', 2 => 'nyc'));
if (is_array($referencable_entity) && !empty($referencable_entity)) {
    // Get a random key.
    $object_field['target_id'] = array_rand($referencable_entity);
  }

Sets the target_id to 'group' rather than an entity ID.

ezra-g’s picture

Status: Active » Needs review
StatusFileSize
new724 bytes

With this patch, I'm able to generate nodes within groups successfully.

kristofferwiklund’s picture

Status: Needs review » Reviewed & tested by the community

This patch works nice. Solved my problem

jolidog’s picture

Worked great for me to! Thank you!

rainman-2’s picture

Worked for me too! Thanks!

darrell_ulm’s picture

Patch applied fine, although on using devel create content, error still occurs on the entity reference.

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value:

note: content types w/ node references can be created, only if there are no nodes of the type referencing yet created.

WorldFallz’s picture

make sure you clear the cache-- the patch fixed the error in #7 for me.

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

benjifisher’s picture

I marked #1916376: Devel Generate error on target id column as a duplicate.

I prefer the patch in that issue to the one committed in this one. It seems like an odd use of a loop:

    foreach ($referencable_entity as $type => $eids) {
      $object_field['target_id'] = array_rand($eids);
    }
dww’s picture

Status: Closed (fixed) » Needs review
StatusFileSize
new1.03 KB

I ran into this while trying to use devel_generate with project and project_issue nodes to get us closer to the D7 port of d.o...

Agreed, the committed code is a bit weird (although it works). Here's a new patch that takes some of the code from #1916376: Devel Generate error on target id column, although I renamed $random_entity to $random_bundle to be more accurately self-documenting.

Thanks,
-Derek

duaelfr’s picture

Status: Needs review » Reviewed & tested by the community

Thanks dww ! It is a lot better for websites having a lot of group types.

aaronbauman’s picture

#12 rtbc ftw

seanr’s picture

Patch doesn't appear to apply anymore, but I patched it manually and it works just fine. This is definitely RTBC and would love to see it go in soon.

tostinni’s picture

The latest dev version already got this fix in, so you should use it to avoid this bug.

benjifisher’s picture

Right. The patch in #3 was committed: see #9. The issue was closed (#10) and @dww reopened it (#12) with an alternative patch. Either way, the issue should be fixed in the next release. (I have not checked the latest dev release, but @tostinni says it contains the fix.)

chrowe’s picture

Using the current dev release ( drush dl entityreference --dev ) I still get an error trying to generate nodes that reference other nodes using entityreference.

Took patch from 12 and manually applied it. This fixed my issue and I can now generate nodes that reference other nodes. As long as there are existing nodes to reference.

patch attached.

chrowe’s picture

Status: Reviewed & tested by the community » Needs review
dutchyoda’s picture

Status: Needs review » Reviewed & tested by the community

Just tested the patch and it works.

marblegravy’s picture

Testing with dev build (downloaded today) and it all works as expected.

LeviThomason’s picture

Confirming entityreference 7.x-1.0+7-dev (2013-Jun-06) and patch in #18 works :)

basvredeling’s picture

+1 works

ryanoreilly’s picture

Also confirming Dev fixes issue.

ryanoreilly’s picture

Issue summary: View changes

genarate to generate

andypost’s picture

Issue summary: View changes

Can we get this in?

amitaibu’s picture

Status: Reviewed & tested by the community » Fixed

Merged, thanks.

  • amitaibu committed ea9eeee on 7.x-1.x authored by chrowe
    Issue #1852112 by ezra-g, chrowe, dww: Invalid field value with...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.