Problem/Motivation
The method \Drupal\Core\KeyValueStore\DatabaseStorage::doSetIfNotExists currently has public visibility, but should be protected.
The prefix "do" is typically used for internal implementation, while the regular method that calls "do*" functions acts as a wrapper. For example, the method ::set() is public, while ::doSet() is protected.
By keeping the method ::doSetIfNotExists() public, it forces classes that extend DatabaseStorage to implement it, even if it's not necessary. This method is also not a part of the interface.
Proposed resolution
Change the visibility of the method from public to protected. This change will not break the code that extends DatabaseStorage because in that case, it can change visibility from protected to public but not from public to protected.
The only concern is if someone uses it directly (core doesn't). In that case, we should deprecate its usage and change the signature in Drupal 12. However, I think this is overkill because it is clearly an internal method.
Issue fork drupal-3485410
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
Comment #6
niklanComment #7
andypostCR required to notify devs
Comment #8
andypostAdded CR
Comment #9
andypostLooks good if no deprecation dance required
Comment #11
longwaveI agree that this was likely just an oversight and nobody should be calling this directly, let's just clean this up in 11.2 only as it's not really doing any harm.
Committed 64cc647 and pushed to 11.x. Thanks!
Comment #12
longwavePublished the change record.