Skip to content

Commit

Permalink
4.1.1 Release
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
ericmann committed Feb 16, 2019
1 parent 8f94fd4 commit 1f1c1e6
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 146 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ None
Changelog
---------

**4.1.1**
- Fix: Defensively protect deprecated functions with `function_exists()` checks to avoid conflicts with other systems.
- Fix: Disable the initialization routine if sessions are disabled.

**4.1.0**
- Fix: Add some defense to ensure end users are running the correct version of PHP before loading the system.
- Fix: Eliminate a race condition where another plugin or the theme created the session first.
Expand Down Expand Up @@ -178,9 +182,9 @@ Additional Information
**Donate link:** https://paypal.me/eam
**Tags:** session
**Requires at least:** 4.7
**Tested up to:** 5.0.2
**Tested up to:** 5.1.0
**Requires PHP:** 7.1
**Stable tag:** 4.1.0
**Stable tag:** 4.1.1
**License:** GPLv2 or later
**License URI:** http://www.gnu.org/licenses/gpl-2.0.html

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name" : "ericmann/wp-session-manager",
"description" : "Prototype session management for WordPress.",
"version" : "4.1.0",
"version" : "4.1.1",
"type" : "wordpress-plugin",
"keywords" : ["session"],
"homepage" : "https://github.com/ericmann/wp-session-manager",
Expand Down
304 changes: 167 additions & 137 deletions includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,162 +5,192 @@
* @since 3.0
*/

/**
* Return the current cache expire setting.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return int
*/
function wp_session_cache_expire(): int
{
_doing_it_wrong('wp_session_cache_expire', 'Please use native Session functionality: session_cache_expire', '3.0');

return session_cache_expire();
}
if (!function_exists('wp_session_cache_expire')) :
/**
* Return the current cache expire setting.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return int
*/
function wp_session_cache_expire(): int
{
_doing_it_wrong(
'wp_session_cache_expire',
'Please use native Session functionality: session_cache_expire',
'3.0'
);

/**
* Alias of wp_session_write_close()
*
* @deprecated 3.0 Please use native Session functionality
*/
function wp_session_commit()
{
_doing_it_wrong('wp_session_commit', 'Please use native Session functionality: session_write_close', '3.0');
return session_cache_expire();
}
endif;

session_write_close();
}
if (!function_exists('wp_session_commit')) :
/**
* Alias of wp_session_write_close()
*
* @deprecated 3.0 Please use native Session functionality
*/
function wp_session_commit()
{
_doing_it_wrong('wp_session_commit', 'Please use native Session functionality: session_write_close', '3.0');

/**
* Load a JSON-encoded string into the current session.
*
* @deprecated 3.0 Please use native Session functionality
*
* @param string $data
*
* @return bool
*/
function wp_session_decode(string $data)
{
_doing_it_wrong('wp_session_decode', 'Please use native Session functionality: session_decode', '3.0');
session_write_close();
}
endif;

return session_decode($data);
}
if (!function_exists('wp_session_decode')) :
/**
* Load a JSON-encoded string into the current session.
*
* @deprecated 3.0 Please use native Session functionality
*
* @param string $data
*
* @return bool
*/
function wp_session_decode(string $data)
{
_doing_it_wrong('wp_session_decode', 'Please use native Session functionality: session_decode', '3.0');

/**
* Encode the current session's data as a JSON string.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return string
*/
function wp_session_encode(): string
{
_doing_it_wrong('wp_session_encode', 'Please use native Session functionality: session_encode', '3.0');
return session_decode($data);
}
endif;

return session_encode();
}
if (!function_exists('wp_session_decode')) :
/**
* Encode the current session's data as a JSON string.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return string
*/
function wp_session_encode(): string
{
_doing_it_wrong('wp_session_encode', 'Please use native Session functionality: session_encode', '3.0');

/**
* Regenerate the session ID.
*
* @deprecated 3.0 Please use native Session functionality
*
* @param bool $delete_old_session
*
* @return bool
*/
function wp_session_regenerate_id(bool $delete_old_session = false): int
{
_doing_it_wrong(
'wp_session_regenerate_id',
'Please use native Session functionality: session_regenerate_id',
'3.0'
);
return session_encode();
}
endif;

return session_regenerate_id($delete_old_session);
}
if (!function_exists('wp_session_regenerate_id')) :
/**
* Regenerate the session ID.
*
* @deprecated 3.0 Please use native Session functionality
*
* @param bool $delete_old_session
*
* @return bool
*/
function wp_session_regenerate_id(bool $delete_old_session = false): int
{
_doing_it_wrong(
'wp_session_regenerate_id',
'Please use native Session functionality: session_regenerate_id',
'3.0'
);

/**
* Start new or resume existing session.
*
* Resumes an existing session based on a value sent by the _wp_session cookie.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return bool
*/
function wp_session_start(): bool
{
_doing_it_wrong('wp_session_start', 'Please use native Session functionality: session_start', '3.0');
return session_regenerate_id($delete_old_session);
}
endif;

do_action('wp_session_start');
if (!function_exists('wp_session_start')) :
/**
* Start new or resume existing session.
*
* Resumes an existing session based on a value sent by the _wp_session cookie.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return bool
*/
function wp_session_start(): bool
{
_doing_it_wrong('wp_session_start', 'Please use native Session functionality: session_start', '3.0');

return session_start();
}
do_action('wp_session_start');

/**
* Return the current session status.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return int
*/
function wp_session_status(): int
{
_doing_it_wrong('wp_session_status', 'Please use native Session functionality: session_status', '3.0');
return session_start();
}
endif;

return session_status();
}
if (!function_exists('wp_session_status')) :
/**
* Return the current session status.
*
* @deprecated 3.0 Please use native Session functionality
*
* @return int
*/
function wp_session_status(): int
{
_doing_it_wrong('wp_session_status', 'Please use native Session functionality: session_status', '3.0');

/**
* Unset all session variables.
*
* @deprecated 3.0 Please use native Session functionality
*/
function wp_session_unset()
{
_doing_it_wrong('wp_session_unset', 'Please use native Session functionality: session_unset', '3.0');
return session_status();
}
endif;

session_unset();
}
if (!function_exists('wp_session_unset')) :
/**
* Unset all session variables.
*
* @deprecated 3.0 Please use native Session functionality
*/
function wp_session_unset()
{
_doing_it_wrong('wp_session_unset', 'Please use native Session functionality: session_unset', '3.0');

/**
* Write session data and end session
*
* @deprecated 3.0 Please use native Session functionality
*/
function wp_session_write_close()
{
_doing_it_wrong('wp_session_write_close', 'Please use native Session functionality: session_write_close', '3.0');
session_unset();
}
endif;

session_write_close();
do_action('wp_session_commit');
}
if (!function_exists('wp_session_write_close')) :
/**
* Write session data and end session
*
* @deprecated 3.0 Please use native Session functionality
*/
function wp_session_write_close()
{
_doing_it_wrong(
'wp_session_write_close',
'Please use native Session functionality: session_write_close',
'3.0'
);

session_write_close();
do_action('wp_session_commit');
}
endif;

/**
* Clean up expired sessions by removing data and their expiration entries from
* the WordPress options table.
*
* This method should never be called directly and should instead be triggered as part
* of a scheduled task or cron job.
*
* @deprecated 3.0
*/
function wp_session_cleanup()
{
_doing_it_wrong('wp_session_cleanup', 'Sessions are cleaned up natively.', '3.0');
}
if (!function_exists('wp_session_cleanup')) :
/**
* Clean up expired sessions by removing data and their expiration entries from
* the WordPress options table.
*
* This method should never be called directly and should instead be triggered as part
* of a scheduled task or cron job.
*
* @deprecated 3.0
*/
function wp_session_cleanup()
{
_doing_it_wrong('wp_session_cleanup', 'Sessions are cleaned up natively.', '3.0');
}
endif;

/**
* Register the garbage collector as a twice daily event.
*
* @deprecated 3.0
*/
function wp_session_register_garbage_collection()
{
_doing_it_wrong('wp_session_register_garbage_collection', 'Sessions are cleaned up natively.', '3.0');
}
if (!function_exists('wp_session_register_garbage_collection')) :
/**
* Register the garbage collector as a twice daily event.
*
* @deprecated 3.0
*/
function wp_session_register_garbage_collection()
{
_doing_it_wrong('wp_session_register_garbage_collection', 'Sessions are cleaned up natively.', '3.0');
}
endif;

// phpcs:disable
if (!class_exists('WP_Session')) :
Expand Down
8 changes: 6 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Contributors: ericmann
Donate link: https://paypal.me/eam
Tags: session
Requires at least: 4.7
Tested up to: 5.0.2
Tested up to: 5.1.0
Requires PHP: 7.1
Stable tag: 4.1.0
Stable tag: 4.1.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -74,6 +74,10 @@ None

== Changelog ==

= 4.1.1 =
* Fix: Defensively protect deprecated functions with `function_exists()` checks to avoid conflicts with other systems.
- Fix: Disable the initialization routine if sessions are disabled.

= 4.1.0 =
* Fix: Add some defense to ensure end users are running the correct version of PHP before loading the system.
* Fix: Eliminate a race condition where another plugin or the theme created the session first.
Expand Down
Loading

0 comments on commit 1f1c1e6

Please sign in to comment.