@@ -115,6 +115,62 @@ private function getExtensionDocumentation( string $extensionName, DBConnRef $db
115115 return $ ret ;
116116 }
117117
118+ /**
119+ * @param string $extensionName
120+ * @param DBConnRef $dbr
121+ *
122+ * @return array
123+ */
124+ private function getExtensionWiki ( string $ extensionName , DBConnRef $ dbr ) {
125+ $ select = [ Structure::WIKI_PAGEID ];
126+ $ from = Structure::DBTABLE_WIKIS ;
127+ $ where = Structure::EXTENSION_NAME . ' LIKE " ' . $ extensionName . '" ' ;
128+ // SELECT w8y_wi_page_id
129+ // FROM w8y_wikis
130+ // JOIN w8y_scrape_records ON w8y_wi_last_sr_id = w8y_sr_sr_id
131+ // JOIN w8y_extension_links ON w8y_sr_vr_id = w8y_el_vr_id
132+ // JOIN w8y_extension_data ON w8y_el_ed_id = w8y_ed_ed_id
133+ // WHERE w8y_ed_name like "ParserFunctions";
134+ try {
135+ $ res = $ dbr ->newSelectQueryBuilder ()->
136+ select ( $ select )->
137+ from ( $ from )->
138+ leftJoin ( Structure::DBTABLE_SCRAPE , null , Structure::DBTABLE_WIKIS . '. ' . Structure::WIKI_LAST_SR_RCRD . '= ' . Structure::DBTABLE_SCRAPE . '. ' . Structure::SR_ID )->
139+ leftJoin ( Structure::DBTABLE_EXTENSIONS_LINK , null , Structure::DBTABLE_SCRAPE . '. ' . Structure::SCRAPE_VR_ID . '= ' . Structure::DBTABLE_EXTENSIONS_LINK . '. ' . Structure::EXTENSION_LINK_VID )->
140+ leftJoin ( Structure::DBTABLE_EXTENSIONS , null , Structure::DBTABLE_EXTENSIONS_LINK . '. ' . Structure::EXTENSION_LINK_ID . '= ' . Structure::DBTABLE_EXTENSIONS . '. ' . Structure::EXTENSION_ID )->
141+ where ( $ where )->
142+ caller ( __METHOD__ )->
143+ fetchResultSet ();
144+ } catch ( \Exception $ e ) {
145+ wfDebug ( $ e ->getMessage (), 'w8y ' );
146+ return [];
147+ }
148+ $ ret = [];
149+ $ t = 0 ;
150+ if ( $ res ->numRows () > 0 ) {
151+ while ( $ row = $ res ->fetchRow () ) {
152+ $ ret [$ t ][Structure::WIKI_PAGEID ] = $ row [Structure::WIKI_PAGEID ];
153+ $ ret [$ t ]['w8y_pageTitle ' ] = $ this ->getPageTitleFromId ( $ row [Structure::WIKI_PAGEID ] );
154+ $ t ++;
155+ }
156+ }
157+
158+ return $ ret ;
159+ }
160+
161+ /**
162+ * @param int $id
163+ *
164+ * @return string
165+ */
166+ private function getPageTitleFromId ( int $ id ): string {
167+ $ page = MediaWikiServices::getInstance ()->getWikiPageFactory ()->newFromID ( $ id );
168+ if ( $ page === null ) {
169+ return '' ;
170+ }
171+ return $ page ->getTitle ()->getFullText ();
172+ }
173+
118174 /**
119175 * @param string $extensionName
120176 * @param string $queryType
@@ -141,6 +197,12 @@ public function doQuery( string $extensionName, string $queryType, string $expor
141197 Structure::w8yMessage ( 'w8y_count ' )
142198 ];
143199 break ;
200+ case "usedby " :
201+ $ result = $ this ->getExtensionWiki ( $ extensionName , $ dbr );
202+ $ tables = [ Structure::w8yMessage ( Structure::WIKI_PAGEID ),
203+ Structure::w8yMessage ( 'w8y_pageTitle ' )
204+ ];
205+ break ;
144206 default :
145207 $ result = [];
146208 }
0 commit comments