r25670 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r25669‎ | r25670 | r25671 >
Date:19:29, 8 September 2007
Author:evan
Status:old
Tags:
Comment:
Change the default consumer and server store type based on the main
cache type. If it's CACHE_NONE, sets up a file store in /tmp/. If it's
anything else, the default is "memc".

This was a big problem in previous versions for people who didn't use
a caching server (like memcached), and is now fixéd.
Modified paths:
  • /trunk/extensions/OpenID/Consumer.php (modified) (history)
  • /trunk/extensions/OpenID/OpenID.php (modified) (history)
  • /trunk/extensions/OpenID/README (modified) (history)
  • /trunk/extensions/OpenID/Server.php (modified) (history)

Diff [purge]

Index: trunk/extensions/OpenID/Consumer.php
@@ -50,13 +50,15 @@
5151 # Where to store transitory data. Can be 'memc' for the $wgMemc
5252 # global caching object, or 'file' if caching is turned off
5353 # completely and you need a fallback.
 54+
 55+ # Default is memc unless the global cache is disabled.
5456
55 - $wgOpenIDConsumerStoreType = 'memc';
 57+ $wgOpenIDConsumerStoreType = ($wgMainCacheType == CACHE_NONE) ? 'file' : 'memc';
5658
5759 # If the store type is set to 'file', this is is the name of a
5860 # directory to store the data in.
5961
60 - $wgOpenIDConsumerStorePath = NULL;
 62+ $wgOpenIDConsumerStorePath = ($wgMainCacheType == CACHE_NONE) ? "/tmp/$wgDBname/openidconsumer/" : NULL;
6163
6264 # Expiration time for the OpenID cookie. Lets the user re-authenticate
6365 # automatically if their session is expired. Only really useful if
Index: trunk/extensions/OpenID/OpenID.php
@@ -172,6 +172,13 @@
173173 return new OpenID_MemcStore($prefix);
174174
175175 case 'file':
 176+ # Auto-create path if it doesn't exist
 177+ if (!is_dir($options['path'])) {
 178+ if (!mkdir($options['path'], 0770, true)) {
 179+ $wgOut->errorPage('openidconfigerror', 'openidconfigerrortext');
 180+ return NULL;
 181+ }
 182+ }
176183 return new Auth_OpenID_FileStore($options['path']);
177184
178185 default:
Index: trunk/extensions/OpenID/Server.php
@@ -37,12 +37,12 @@
3838 # global caching object, or 'file' if caching is turned off
3939 # completely and you need a fallback.
4040
41 - $wgOpenIDServerStoreType = 'memc';
 41+ $wgOpenIDServerStoreType = ($wgMainCacheType == CACHE_NONE) ? 'file' : 'memc';
4242
4343 # If the store type is set to 'file', this is is the name of a
4444 # directory to store the data in.
4545
46 - $wgOpenIDServerStorePath = NULL;
 46+ $wgOpenIDServerStorePath = ($wgMainCacheType == CACHE_NONE) ? "/tmp/$wgDBname/openidserver/" : NULL;
4747
4848 # Outputs a Yadis (http://yadis.org/) XRDS file, saying that this server
4949 # supports OpenID and lots of other jazz.
Index: trunk/extensions/OpenID/README
@@ -242,14 +242,18 @@
243243 one or both is "file", $wgOpenIDConsumerStorePath or
244244 $wgOpenIDServerStorePath must be set, respectively (see below). If
245245 either of these variables is set to an invalid value, an error page
246 - will be displayed.
 246+ will be displayed. The default is "memc", unless the main cache is
 247+ set to CACHE_NONE (default for MW), in which case it is "file".
247248
248249 * $wgOpenIDConsumerStorePath and $wgOpenIDServerStorePath -- strings
249250 specifying the paths where OpenID assocation data should be stored
250251 when acting as a relying party (consumer) or server, respectively.
251252 Each of these need only be set if the store type settings (above)
252253 are set to "file", respectively. These strings, if both are set,
253 - MUST NOT be equal.
 254+ MUST NOT be equal. If the store type is "file", the default here is
 255+ "/tmp/$wgDBname/openidconsumer/" and "/tmp/$wgDBname/openidserver/"
 256+ respectively. The path will be automatically created if it doesn't
 257+ exist at runtime.
254258
255259 == Skins ==
256260

Status & tagging log