Problem/Motivation
Part of #2851705: [meta] Deprecate DRUPAL_DISABLED, DRUPAL_OPTIONAL and DRUPAL_REQUIRED - we want to deprecate DRUPAL_DISABLED, DRUPAL_OPTIONAL and DRUPAL_REQUIRED. Doing this in a single issue is too hard to review and we want to change the API as we go.
This ticket is for the Node module.
Proposed resolution
- Add NodePreview enum
- Replace usages of constants with new enum
- Add deprecated $returnAsInt param to NodeTypeInterface::getPreviewMode and update return type to int|NodePreview
- Update usages in core of NodeTypeInterface::getPreviewMode to expect NodePreview enum
- Allow int|NodePreview in NodeTypeInterface::setPreviewMode
- Update usages in core of NodeTypeInterface::setPreviewMode to use the NodePreview enum
API changes
NodeTypeInterface::getPreviewMode and NodeTypeInterface::setPreviewMode now interact with the NodePreview enum
Release notes snippet
N/A
Issue fork drupal-3538277
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3538277-add-nodepreview-enum
changes, plain diff MR !12864
Comments
Comment #2
acbramley commentedComment #3
acbramley commentedComment #5
acbramley commentedComment #6
mstrelan commentedAdded a couple comments on the MR.
FWIW #3244848: Remove comment and node preview, but that's not likely to get in quickly, so let's continue here.
Comment #7
catchA trait for shared logic in the enums was mentioned in the meta issue. A bit of a cop out - but could we just add that to Drupal\Core\Utility?
But also if #3244848: Remove comment and node preview ever happens we wouldn't have enough uses to justify a trait.
Comment #8
acbramley commentedTrait added, I think the logic is good enough to keep around even if comment/node previews were removed because the Link enum will still use it and it may be handy for other things in the future.
Comment #9
acbramley commented@mstrelan linked me to #3249599: Add support for PHP 8.1 Backed Enums in Select, Checkboxes, Radio elements which could use this trait as well.
Comment #10
dwwThanks for working on this! Opened a bunch of MR threads. Mostly very nit-picky bikesheds. A couple things of substance.
Comment #11
acbramley commentedMostly addressed, left stuff I don't agree with or have no strong feelings about.
Comment #12
nicxvan commentedI think this is ready.
All deprecations line up.
I commented on the open threads I agree should remain as is.
There is one bc break that is commented that will want confirmation it is ok before commit.
This includes a helpful trait in utility.
All other changes seem relevant and scoped to node.
I read the CR as well and it seems clear to me.
Comment #13
dwwSaving credit for reviews.
Comment #14
dwwThere are 2 legit unresolved MR threads. I want to take this out of RTBC, since it’d be better to resolve those before a core committer looks at it. But we probably need a framework manager or release manager to decide on the BC break problem and how to handle the API change to
NodeTypeInterface::getPreviewMode(). 😅 So I’m leaving the RTBC, but won’t formally tag it for any specific sign-off (yet).Thanks/apologies,
-Derek
Comment #15
catchReplied on the MR, we can use the process in https://www.drupal.org/node/3376455 to add the argument to the interface method. I think that's reasonable to change in Drupal 12.
Comment #16
acbramley commentedThanks @mstrelan, I don't think the bikeshedding of the trait name should hold this back from RTBC. We have 2 +1s for the current name and one against.
Comment #17
mstrelan commentedTest fail (twice) seems unrelated. This is the code on the status report page:
// Ensure the status is not a warning if APCu size is greater than or equal
// to the recommended size.
if (preg_match('/^Enabled \((.*)\)$/', $elements[0]->getText(), $matches)) {
if (Bytes::toNumber($matches[1]) >= 1024 * 1024 * 32) {
$this->assertFalse($elements[0]->find('xpath', '../../summary')->hasClass('system-status-report__status-icon--warning'));
}
}
And this is the browser output https://issue.pages.drupalcode.org/-/drupal-3538277/-/jobs/6109542/artif...
Comment #18
nicxvan commentedNeeds a rebase, that test has been skipped on HEAD.
Comment #20
catchIf we have lots of enum traits we want to group, we could move them to Drupal\Core\Utility\Enum or similar. I wasn't sure about the trait initially but it looks tidy now that it exists. Interface param addition looks right now too.
Have to say while the original issue was borderline for me on MR size, the scope of doing the parameter changes one by one feels much better - this was a much nicer MR to review and it should be easier to tie up the loose ends in Drupal 12/13 and for contrib modules to copy the pattern from.
Committed/pushed to 11.x, thanks!
Comment #22
acbramley commentedThanks @catch, I've published the CR