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

Issue fork drupal-3577133

Command icon 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:

Comments

quietone created an issue. See original summary.

quietone’s picture

Issue summary: View changes
Issue tags: +Novice

Reading #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.

      // 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.

And searching the history, I agree with @dcam.

$ git log -SdateExample
commit 40b5046f43b3177d92178c7470533aaf7865ca38
Author: Alex Pott <alex.a.pott@googlemail.com>
Date:   Fri Apr 26 09:21:18 2024 +0100

    Issue #3443486 by smustgrave: Remove deprecated code from lib/Batch and lib/Datetime

commit 12ee21a360fd18db04e52650ef4b944fb5181ba2
Author: webchick <drupal@webchick.net>
Date:   Thu Aug 28 21:42:51 2014 -0700

    Issue #2328061 by tim.plunkett: Move datetime's FormElement #type classes in Core.

karthik_gundu changed the visibility of the branch 3577133-remove-unused-class to hidden.

karthik_gundu’s picture

I 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.

quietone’s picture

Status: Active » Needs review

@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.

scontzen’s picture

Assigned: Unassigned » scontzen
scontzen’s picture

Assigned: scontzen » Unassigned
Status: Needs review » Needs work

Thanks @karthik_gundu for working on this!

The property removal is correct.

Confirmed via git history that $dateExample was only ever used in formatExample().

$ 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):

        // 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.

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.

quietone’s picture

Issue summary: View changes

Fix 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,

[#2791693]

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

thirteenthdown made their first commit to this issue’s fork.

thirteenthdown’s picture

Status: Needs work » Needs review

I'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.

scontzen’s picture

Status: Needs review » Reviewed & tested by the community

Verified MR !15020: both the unused $dateExample property (lines 19–22) and the outdated tooltip comment in processDatetime() (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.

longwave’s picture

Version: main » 11.x-dev
Status: Reviewed & tested by the community » Fixed

Thanks 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!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • longwave committed 965d5673 on 11.x
    fix: #3577133 Remove unused class property dateExample
    
    By: quietone
    By...

  • longwave committed c6498ec0 on main
    fix: #3577133 Remove unused class property dateExample
    
    By: quietone
    By...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.