Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
6b24aa52
Commit
6b24aa52
authored
10 years ago
by
cetra3
Browse files
Options
Downloads
Patches
Plain Diff
Refactor internal session to write directly to $_SESSION
parent
53f3b7ab
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/private/session/internal.php
+37
-7
37 additions, 7 deletions
lib/private/session/internal.php
with
37 additions
and
7 deletions
lib/private/session/internal.php
+
37
−
7
View file @
6b24aa52
...
...
@@ -15,46 +15,76 @@ namespace OC\Session;
*
* @package OC\Session
*/
class
Internal
extends
Memory
{
class
Internal
extends
Session
{
public
function
__construct
(
$name
)
{
session_name
(
$name
);
session_start
();
if
(
!
isset
(
$_SESSION
))
{
throw
new
\Exception
(
'Failed to start session'
);
}
$this
->
data
=
$_SESSION
;
}
public
function
__destruct
()
{
$this
->
close
();
}
/**
* @param string $key
* @param integer $value
*/
public
function
set
(
$key
,
$value
)
{
$this
->
validateSession
();
$_SESSION
[
$key
]
=
$value
;
}
/**
* @param string $key
* @return mixed
*/
public
function
get
(
$key
)
{
if
(
!
$this
->
exists
(
$key
))
{
return
null
;
}
return
$_SESSION
[
$key
];
}
/**
* @param string $key
* @return bool
*/
public
function
exists
(
$key
)
{
return
isset
(
$_SESSION
[
$key
]);
}
/**
* @param string $key
*/
public
function
remove
(
$key
)
{
// also remove it from $_SESSION to prevent re-setting the old value during the merge
if
(
isset
(
$_SESSION
[
$key
]))
{
unset
(
$_SESSION
[
$key
]);
}
parent
::
remove
(
$key
);
}
public
function
clear
()
{
session_unset
();
@
session_regenerate_id
(
true
);
@
session_start
();
$this
->
data
=
$_SESSION
=
array
();
$_SESSION
=
array
();
}
public
function
close
()
{
$_SESSION
=
array_merge
(
$_SESSION
,
$this
->
data
);
session_write_close
();
parent
::
close
();
}
public
function
reopen
()
{
throw
new
\Exception
(
'The session cannot be reopened - reopen() is ony to be used in unit testing.'
);
}
private
function
validateSession
()
{
if
(
$this
->
sessionClosed
)
{
throw
new
\Exception
(
'Session has been closed - no further changes to the session as allowed'
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment