Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The lock() function found in bootstrap.inc has been marked as deprecated. The code comment instructs that it can be replaced with Drupal::lock().
We should replace every instance of lock() with \Drupal::lock().
Should we also remove the lock function from bootstrap.inc?
Comment | File | Size | Author |
---|---|---|---|
#29 | drupal_2044367_29.patch | 13.97 KB | Xano |
Comments
Comment #1
wildflower_0002 CreditAttribution: wildflower_0002 commentedChanged lock() to Drupal::lock()
Comment #3
wildflower_0002 CreditAttribution: wildflower_0002 commented#1: 2044367_2.patch queued for re-testing.
Comment #5
wildflower_0002 CreditAttribution: wildflower_0002 commentedChanged lock() to Drupal::lock()
Comment #6.0
(not verified) CreditAttribution: commenteds/depreciated/deprecated/
Comment #7
sunComment #8
InternetDevels CreditAttribution: InternetDevels commentedAs we replaced lock() function in all places we think it makes sense to remove it from bootstrap.inc. Patch attached.
Comment #9
sunHm. I wanted to RTBC, but what do we do with this (helpful) documentation group?
It does not fit into any of the interfaces or classes in Drupal\Core\Lock, as these docs are rather bird-level.
Normally, in PHP components/libraries, each component ships with an own README.md file, so as to be able to provide high-level anatomy and usage docs.
Perhaps we should start to do that for core components, too?
I.e., simply move the phpDoc lines into a new README.md or README.txt file in /core/lib/Drupal/Core/Lock?
(I'd prefer .md, but I don't think we have any .md files at this point)
Comment #10
InternetDevels CreditAttribution: InternetDevels commentedWe've saved documentation with attached patch :)
Comment #11
ParisLiakos CreditAttribution: ParisLiakos commentedi would love sun's proposal (having those info in README.md in
Drupal/Core/Lock
) but then i dont think those info would appear to api.drupal.org? so lets have it in \Drupal::lock() for now.Patch needs reroll
Comment #12
InternetDevels CreditAttribution: InternetDevels commentedReroll.
Comment #13
InternetDevels CreditAttribution: InternetDevels commentedChanged status.
Comment #14
BerdirThat documentation isn't on the function, it is a @defgroup. There is no need to remove that and move it to a specific function, I think they can live anywhere in a file that is parsed? We should rather make sure that all relevant interfaces and methods are part of that defgroup.
See https://api.drupal.org/api/drupal/core%21includes%21bootstrap.inc/group/...
That is kind of sad right now :) That should eventually list the interface, \Drupal::lock() method and the service, once we can handle them in a useful way.
Comment #15
jhodgdon@defgroups can indeed live anywhere.
If they don't have a good home near some related functions, a good idea is to put them into a .api.php file in the system.module directory, or maybe in core itself?. We discussed on some other issue recently making a catch-all core.api.php file for such topics, but I don't think it's been done.
Comment #16
BerdirNote: To add something to a group/topic, add @ingroup lock to it.
Comment #17
BerdirMaybe like this, move the @defgroup to the interface file? Also added ingroups and verified on a local installation, see screenshot.
Comment #18
jhodgdonI think moving this to the interface file is OK... technically if you have a @defgroup @{ you should also have a @} at the end, though if the file ends that would be implied. Keeping the @defgroup next to the class that is included is probably a good idea.
Comment #19
jhodgdonhttps://drupal.org/node/1354#defgroup
Comment #20
BerdirSure, I didn't even notice the @{ there, I guess would also remove that, but this works too.
Anything else left to do here?
I thought about creating a draft notice, but I'm actually not sure, because we do https://drupal.org/node/1525118, so it might be better to just update that one. I could create an additional one for the 8.x -> 8.x change, but not sure if it's worth it.
Comment #21
jhodgdonThe @{ says "Everything between this and the @} are part of the documentation of this topic and/or are things to be included", so you do need that.
IMO, editing an existing change notice that is no longer accurate is definitely a good idea, so people don't find the older change notice and get misleading information on how to update from 7 to 8. I would suggest putting language in there like "Later in the course of Drupal 8 development, these deprecated functions were removed: ...".
For people subscribing to change notices RSS (there is an RSS feed, although I have no idea if anyone subscribes), you can also create a very short change notice saying something like "During the Drupal 8 cycle, the function ... that had previously been deprecated was removed. See ... for more details."
Comment #22
sun@jhodgdon is right about the closing @defgroup tag, but I don't think it makes sense to add one to the end of the interface file, because PSR-N standards are enforcing already that a single file only contains a single interface/class/trait.
Even though I'd vastly prefer README.md files in each component (the de-facto standard for PHP components/libraries), I like the idea of moving our former high-level @defgroup documentation onto the primary interfaces.
I wonder whether we could simplify this some more and bake the @defgroup right into the interface?
In other words: Skipping the opening and closing @{ and @} phpDoc grouping tags altogether.
Comment #23
jhodgdonThe idea in #22 will not work without rewriting the way defgroups work in the API module, which I would prefer not to do please. @defgroup is not supported at all (nor anything like it) by the PSR-5 standard, in spite of my asking politely that they consider having this... they are not open to revisions apparently. We have had defgroup docs done the way we are doing them now for ages...
There isn't really a problem with leaving the @{ open except for editors possibly complaining about unclosed parens. Alternatively you can close the @} at the end of the defgroup documentation, and then put @ingroup into the interface docs. But please do not try to combine them. Thanks!
Comment #24
ParisLiakos CreditAttribution: ParisLiakos commentedso, something like that :)
also made the test to use $this->container rathen than \Drupal global
Comment #25
jhodgdonThat placement of the defgroup works for me. I think some people didn't want it in the same file as the interface itself, but I personally don't mind.
Comment #26
ianthomas_ukI have updated the existing change record, see https://drupal.org/node/1525118/revisions/view/2355494/6937569. Although the example is procedural, I've assigned the lock service to a variable so the same code applies in objects.
I've previously been told by a core maintainer (webchick IIRC) that change records are not intended for 8.x-dev to 8.x-dev upgrades and should just give the instructions for upgrading from 7.x. I think this makes sense, and provides the most readable change records for the people who are most likely to use them. If anyone is subscribing to them using RSS, then I'd suggest they switch to looking at the commit log instead.
I've rolled a new patch that keeps the lock() function itself (the current preference is that functions should be removed in simple patches to minimise the risk of HEAD breaking). I've also changed the documentation to use a $lock variable instead of \Drupal::lock(), again so the code applies to both procedural and OO code.
Comment #27
ParisLiakos CreditAttribution: ParisLiakos commentedsounds good, lets do it
Comment #28
ParisLiakos CreditAttribution: ParisLiakos commentedComment #29
XanoRe-roll.
Comment #30
ianthomas_ukReroll is good, was just context conflicts with the recent cache() and @deprecated patches.
Comment #31
webchickLooks like this is covered in the change notice at https://drupal.org/node/1525118
Committed and pushed to 8.x. Thanks!