Fix crash when editing taxonomy blueprints#48
Merged
tdwesten merged 5 commits intotdwesten:mainfrom Apr 2, 2025
Merged
Conversation
Owner
|
Hi @tylerdak, Could you provide me with a test case to evaluate your code? |
9b19585 to
842ae7c
Compare
842ae7c to
1985cbe
Compare
Contributor
Author
|
Hi, I've added a test case. It's in this branch's history now. It's also in tylerdak:test/taxonomies-blueprint-parent-edit which might be more convenient for testing against the current version of statamic-builder. I did have to make some changes to TestCase.php and add an autoload-dev entry to get Statamic to load properly in the test. |
Owner
|
@tylerdak Thanks a lot! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi!
I've noticed Statamic Builder causes a crash when trying to edit Taxonomy Blueprints.
In the TaxonomyBlueprintsController provided by Statamic-Builder, the blueprint parameter passed into
::editgets overridden and then potentially passed intoparent::editdespite the malformed parameter:This results in the
parent::editmethod calling$taxonomy->termBlueprintagain except with an object instead of the expected string. Here's the resulting error and stack trace:To fix this, I've stored the original blueprint handle passed into the method in a temporary variable. That temporary variable then gets passed to
parent::editinstead of the Blueprint object:This bug is technically present in the CollectionBlueprintsController too. However, Statamic uses Blink to get the result for the
$collection->entryBlueprintcall. So, when the parent calls entryBlueprint again (after the first call being by Statamic-Builder's implementation), Blink returns the first result so no error gets thrown. I've implemented a similar patch to the CollectionBlueprintsController too, though.Let me know if there's anything else I can do to help get this merged! Thanks!