Problem/Motivation
\Drupal\Core\Datetime\Element\Datetime::$dateExample is not used.
Found while working on #3517505: Fix 'DocComment.MissingShort' in core/lib. dcam reports, that this should have been removed in #2791693: Remove sample date from date field error message and title attribute
Steps to reproduce
Proposed resolution
Remove \Drupal\Core\Datetime\Element\Datetime::$dateExample
Remove
// Creating format examples on every individual date item is messy, and
// placeholders are invalid for HTML5 date and datetime, so an example
// format is appended to the title to appear in tooltips.
Remaining tasks
Confirm that this isn't supposed to be used somewhere.
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Comments
Comment #2
quietone commentedReading #2791693: Remove sample date from date field error message and title attribute lead me to search for 'example'. This comment is also out of date and can be removed.
And searching the history, I agree with @dcam.
Comment #5
karthik_gundu commentedI created an issue fork and opened a merge request that removes the unused class property `\Drupal\Core\Datetime\Element\Datetime::$dateExample`.
The property is not referenced anywhere in the codebase, so it can safely be removed.
Merge request submitted for review.
Comment #6
quietone commented@karthik_gundu, Welcome to Drupal! When you think the MR is ready for review, you can change the status to 'Needs review'.
I am leaving this because a review of this is also Novice level. This offers experience in searching git history to find the issue when something changed. Reading the original issue can offer insights into why something was done.
Comment #7
scontzen commentedComment #8
scontzen commentedThanks @karthik_gundu for working on this!
The property removal is correct.
Confirmed via git history that
$dateExamplewas only ever used informatExample().$ git log -S dateExample --all --oneline -- '*.php'40b5046f43b Issue #3443486 by smustgrave: Remove deprecated code
12ee21a360f Issue #2328061 by tim.plunkett: Move datetime's FormElement classes in Core.
formatExample()was deprecated in #2791693 and removed in #3443486. The property was left behind by oversight.However, the outdated comment in
processDatetime()also needs to be removed (see issue summary and comment #2):The title attribute this comment described was removed in #2791693 (commit 5404ebfb). The comment now describes behavior that no longer exists.
Setting to Needs work for the missing comment removal.
Comment #9
quietone commentedFix typo in the issue summary.
@scontzen, when brackets are placed around issue numbers, it will be expanded to a link with the issue title automatically. So,
will become #2791693: Remove sample date from date field error message and title attribute. It is one of the bits of information in the More information about text formats at the lower right of the comment field
Comment #12
thirteenthdown commentedI've opened a new MR at !15020 that addresses the "Needs Work" feedback from @scontzen. Building upon the previous MR, I have removed the unused \Drupal\Core\Datetime\Element\Datetime::$dateExample property and also deleted the corresponding outdated tooltip comment in processDatetime(). I have verified via git grep that there are no remaining references to the property in the codebase, and the pipeline is passing cleanly.
Comment #13
scontzen commentedVerified MR !15020: both the unused
$dateExampleproperty (lines 19–22) and the outdated tooltip comment inprocessDatetime()(lines 252–254) are removed cleanly. No formatting issues, no remaining references in the codebase. See #3577133-8: Remove unused class property dateExample for the git log -S confirmation.Setting to RTBC.
Comment #14
longwaveThanks for spotting that additional comment that should have been removed when the examples were.
Committed and pushed c6498ec04bd to main and 965d5673dfe to 11.x. Thanks!