Difference between revisions of "Extension:SimpleSecurity"
(→SimpleSecurity5.0: the issue) |
(Finding a solution) |
||
Line 1: | Line 1: | ||
{{voodoo}}{{svn|http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SimpleSecurity}} | {{voodoo}}{{svn|http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/SimpleSecurity}} | ||
− | == | + | == SimpleSecurity 4.x incompatible with MediaWiki 1.17+ == |
An issue has cropped up with MediaWiki 1.17 ([https://bugzilla.wikimedia.org/show_bug.cgi?id=29525 bug 29525]) which is due to changes in the load-balancer that are incompatible with the DatabaseHook used in SimpleSecurity. | An issue has cropped up with MediaWiki 1.17 ([https://bugzilla.wikimedia.org/show_bug.cgi?id=29525 bug 29525]) which is due to changes in the load-balancer that are incompatible with the DatabaseHook used in SimpleSecurity. | ||
{{code|<pre> | {{code|<pre> | ||
Line 7: | Line 7: | ||
</pre>}} | </pre>}} | ||
− | + | == The cause == | |
This is due to the following statement returning null (in MediaWiki 1.18 this method is changed to ''DatabaseBase::factory()'', but the same problem persists), | This is due to the following statement returning null (in MediaWiki 1.18 this method is changed to ''DatabaseBase::factory()'', but the same problem persists), | ||
{{code|<php> | {{code|<php> | ||
Line 29: | Line 29: | ||
Updating the code to make this list globally accessible would be quite simple, but would not be introduced until probably version 1.19, so there would then be two major versions of MediaWiki in use which are incompatible with SimpleSecurity, so we need to figure out a new approach to the DatabaseHook which works with the latest LoadBalancer. | Updating the code to make this list globally accessible would be quite simple, but would not be introduced until probably version 1.19, so there would then be two major versions of MediaWiki in use which are incompatible with SimpleSecurity, so we need to figure out a new approach to the DatabaseHook which works with the latest LoadBalancer. | ||
+ | == Finding a solution == | ||
+ | The bottom line is that we need the ''wfGetDB()'' global function to return an instance of database class that has been extended by having our hooks added into the ''query()'' and ''fetchObject()'' methods. As can be seen in the following snippet from ''GlobalFunctions.php'', the ''wfGetDB()'' function, we actually need to be looking at ''LBFactory::singleton()'', | ||
+ | {{code|<php> | ||
+ | function wfGetLB( $wiki = false ) { | ||
+ | return wfGetLBFactory()->getMainLB( $wiki ); | ||
+ | } | ||
+ | |||
+ | function &wfGetLBFactory() { | ||
+ | return LBFactory::singleton(); | ||
+ | } | ||
+ | </php>}} | ||
[[Category:Extensions|SimpleSecurity]] | [[Category:Extensions|SimpleSecurity]] |
Revision as of 23:45, 22 June 2011
SimpleSecurity 4.x incompatible with MediaWiki 1.17+
An issue has cropped up with MediaWiki 1.17 (bug 29525) which is due to changes in the load-balancer that are incompatible with the DatabaseHook used in SimpleSecurity.
The cause
This is due to the following statement returning null (in MediaWiki 1.18 this method is changed to DatabaseBase::factory(), but the same problem persists),
SimpleSecurity changes the database-type to "SimpleSecurity" which is a new type that extends the original type by replicating it exactly but adding the hooks into the query() and fetchObject() methods. The problem is that the newFromType() and factory() methods use a hard-coded list of available types and return null if the passed type doesn't match any of them,
Updating the code to make this list globally accessible would be quite simple, but would not be introduced until probably version 1.19, so there would then be two major versions of MediaWiki in use which are incompatible with SimpleSecurity, so we need to figure out a new approach to the DatabaseHook which works with the latest LoadBalancer.
Finding a solution
The bottom line is that we need the wfGetDB() global function to return an instance of database class that has been extended by having our hooks added into the query() and fetchObject() methods. As can be seen in the following snippet from GlobalFunctions.php, the wfGetDB() function, we actually need to be looking at LBFactory::singleton(),