Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#9 | nestedbox-2259005-9.patch | 2.4 KB | pifagor |
#4 | nested_box-2259005-4.patch | 933 bytes | pifagor |
Comments
Comment #1
donquixote CreditAttribution: donquixote commentedI 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?
Comment #2
Nicolas Bouteille CreditAttribution: Nicolas Bouteille commentedActually 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.
Comment #3
donquixote CreditAttribution: donquixote commentedOk then, this looks more like a bug in nestedbox itself.
Going to check.
Comment #4
pifagorAdded 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'.
Comment #5
donquixote CreditAttribution: donquixote as a volunteer commented"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 innestedbox_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.
Comment #6
donquixote CreditAttribution: donquixote as a volunteer commentedIt 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 toentity_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.
Comment #7
donquixote CreditAttribution: donquixote as a volunteer commentedI 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.
Comment #8
donquixote CreditAttribution: donquixote as a volunteer commentedMaybe 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 :)
Comment #9
pifagorDiscovered 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.
Comment #10
pifagorComment #11
donquixote CreditAttribution: donquixote as a volunteer commentedPatch does not apply.
Can you create a pull request on github?
Comment #12
pifagorComment #13
pifagorok
Comment #14
pifagorDone https://github.com/donquixote/drupal-nestedbox/pull/1
Comment #15
donquixote CreditAttribution: donquixote as a volunteer commented@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 innestedbox_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.
Comment #16
donquixote CreditAttribution: donquixote as a volunteer commentedBtw, 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.
Comment #17
pifagorChanges brunches https://github.com/donquixote/drupal-nestedbox/tree/7.x-1.x-donquixote-r... a good job. But found another bug that is corrected here: https://github.com/donquixote/drupal-nestedbox/pull/2
Comment #18
donquixote CreditAttribution: donquixote as a volunteer commentedIt is merged (since a while). Should we release now on drupal.org?
Comment #19
pifagorI think you can release now on drupal.org
Comment #20
pifagorComment #21
pifagor