Permalink
Browse files

less mucking around with the PHP include path

the calls to restore_include_path seem to be causing problems with other
WordPress plugins (like [instapress][]) because it resets the include
path to the master value set in php.ini, thereby losing any
modifications made by other plugins.  So instead of constantly setting
the include path and then restoring it, we set it once at the beginning
of loading the plugin, and then just leave it alone.  In order to
prevent any accidental conflicts, I'm also moving the OpenID library
into a dedicated lib directory to ensure that we're only adding the
library to the include path, not all files in the plugin directory.

[instapress]: http://wordpress.org/support/topic/plugin-openid-openid-conflicting-with-instapress-plugin
  • Loading branch information...
1 parent 404f32b commit 6529cf33377c6bcb573555986a4f989970b44839 @willnorris willnorris committed Dec 31, 2011
Showing with 9 additions and 21 deletions.
  1. +0 −3 admin_panels.php
  2. +0 −2 common.php
  3. +0 −6 consumer.php
  4. 0 { → lib}/Auth/OpenID.php
  5. 0 { → lib}/Auth/OpenID/AX.php
  6. 0 { → lib}/Auth/OpenID/Association.php
  7. 0 { → lib}/Auth/OpenID/BigMath.php
  8. 0 { → lib}/Auth/OpenID/Consumer.php
  9. 0 { → lib}/Auth/OpenID/CryptUtil.php
  10. 0 { → lib}/Auth/OpenID/DatabaseConnection.php
  11. 0 { → lib}/Auth/OpenID/DiffieHellman.php
  12. 0 { → lib}/Auth/OpenID/Discover.php
  13. 0 { → lib}/Auth/OpenID/DumbStore.php
  14. 0 { → lib}/Auth/OpenID/Extension.php
  15. 0 { → lib}/Auth/OpenID/FileStore.php
  16. 0 { → lib}/Auth/OpenID/HMAC.php
  17. 0 { → lib}/Auth/OpenID/Interface.php
  18. 0 { → lib}/Auth/OpenID/KVForm.php
  19. 0 { → lib}/Auth/OpenID/MDB2Store.php
  20. 0 { → lib}/Auth/OpenID/MemcachedStore.php
  21. 0 { → lib}/Auth/OpenID/Message.php
  22. 0 { → lib}/Auth/OpenID/MySQLStore.php
  23. 0 { → lib}/Auth/OpenID/Nonce.php
  24. 0 { → lib}/Auth/OpenID/PAPE.php
  25. 0 { → lib}/Auth/OpenID/Parse.php
  26. 0 { → lib}/Auth/OpenID/PostgreSQLStore.php
  27. 0 { → lib}/Auth/OpenID/SQLStore.php
  28. 0 { → lib}/Auth/OpenID/SQLiteStore.php
  29. 0 { → lib}/Auth/OpenID/SReg.php
  30. 0 { → lib}/Auth/OpenID/Server.php
  31. 0 { → lib}/Auth/OpenID/ServerRequest.php
  32. 0 { → lib}/Auth/OpenID/TrustRoot.php
  33. 0 { → lib}/Auth/OpenID/URINorm.php
  34. 0 { → lib}/Auth/Yadis/HTTPFetcher.php
  35. 0 { → lib}/Auth/Yadis/Manager.php
  36. 0 { → lib}/Auth/Yadis/Misc.php
  37. 0 { → lib}/Auth/Yadis/ParanoidHTTPFetcher.php
  38. 0 { → lib}/Auth/Yadis/ParseHTML.php
  39. 0 { → lib}/Auth/Yadis/PlainHTTPFetcher.php
  40. 0 { → lib}/Auth/Yadis/XML.php
  41. 0 { → lib}/Auth/Yadis/XRDS.php
  42. 0 { → lib}/Auth/Yadis/XRI.php
  43. 0 { → lib}/Auth/Yadis/XRIRes.php
  44. 0 { → lib}/Auth/Yadis/Yadis.php
  45. +9 −10 openid.php
View
@@ -741,7 +741,6 @@ function openid_profile_delete_openids($delete) {
openid_status('success');
// ensure that profile URL is still a verified OpenID
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'Auth/OpenID.php';
@include_once(ABSPATH . WPINC . '/registration.php'); // WP < 2.3
@include_once(ABSPATH . 'wp-admin/includes/admin.php'); // WP >= 2.3
@@ -781,7 +780,6 @@ function openid_finish_verify($identity_url, $action) {
$message = 3;
// ensure that profile URL is a verified OpenID
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'Auth/OpenID.php';
require_once(ABSPATH . 'wp-admin/includes/admin.php');
@@ -824,7 +822,6 @@ function openid_ensure_url_match($user, $url = null) {
$identities = get_user_openids($user->ID);
if (empty($identities)) return true;
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'Auth/OpenID.php';
if ($url == null) $url = $user->user_url;
View
@@ -422,9 +422,7 @@ function openid_get_user_data($identity_url) {
* @see get_user_data
*/
function openid_get_user_data_ax($data, $identity_url) {
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once('Auth/OpenID/AX.php');
- restore_include_path();
$response = openid_response();
$ax = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
View
@@ -19,9 +19,7 @@ function openid_getConsumer() {
static $consumer;
if (!$consumer) {
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once 'Auth/OpenID/Consumer.php';
- restore_include_path();
$store = openid_getStore();
$consumer = new Auth_OpenID_Consumer($store);
@@ -185,9 +183,7 @@ function openid_start_login( $claimed_url, $action, $finish_url = null) {
*/
function openid_add_ax_extension($extensions, $auth_request) {
if(!get_user_by_openid($auth_request->endpoint->claimed_id)) {
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once('Auth/OpenID/AX.php');
- restore_include_path();
if ($auth_request->endpoint->usesExtension(Auth_OpenID_AX_NS_URI)) {
$ax_request = new Auth_OpenID_AX_FetchRequest();
@@ -208,9 +204,7 @@ function openid_add_ax_extension($extensions, $auth_request) {
*/
function openid_add_sreg_extension($extensions, $auth_request) {
if(!get_user_by_openid($auth_request->endpoint->claimed_id)) {
- set_include_path( dirname(__FILE__) . PATH_SEPARATOR . get_include_path() );
require_once('Auth/OpenID/SReg.php');
- restore_include_path();
if ($auth_request->endpoint->usesExtension(Auth_OpenID_SREG_NS_URI_1_0) || $auth_request->endpoint->usesExtension(Auth_OpenID_SREG_NS_URI_1_1)) {
$extensions[] = Auth_OpenID_SRegRequest::build(array(),array('nickname','email','fullname'));
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -16,23 +16,22 @@
// last plugin revision that required database schema changes
define ( 'OPENID_DB_REVISION', 24426);
-
-$openid_include_path = dirname(__FILE__);
+$openid_include_path = dirname(__FILE__) . '/lib';
// check source of randomness
if ( !@is_readable('/dev/urandom') ) {
define('Auth_OpenID_RAND_SOURCE', null);
}
set_include_path( $openid_include_path . PATH_SEPARATOR . get_include_path() );
-require_once 'common.php';
-require_once 'consumer.php';
-require_once 'admin_panels.php';
-require_once 'comments.php';
-require_once 'login.php';
-require_once 'server.php';
-require_once 'store.php';
-restore_include_path();
+
+require_once dirname(__FILE__) . '/common.php';
+require_once dirname(__FILE__) . '/consumer.php';
+require_once dirname(__FILE__) . '/admin_panels.php';
+require_once dirname(__FILE__) . '/comments.php';
+require_once dirname(__FILE__) . '/login.php';
+require_once dirname(__FILE__) . '/server.php';
+require_once dirname(__FILE__) . '/store.php';
// register activation (and similar) hooks
register_activation_hook('openid/openid.php', 'openid_activate_plugin');

0 comments on commit 6529cf3

Please sign in to comment.