Skip to content

Commit 1f1c1e6

Browse files
committed
4.1.1 Release
* Disable the initialization routine if sessions are disabled. (Fixes #79) * Defensively protect deprecated functions with `function_exists()` checks to avoid conflicts with other systems. (Fixes #80)
1 parent 8f94fd4 commit 1f1c1e6

File tree

5 files changed

+183
-146
lines changed

5 files changed

+183
-146
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ None
7070
Changelog
7171
---------
7272

73+
**4.1.1**
74+
- Fix: Defensively protect deprecated functions with `function_exists()` checks to avoid conflicts with other systems.
75+
- Fix: Disable the initialization routine if sessions are disabled.
76+
7377
**4.1.0**
7478
- Fix: Add some defense to ensure end users are running the correct version of PHP before loading the system.
7579
- Fix: Eliminate a race condition where another plugin or the theme created the session first.
@@ -178,9 +182,9 @@ Additional Information
178182
**Donate link:** https://paypal.me/eam
179183
**Tags:** session
180184
**Requires at least:** 4.7
181-
**Tested up to:** 5.0.2
185+
**Tested up to:** 5.1.0
182186
**Requires PHP:** 7.1
183-
**Stable tag:** 4.1.0
187+
**Stable tag:** 4.1.1
184188
**License:** GPLv2 or later
185189
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html
186190

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name" : "ericmann/wp-session-manager",
33
"description" : "Prototype session management for WordPress.",
4-
"version" : "4.1.0",
4+
"version" : "4.1.1",
55
"type" : "wordpress-plugin",
66
"keywords" : ["session"],
77
"homepage" : "https://github.com/ericmann/wp-session-manager",

includes/deprecated.php

Lines changed: 167 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -5,162 +5,192 @@
55
* @since 3.0
66
*/
77

8-
/**
9-
* Return the current cache expire setting.
10-
*
11-
* @deprecated 3.0 Please use native Session functionality
12-
*
13-
* @return int
14-
*/
15-
function wp_session_cache_expire(): int
16-
{
17-
_doing_it_wrong('wp_session_cache_expire', 'Please use native Session functionality: session_cache_expire', '3.0');
18-
19-
return session_cache_expire();
20-
}
8+
if (!function_exists('wp_session_cache_expire')) :
9+
/**
10+
* Return the current cache expire setting.
11+
*
12+
* @deprecated 3.0 Please use native Session functionality
13+
*
14+
* @return int
15+
*/
16+
function wp_session_cache_expire(): int
17+
{
18+
_doing_it_wrong(
19+
'wp_session_cache_expire',
20+
'Please use native Session functionality: session_cache_expire',
21+
'3.0'
22+
);
2123

22-
/**
23-
* Alias of wp_session_write_close()
24-
*
25-
* @deprecated 3.0 Please use native Session functionality
26-
*/
27-
function wp_session_commit()
28-
{
29-
_doing_it_wrong('wp_session_commit', 'Please use native Session functionality: session_write_close', '3.0');
24+
return session_cache_expire();
25+
}
26+
endif;
3027

31-
session_write_close();
32-
}
28+
if (!function_exists('wp_session_commit')) :
29+
/**
30+
* Alias of wp_session_write_close()
31+
*
32+
* @deprecated 3.0 Please use native Session functionality
33+
*/
34+
function wp_session_commit()
35+
{
36+
_doing_it_wrong('wp_session_commit', 'Please use native Session functionality: session_write_close', '3.0');
3337

34-
/**
35-
* Load a JSON-encoded string into the current session.
36-
*
37-
* @deprecated 3.0 Please use native Session functionality
38-
*
39-
* @param string $data
40-
*
41-
* @return bool
42-
*/
43-
function wp_session_decode(string $data)
44-
{
45-
_doing_it_wrong('wp_session_decode', 'Please use native Session functionality: session_decode', '3.0');
38+
session_write_close();
39+
}
40+
endif;
4641

47-
return session_decode($data);
48-
}
42+
if (!function_exists('wp_session_decode')) :
43+
/**
44+
* Load a JSON-encoded string into the current session.
45+
*
46+
* @deprecated 3.0 Please use native Session functionality
47+
*
48+
* @param string $data
49+
*
50+
* @return bool
51+
*/
52+
function wp_session_decode(string $data)
53+
{
54+
_doing_it_wrong('wp_session_decode', 'Please use native Session functionality: session_decode', '3.0');
4955

50-
/**
51-
* Encode the current session's data as a JSON string.
52-
*
53-
* @deprecated 3.0 Please use native Session functionality
54-
*
55-
* @return string
56-
*/
57-
function wp_session_encode(): string
58-
{
59-
_doing_it_wrong('wp_session_encode', 'Please use native Session functionality: session_encode', '3.0');
56+
return session_decode($data);
57+
}
58+
endif;
6059

61-
return session_encode();
62-
}
60+
if (!function_exists('wp_session_decode')) :
61+
/**
62+
* Encode the current session's data as a JSON string.
63+
*
64+
* @deprecated 3.0 Please use native Session functionality
65+
*
66+
* @return string
67+
*/
68+
function wp_session_encode(): string
69+
{
70+
_doing_it_wrong('wp_session_encode', 'Please use native Session functionality: session_encode', '3.0');
6371

64-
/**
65-
* Regenerate the session ID.
66-
*
67-
* @deprecated 3.0 Please use native Session functionality
68-
*
69-
* @param bool $delete_old_session
70-
*
71-
* @return bool
72-
*/
73-
function wp_session_regenerate_id(bool $delete_old_session = false): int
74-
{
75-
_doing_it_wrong(
76-
'wp_session_regenerate_id',
77-
'Please use native Session functionality: session_regenerate_id',
78-
'3.0'
79-
);
72+
return session_encode();
73+
}
74+
endif;
8075

81-
return session_regenerate_id($delete_old_session);
82-
}
76+
if (!function_exists('wp_session_regenerate_id')) :
77+
/**
78+
* Regenerate the session ID.
79+
*
80+
* @deprecated 3.0 Please use native Session functionality
81+
*
82+
* @param bool $delete_old_session
83+
*
84+
* @return bool
85+
*/
86+
function wp_session_regenerate_id(bool $delete_old_session = false): int
87+
{
88+
_doing_it_wrong(
89+
'wp_session_regenerate_id',
90+
'Please use native Session functionality: session_regenerate_id',
91+
'3.0'
92+
);
8393

84-
/**
85-
* Start new or resume existing session.
86-
*
87-
* Resumes an existing session based on a value sent by the _wp_session cookie.
88-
*
89-
* @deprecated 3.0 Please use native Session functionality
90-
*
91-
* @return bool
92-
*/
93-
function wp_session_start(): bool
94-
{
95-
_doing_it_wrong('wp_session_start', 'Please use native Session functionality: session_start', '3.0');
94+
return session_regenerate_id($delete_old_session);
95+
}
96+
endif;
9697

97-
do_action('wp_session_start');
98+
if (!function_exists('wp_session_start')) :
99+
/**
100+
* Start new or resume existing session.
101+
*
102+
* Resumes an existing session based on a value sent by the _wp_session cookie.
103+
*
104+
* @deprecated 3.0 Please use native Session functionality
105+
*
106+
* @return bool
107+
*/
108+
function wp_session_start(): bool
109+
{
110+
_doing_it_wrong('wp_session_start', 'Please use native Session functionality: session_start', '3.0');
98111

99-
return session_start();
100-
}
112+
do_action('wp_session_start');
101113

102-
/**
103-
* Return the current session status.
104-
*
105-
* @deprecated 3.0 Please use native Session functionality
106-
*
107-
* @return int
108-
*/
109-
function wp_session_status(): int
110-
{
111-
_doing_it_wrong('wp_session_status', 'Please use native Session functionality: session_status', '3.0');
114+
return session_start();
115+
}
116+
endif;
112117

113-
return session_status();
114-
}
118+
if (!function_exists('wp_session_status')) :
119+
/**
120+
* Return the current session status.
121+
*
122+
* @deprecated 3.0 Please use native Session functionality
123+
*
124+
* @return int
125+
*/
126+
function wp_session_status(): int
127+
{
128+
_doing_it_wrong('wp_session_status', 'Please use native Session functionality: session_status', '3.0');
115129

116-
/**
117-
* Unset all session variables.
118-
*
119-
* @deprecated 3.0 Please use native Session functionality
120-
*/
121-
function wp_session_unset()
122-
{
123-
_doing_it_wrong('wp_session_unset', 'Please use native Session functionality: session_unset', '3.0');
130+
return session_status();
131+
}
132+
endif;
124133

125-
session_unset();
126-
}
134+
if (!function_exists('wp_session_unset')) :
135+
/**
136+
* Unset all session variables.
137+
*
138+
* @deprecated 3.0 Please use native Session functionality
139+
*/
140+
function wp_session_unset()
141+
{
142+
_doing_it_wrong('wp_session_unset', 'Please use native Session functionality: session_unset', '3.0');
127143

128-
/**
129-
* Write session data and end session
130-
*
131-
* @deprecated 3.0 Please use native Session functionality
132-
*/
133-
function wp_session_write_close()
134-
{
135-
_doing_it_wrong('wp_session_write_close', 'Please use native Session functionality: session_write_close', '3.0');
144+
session_unset();
145+
}
146+
endif;
136147

137-
session_write_close();
138-
do_action('wp_session_commit');
139-
}
148+
if (!function_exists('wp_session_write_close')) :
149+
/**
150+
* Write session data and end session
151+
*
152+
* @deprecated 3.0 Please use native Session functionality
153+
*/
154+
function wp_session_write_close()
155+
{
156+
_doing_it_wrong(
157+
'wp_session_write_close',
158+
'Please use native Session functionality: session_write_close',
159+
'3.0'
160+
);
161+
162+
session_write_close();
163+
do_action('wp_session_commit');
164+
}
165+
endif;
140166

141-
/**
142-
* Clean up expired sessions by removing data and their expiration entries from
143-
* the WordPress options table.
144-
*
145-
* This method should never be called directly and should instead be triggered as part
146-
* of a scheduled task or cron job.
147-
*
148-
* @deprecated 3.0
149-
*/
150-
function wp_session_cleanup()
151-
{
152-
_doing_it_wrong('wp_session_cleanup', 'Sessions are cleaned up natively.', '3.0');
153-
}
167+
if (!function_exists('wp_session_cleanup')) :
168+
/**
169+
* Clean up expired sessions by removing data and their expiration entries from
170+
* the WordPress options table.
171+
*
172+
* This method should never be called directly and should instead be triggered as part
173+
* of a scheduled task or cron job.
174+
*
175+
* @deprecated 3.0
176+
*/
177+
function wp_session_cleanup()
178+
{
179+
_doing_it_wrong('wp_session_cleanup', 'Sessions are cleaned up natively.', '3.0');
180+
}
181+
endif;
154182

155-
/**
156-
* Register the garbage collector as a twice daily event.
157-
*
158-
* @deprecated 3.0
159-
*/
160-
function wp_session_register_garbage_collection()
161-
{
162-
_doing_it_wrong('wp_session_register_garbage_collection', 'Sessions are cleaned up natively.', '3.0');
163-
}
183+
if (!function_exists('wp_session_register_garbage_collection')) :
184+
/**
185+
* Register the garbage collector as a twice daily event.
186+
*
187+
* @deprecated 3.0
188+
*/
189+
function wp_session_register_garbage_collection()
190+
{
191+
_doing_it_wrong('wp_session_register_garbage_collection', 'Sessions are cleaned up natively.', '3.0');
192+
}
193+
endif;
164194

165195
// phpcs:disable
166196
if (!class_exists('WP_Session')) :

readme.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ Contributors: ericmann
33
Donate link: https://paypal.me/eam
44
Tags: session
55
Requires at least: 4.7
6-
Tested up to: 5.0.2
6+
Tested up to: 5.1.0
77
Requires PHP: 7.1
8-
Stable tag: 4.1.0
8+
Stable tag: 4.1.1
99
License: GPLv2 or later
1010
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1111

@@ -74,6 +74,10 @@ None
7474

7575
== Changelog ==
7676

77+
= 4.1.1 =
78+
* Fix: Defensively protect deprecated functions with `function_exists()` checks to avoid conflicts with other systems.
79+
- Fix: Disable the initialization routine if sessions are disabled.
80+
7781
= 4.1.0 =
7882
* Fix: Add some defense to ensure end users are running the correct version of PHP before loading the system.
7983
* Fix: Eliminate a race condition where another plugin or the theme created the session first.

0 commit comments

Comments
 (0)