Bug 24254: Output JS var wgCategories on other actions than view as well. Bug 24254
authorLeo Koppelkamm <diebuche@users.mediawiki.org>
Tue, 12 Jul 2011 16:53:46 +0000 (16:53 +0000)
committerLeo Koppelkamm <diebuche@users.mediawiki.org>
Tue, 12 Jul 2011 16:53:46 +0000 (16:53 +0000)
includes/OutputPage.php

index 82d082a..78900ff 100644 (file)
@@ -1168,6 +1168,21 @@ class OutputPage {
         * @return Array of strings
         */
        public function getCategories() {
+               // mCategories will only be filled if we're coming from the parser
+               if ($this->getRequest()->getVal('action') != 'view') {
+                       $categories = array();
+                       $dbr = wfGetDB( DB_SLAVE );
+                       $res = $dbr->select(
+                               'categorylinks',
+                               array( 'cl_to' ),
+                               'cl_from='. $this->getTitle()->getArticleId(),
+                               __METHOD__
+                       );
+                       foreach( $res as $row ) {
+                               $categories[] = $row->cl_to;
+                       }
+                       $this->mCategories = $categories;
+               }
                return $this->mCategories;
        }