Closed (fixed)
Project:
Drupal core
Version:
7.x-dev
Component:
base system
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
1 May 2008 at 22:15 UTC
Updated:
21 Dec 2009 at 04:07 UTC
Jump to comment: Most recent file
Comments
Comment #1
jscheel commentedSorry, changing category.
Comment #2
beeradb commentedI haven't had a chance to test the patch yet, but +1 for documentation, as well as the clarity of renaming the functions. My gut feeling is this should be "normal" priority rather than minor, since it introduces documentation to previously undocumented functions, and adds clarity all around.
Comment #3
jscheel commentedOk, I am changing the priority to normal.
Comment #4
jscheel commentedOk, after a discussion with chx on irc, I am marking this as needs work. I need to rewrite all of this more thoroughly. Patch coming soon.
Comment #5
jscheel commentedHere's a new patch with the updated documentation. Also, at the suggestion of chx, I have removed the arguments for session_open() because they are never used. Keep in mind, this patch prefixes the functions with an underscore to reinforce the fact that they should not be used directly (private).
Comment #6
jscheel commentedComment #7
gpk commentedLooks a huge improvement :)
What about the changes to bootstrap.inc and cache.inc that were in the original patch?
Some minor comments on the documentation:
First a general comment - the documentation for the first 2 functions describes what they do in general, whereas for the last 2 it describes the Drupal implmentation specifically. I've suggested specific changes for better consitency below.
1. Suggest changing
to
2. I don't understand the documentation for _sess_open() - I thought that http://uk3.php.net/manual/en/function.session-save-path.php is what is used to set the save path, and anyway the save path is not used in Drupal...
3. _sess_close(): Suggest changing
to
4. _sess_read(): Suggest changing
to
5. _sess_write(): Suggest changing
to
6. Suggest changing
to
7. Suggest removing
from the documentation of _sess_open() and _sess_close().
Also some of the documentation lines are longer than the 80 character limit (coding standards).
Sorry, rather more suggested changes here than I originally intended!
Comment #8
jscheel commented@gpk: Thanks for the suggestions. I'll get a new patched rolled shortly (been super busy).
Comment #9
jscheel commentedOk, here is a new patch. Sorry it took so long in coming, I've been crazy busy :P
Comment #10
gpk commentedThanks for update, looking good :)
A few final comments, pretty minor stuff really:
- At the top, maybe replace "The user-level session save handlers:" with "The user-level session storage handlers:" (which is how PHP doc describes them)
- The list of 4 handlers omits 2 - gc and destroy_sid. Obviously the last 2 *can* be called directly.
- "and are called by PHP" -> "and are called automatically by PHP"
- The comment "This function should not be called directly." actually still looks a bit unnecessary to me in the context of _sess_open() and _sess_close() - I mean, calling these directly basically does nothing, is therefore harmless, and also there is no reason that anyone would want to in a Drupal app. Suggest removing these 2 instances.
- "This function will be called by PHP to retrieve the current user's session data from the database. It also loads the current user's appropriate roles into the user object."
--> - "This function will be called by PHP to retrieve the current user's session data, which is stored in the database. It also loads the user's roles into the user object."
- "This function will be called by PHP to store the current user's session to the database." -> "This function will be called by PHP to store the current user's session, which Drupal saves to the database."
Hope this is helpful, have not actually tested the fairly trival code changes but all looks OK.
Comment #11
chx commentedHoly batman! Very very nice work! Keep going.
Comment #12
jscheel commented@gpk, thanks for all the suggestions! I'll work on that this afternoon. The user registration test should work for this, but I can write a new one if needed.
Comment #13
jscheel commentedWell, darn, 9 weeks and I haven't been able to touch this. We have a long weekend here in the US, so I'll try to take some time to finish this up!
Comment #14
jscheel commentedHere's the new patch. I made most of the changes gpk suggested, but I did leave in the "function should not be called directly" because I believe it adds clarification. What do you guys think?
Comment #15
jscheel commentedComment #16
dries commentedExcellent patch! Committed to CVS HEAD. Thanks jscheel and gpk.
Comment #17
dries commentedOops, meant to mark them as 'fixed'.
Comment #18
gpk commentedFantastic, thanks Dries :) and especially jscheel for doing the bulk of the donkey-work :) :)
Comment #19
damien tournoud commentedSorry to reopen this, but why not marking sess_destroy_sid and sess_gc private? These are also session callback functions registered by
session_set_save_handler(), and they should not (and are not) called directly.Comment #20
gpk commentedAlso the PHPdoc of _sess_open() and _sess_close() is not working - can't see why. And the documentation parser is stripping out an opening bracket and leaving
session_set_save_handler)in a few places. See http://api.drupal.org/api/file/includes/session.inc/7. Hardly earth-shattering but a bit odd. sess_gc (or _sess_gc) is also missing documentation.Comment #21
jscheel commentedOdd, not sure what's up with the parser. I'll look through everything again and see if I can find anything.
sess_gc() and sess_destroy_sid() shouldn't be marked private because you can theoretically use them, at least that was Clouseau's reasoning he gave when he saw that I had them marked as private. What do you guys think, should we just mark all of the session handlers private?
@gpk Thanks for all of the input!
Comment #22
damien tournoud commented@jsheel: I would like to see sess_gc an sess_destroy_sid marked as private. Those are also callbacks of the PHP session handler and should not be used directly. Instead, you can use the public PHP function session_destroy to kill a session. You should not have to trigger a garbage collection manually.
Comment #23
damien tournoud commented@jsheel: could you please also fix the last lines of your docbook comments? You are missing the leading space in all of them:
should be:
Comment #24
gpk commented@23: Thanks Damien, I couldn't see that for the looking!
Comment #25
damien tournoud commentedHere is an extension for this.
This new patch:
- privatize _sess_gc and _sess_destroy_sid
- prefix all public functions with
drupal_to clarify their use. session_regenerate is drupal_session_regenerate, session_count is drupal_session_count, session_destroy_uid is drupal_session_destroy_uid, session_save_session is now drupal_save_session- fixed the doxygen from session.inc
Comment #26
catchMakes sense to rename the functions to drupal_ - consistent with similar functions elsewhere in core. The other fixes look fine. No time to run tests now though so could do with another review.
Comment #27
damien tournoud commentedApparently not all the chunk got in the previous patch.
Comment #28
dries commentedCommitted this to CVS HEAD. Thanks!
I'm marking this as 'code needs work' because we need to update the upgrade instructions in the handbook.
Comment #29
damien tournoud commentedThis may have broken the file tests that got in this morning (and used session_save_session).
Comment #30
catchIt did. Patch.
Comment #31
damien tournoud commentedThanks catch.
Comment #32
webchickCommitted. Thanks!
Comment #33
beeradb commentedmarking back as "code needs work" for the handbook additions Dries requested in #28
Comment #34
beeradb commentedTests no longer broken (I presume...)
Comment #35
gpk commentedhttp://api.drupal.org/api/file/includes/session.inc/7 looks much more sane now, however the Description section of the PHPdoc needs fixing. Attached patch does that, and also corrects documentation of http://api.drupal.org/api/function/drupal_session_count/7 (it looks as if the patch from #293421: Documentation for sess_count is wrong did not apply properly). Also some further comments cleanup.
Is it worth improving the naming of drupal_save_session() - which despite its name does not actually save the session. How about drupal_set_session_save() (and maybe pair it with a new drupal_get_session_save()) ??
I presume that in #28 Dries was referring to the module update instructions? http://drupal.org/node/224333.
Comment #36
drewish commentedi'll chime in that drupal_save_session() is a pretty bad name for a function that doesn't save the session.
Comment #37
jscheel commentedHey, sorry I've been awol for a while... been heads down with work :P I'm gonna throw my vote in with gpk, drupal_save_session() needs to be renamed. Awesome work on this!
Comment #38
dries commentedThis patch no longer applies because of the REQUEST_TIME changes. Will need a quick re-roll.
Let's deal with the naming of drupal_save_session() after the reroll. It might be a bad name, but I need to investigate where the function is used, and why.
Comment #39
gpk commented@38: IIRC drupal_save_session() is not used in core (except in http://api.drupal.org/api/function/_sess_write/7 - to check whether to save session data - and in a test).
The PHPdoc of http://api.drupal.org/api/function/drupal_save_session/7 is helpful and the handbook page referenced there (http://drupal.org/node/218104) gives further info.
Ah, so that page will also need updating in due course as the function is no longer called session_save_session() ..!
Comment #40
redndahead commentedBy the looks at the latest patch a lot has changed since then. Does this need to be fixed anymore?
Comment #41
moshe weitzman commentedMuch session stuff has changed. Reopen as needed.