* Get a list of all subscribed hooks, and those subscribers
authorSam Reed <reedy@users.mediawiki.org>
Fri, 29 Apr 2011 23:33:38 +0000 (23:33 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 29 Apr 2011 23:33:38 +0000 (23:33 +0000)
Essentially what SpecialVersion will give you if wgSpecialVersionShowHooks is true

RELEASE-NOTES
includes/api/ApiQuerySiteinfo.php

index 4fda976..d155e9e 100644 (file)
@@ -366,6 +366,7 @@ PHP if you have not done so prior to upgrading MediaWiki.
 * (bug 28238) paraminfo: output both limits for multi param
 * (bug 27179) API: List of extension tags through meta=siteinfo
 * Get a list of function hooks through meta=siteinfo
+* Get a list of all subscribed hooks, and those subscribers
 
 === Languages updated in 1.18 ===
 
index 13550d6..72d0571 100644 (file)
@@ -94,6 +94,9 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                case 'functionhooks':
                                        $fit = $this->appendFunctionHooks( $p );
                                        break;
+                               case 'showhooks':
+                                       $fit = $this->appendSubscribedHooks( $p );
+                                       break;
                                default:
                                        ApiBase::dieDebug( __METHOD__, "Unknown prop=$p" );
                        }
@@ -498,6 +501,26 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                return "&lt;{$item}&gt;";
        }
 
+       public function appendSubscribedHooks( $property ) {
+               global $wgHooks;
+               $myWgHooks = $wgHooks;
+               ksort( $myWgHooks );
+
+               $data = array();
+               foreach ( $myWgHooks as $hook => $hooks )  {
+                       $arr = array(
+                               'name' => $hook,
+                               'subscribers' => $hooks,
+                       );
+
+                       $this->getResult()->setIndexedTagName( $arr['subscribers'], 's' );
+                       $data[] = $arr;
+               }
+
+               $this->getResult()->setIndexedTagName( $data, 'hook' );
+               return $this->getResult()->addValue( 'query', $property, $data );
+       }
+
        public function getCacheMode( $params ) {
                return 'public';
        }
@@ -524,6 +547,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                        'skins',
                                        'extensiontags',
                                        'functionhooks',
+                                       'showhooks',
                                )
                        ),
                        'filteriw' => array(
@@ -557,6 +581,7 @@ class ApiQuerySiteinfo extends ApiQueryBase {
                                ' skins                 - Returns a list of all enabled skins',
                                ' extensiontags         - Returns a list of parser extension tags',
                                ' functionhooks         - Returns a list of parser function hooks',
+                               ' showhooks             - Returns a list of all subscribed hooks (contents of $wgHooks)'
                        ),
                        'filteriw' =>  'Return only local or only nonlocal entries of the interwiki map',
                        'showalldb' => 'List all database servers, not just the one lagging the most',