I just deleted a bunch of test nodes that had test nested boxes inside of them... then I went on the nested box listing page to also delete all test nested boxes but I get a fatal error when I click delete. Ok I probably should have deleted nested boxes first, but still it should work both ways right ?

Here is the error:

Fatal error: Call to a member function label() on a non-object in entity/entity.module

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

donquixote’s picture

I imagine this is up to Entity API / Entity reference / Inline entity form. So, not much that Nestedbox can do.
Can you try the same with nodes or commerce products as referenced entities?

Nicolas Bouteille’s picture

Title: Fatal error when deleting nested box after deleting nodes that was refering it » Fatal error when deleting nested box from admin/content/nestedbox

Actually I get the error anyway, even without having previously deleted the node that was referencing the nested box... I simply can't delete nested boxes from admin/content/nestedbox.

I can however delete the nestedbox from the node edit form and checking "completely delete from the system" without error.

donquixote’s picture

Ok then, this looks more like a bug in nestedbox itself.
Going to check.

pifagor’s picture

FileSize
933 bytes

Added patch, but there's next problem:
"Missing bundle property on entity of type nestedbox. In entity_extract_ids ()"
variable $entity in functions entity_extract_ids() is not object and have value type string -> 'manage'.

donquixote’s picture

"Call to a member function label() on a non-object in entity/entity.module"

The message implies that the problem is that there is no object at all. Not that the object lacks the ->label() method.
If there is an object, it should be an instance of Drupal\nestedbox_core\NestedBox, as defined in nestedbox_core_entity_info(). This does have a ->label() method, inherited from \Entity.

So the real question is why is there no object.
A stack trace should tell us.

donquixote’s picture

It seems the problem is fixed in this tag:
https://github.com/donquixote/drupal-nestedbox/tree/2259005-6-delete
https://github.com/donquixote/drupal-nestedbox/commits/2259005-6-delete

The problem was this:
nestedbox_core uses entity_operations for its UI paths. But the integration with entity_operations was flawed and inconsistent.
entity_operations registered a path 'admin/content/nestedbox/manage/%/delete' with 'title callback' => 'entity_class_label', but the 'title arguments' were as if the path was 'admin/content/nestedbox/%/delete'. So the parameter passed to entity_class_label() was the string 'manage', instead of the entity object.

Also some paths were like 'nestedbox/%/*', instead of 'admin/content/nestedbox/%/*'.

But now new problem occur, it seems.
There is no more "Add nested box" button on the 'admin/content/nestedbox' page.

I think the commits contain the solution, but the entity_operations integration needs a careful review.

donquixote’s picture

I stumbled upon this problem with entity_operations:
#2775417: Need to flush cache twice after adding or removing an operation in hook_entity_operation_info()

This problem is easily avoided: Just clear the cache twice, problem solved.
But it can throw you off the track if you don't know it.

donquixote’s picture

Maybe we should give up on entity_operations some day in the future..
But for now I think we can leave it.

I think I made everything work, in the tag 2259005-8-manychanges on github:
https://github.com/donquixote/drupal-nestedbox/compare/7.x-1.x...2259005...

@pifagor: Is there any commit you disagree with, or they all seem reasonable? You can post inline comments directly on github.
This could be what becomes the first release on drupal.org :)

pifagor’s picture

FileSize
2.4 KB

Discovered and corrected some errors in https://github.com/donquixote/drupal-nestedbox/compare/7.x-1.x...2259005... branch 7.x-1.x-donquixote-local
1 - as you yourself said "There is no more" Add nested box "button on the 'admin / content / nestedbox' page.", There was no "Add nested box", corrected.
2 - at removing such entity published a mistake, because there was no function nestedbox_type_form_delete_confirm, corrected.
The patch is attached.

pifagor’s picture

Status: Active » Needs work
donquixote’s picture

Patch does not apply.

Can you create a pull request on github?

pifagor’s picture

Status: Needs work » Needs review
pifagor’s picture

ok

pifagor’s picture

donquixote’s picture

@pifagor:

I started a branch 7.x-1.x-donquixote-rebase. As the name suggests, I will rebase this when I feel like it.. so don't expect it to be stable over time.

To provide stable points of reference, I publish tags.
Such as this one, which atm marks the last commit of the above mentioned branch: 7.x-1.x-2259005-15.

I think this code in the tag solves all the issues. Would be great if you can have a look.

It works differently than the solution you proposed:
Instead of adding a function nestedbox_type_form_delete_confirm(), it removes the entry in nestedbox_core_menu(). Because entity module already does this stuff natively.

The branch does some more changes, you can review if you like, and comment (in github) if something seems weird.

If/when we are both happy with this, we can finally publish this here on drupal.org, as the official 7.x-1.x branch, and 7.x-1.0 release.

donquixote’s picture

Btw, your PR in #14 was not based on the most recent code at that time. Some of the changes became obsolete after a rebase.
I wrote some comments in https://github.com/donquixote/drupal-nestedbox/pull/1

But now the changes in 7.x-1.x-2259005-15 make most of the PR obsolete anyway..

I hope this was not too confusing.

pifagor’s picture

donquixote’s picture

It is merged (since a while). Should we release now on drupal.org?

pifagor’s picture

I think you can release now on drupal.org

pifagor’s picture

Version: » 7.x-1.0
Status: Needs review » Closed (fixed)
pifagor’s picture