Updated: Comment #0

Problem/Motivation

In KeyValueStoreExpirableInterface we have
public function setWithExpire($key, $value, $expire);
where $expire is "The time to live for items, in seconds". In CacheBackendInterface we have
public function set($cid, $data, $expire, $tags);
where $expire is something else.

I think it would make sense in KeyValueExpirableInterface to change from $expire to $ttl.

Proposed resolution

Remaining tasks

User interface changes

API changes

Comments

jhodgdon’s picture

Are these two interfaces related in some way? It's not obvious to me why they can't both use the parameter name $expire to mean different things. If a class would be likely to implement both, then they'd have two methods with nearly the same name with different meanings, but otherwise... Requiring that the same parameter name has the same meaning across all uses of it would be very difficult to enforce!

olli’s picture

Thanks for the quick reply.

These two are not related in a way that a class could implement both, but they do serve a similar purpose of saving temporary data. At least for me it feels very easy to make a mistake like:
$tempStore->setWithExpire($key, $data, REQUEST_TIME + 3600)

Drupal would keep my $data for 45 years. Feel free to close this if you dont feel the same way. Or would you prefer $lifetime instead of $ttl?

jhodgdon’s picture

Definitely we should not use $ttl as a variable name, as it violates our coding standards for variable names (abbreviations are bad, writing out words is good). So $lifetime would be a better variable/parameter name. And I don't have a problem with changing the variable name... just make a patch. :)

jhodgdon’s picture

Issue tags: +Novice

This is still an issue.

I think it makes sense to rename this parameter to $time_to_live, to avoid confusion about it being a timestamp (as it is in other contexts). Good Novice issue?

Note that it needs to be changed in the Interface and any classes that implement the method (there are two).

wadmiraal’s picture

Assigned: Unassigned » wadmiraal

On it.

wadmiraal’s picture

Assigned: wadmiraal » Unassigned
Status: Active » Needs review
StatusFileSize
new2.32 KB

Here we go.

wadmiraal’s picture

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

Oops, sorry. There are actually 3 methods that have the problem :-). On it.

wadmiraal’s picture

Assigned: wadmiraal » Unassigned
Status: Needs work » Needs review
StatusFileSize
new4.66 KB
new3.64 KB
jhodgdon’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me!

Note: this is really just a docs change. Changes name of parameter to several methods, with no change in functionality.

xjm’s picture

Component: documentation » base system
Category: Bug report » Task
Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs work

Hm, I disagree that this is only a documentation change. While there is indeed no impact on calling code, changing a parameter name does have a small risk of adding a functional bug. That said, the existing parameter name is misleading, which adds some fragility, so I am considering this a prioritized change per: https://www.drupal.org/core/beta-changes#prioritized

Since the potential for disruption is very minimal, I this is okay to go into 8.0.x. Let's add a beta evaluation.

I think we also need to name the other places that the time-to-live for key value stores is named $expire. For example, see the protected property SharedTempStore::$expire (there are many similar cases).

xjm’s picture

Issue tags: -Needs work +Needs beta evaluation

Oops.

jhodgdon’s picture

Changing class member names would be actual API changes, though, as opposed to changing the parameter name in a method, which (if it's done right) does not change the API. Is it prioritized enough that this would be a good idea at this stage in the game?

xjm’s picture

Well, my thought is that it's worse to change only some references to the same quantity than either changing all of them or leaving all of them consistent. Changing a protected property name is a limited API break, but if it's too disruptive, then I don't think we should do it halfway.

A beta eval of the specific BC breaks (in things that we would add to the patch) will probably help us decide.

jhodgdon’s picture

OK then, sounds like we need a new patch and a beta evaluation. And since this is not just docs any more, I'm bowing out of the discussion.

xjm: maybe you could indicate whether you think it's even worth proceeding, since you seem unwilling to have the non-disruptive patch committed, and it's not clear the disruptive one is OK to commit? It would be annoying for someone to waste time doing a patch if it's just going to get thrown out. Or maybe we can just do the non-disruptive fix?

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

markdorison’s picture

Version: 8.1.x-dev » 8.2.x-dev
Issue tags: -Needs beta evaluation
StatusFileSize
new4.03 KB

Re-rolled the patch from #8 against 8.2.x. The additional changes in #10 still need to be addressed.

markdorison’s picture

Status: Needs work » Needs review

Updating issue status to trigger automated tests.

jhodgdon’s picture

Assigned: Unassigned » xjm

Let's assign this back to @xjm to decide what to do, based on #10-#14.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Virbius’s picture

Issue tags: +Dublin2016

From a long-term software developer's point of view, I'd say that the change away from $expire and to $time_to_live (or $time_to_timeout, as expire implies it's time left, not time to commencing) is a very sensible idea. If this is a setting that can be set through an external interface (e.g. the API), rather than just inside the method etc, then that should also be changed.

As a Novice Sprinter, though a very experienced software developer, I'm not sure what else I can add at this stage, other than running code searches to see where this code is called from and listing all those places ready for changes to be made.

xjm’s picture

Title: Rename parameter $expire in KeyValueStoreExpirableInterface » Misleading parameter name $expire in KeyValueStoreExpirableInterface
Assigned: xjm » Unassigned
Status: Needs review » Needs work

I spoke to @Virbius about this issue. Whether or not we still go forward with this depends on the specific things we will need to change. We've adopted the policy that protected properties and methods are considered internal, so we can rename them if needed to fix bugs. We can also do something like deprecate the old name and add the new one, if it's too disruptive to remove it. But the best way to decide will be to get the full scope of what might be affected. So @Virbius will do some research to see where else this might apply.

I pointed out that $time_to_live is a correct label since that's the standard terminology in caching. (The confusion here was the difference between "live" as a verb and as an adjective, I think.)

Thanks everyone!

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

ramya balasubramanian’s picture

Assigned: Unassigned » ramya balasubramanian
ramya balasubramanian’s picture

I am working on this. Will update the patch soon

ramya balasubramanian’s picture

Hi @xjm, @virbius,

I have updated the patch for 9.1. Please have a look

ramya balasubramanian’s picture

Assigned: ramya balasubramanian » Unassigned
Status: Needs work » Needs review
pradeepjha’s picture

Status: Needs review » Reviewed & tested by the community

Path is working fine. Moving it to RTBC.

xjm’s picture

Thanks for finding this unresolved issue and bringing it up to date.

#21 has still not been addressed.

  • We need to look at other places in core where it's still called $expire, including member variables, local variables, and other APIs.
  • We need to identify which should be changed for consistency.
  • If we rename member variables, etc., we should do so using deprecation for backwards compatibility.

Please make sure to read the issue and work to address the feedback rather than rerolling patches that have already been marked "Needs work". I'm removing credit for rerolls that did not incorporate the feedback. You can get credit on this issue by helping to address the needed changes. Thanks!

xjm’s picture

Status: Reviewed & tested by the community » Needs work
ramya balasubramanian’s picture

StatusFileSize
new644.65 KB

Hi @xjm,
$expire is used in 25 files in core and here I will attach the screenshot of the file's data. Please let me know the next step of this issue.

walangitan’s picture

StatusFileSize
new190.51 KB

In regards to #36, there are some files that are `$expires` and not purely `$expire` so we must be a bit cautious with replacing these. Looking at these and working on a patch that makes updates recommended from #21.

walangitan’s picture

Status: Needs work » Needs review
StatusFileSize
new29.61 KB
new36.19 KB

First pass on from the feedback xjm left on #21, #34 and the callouts from #36 and #37

This does not address or update the database definitions in the semaphore table in DatabaseLockBackend.php, left this alone in this patch, perhaps another issue entirely, just note for those searching for $expire. Awaiting the automated test results as I expect that some issues will be identified that will need to be addressed.
Variables are being renamed here and as xjm said, we should do so using deprecation for backwards compatibility, note that this is affecting a large number of variables and was not included in this patch.

himanshu_sindhwani’s picture

Status: Needs review » Needs work

Test cases are failing, Test Result (3,310 failures / +3302). Moving this to needs work.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

nitin shrivastava’s picture

StatusFileSize
new37.59 KB

re-rolled for 10.1.x

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.