Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 6d1afb4

Browse files
committed
Catch action=wiki and scrapes with no version id
1 parent 76c80eb commit 6d1afb4

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

includes/data/Structure.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class Structure {
2828
public const WIKI_LAST_SR_RCRD = 'w8y_wi_last_sr_id';
2929
public const SR_ID = 'w8y_sr_sr_id';
3030
public const SCRAPE_VR_ID = 'w8y_sr_vr_id';
31+
public const SCRAPE_IS_ALIVE = 'w8y_sr_is_alive';
3132
public const EXTENSION_ID = 'w8y_ed_ed_id';
3233
public const EXTENSION_NAME = 'w8y_ed_name';
3334
public const EXTENSION_LINK_VID = 'w8y_el_vr_id';

includes/data/query/Wiki.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,13 @@ private function getExtensions( int $versionId, DBConnRef $dbr ): array {
3838
$select = [ '*' ];
3939
$from = Structure::DBTABLE_EXTENSIONS_LINK;
4040
$where = [ Structure::DBTABLE_EXTENSIONS_LINK . '.' . Structure::EXTENSION_LINK_VID => $versionId ];
41-
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->join( Structure::DBTABLE_EXTENSIONS,
42-
null,
43-
Structure::DBTABLE_EXTENSIONS_LINK . '.' . Structure::EXTENSION_LINK_ID . ' = ' . Structure::DBTABLE_EXTENSIONS . '.' . Structure::EXTENSION_ID )
44-
->where( $where )->caller( __METHOD__ )->fetchResultSet();
41+
$res = $dbr->newSelectQueryBuilder()->
42+
select( $select )->
43+
from( $from )->
44+
join( Structure::DBTABLE_EXTENSIONS, null, Structure::DBTABLE_EXTENSIONS_LINK . '.' . Structure::EXTENSION_LINK_ID . ' = ' . Structure::DBTABLE_EXTENSIONS . '.' . Structure::EXTENSION_ID )->
45+
where( $where )->
46+
caller( __METHOD__ )->
47+
fetchResultSet();
4548

4649
$ret = [];
4750
$t = 0;
@@ -66,10 +69,13 @@ private function getSkins( int $versionId, DBConnRef $dbr ): array {
6669
$select = [ '*' ];
6770
$from = Structure::DBTABLE_SKINS_LINK;
6871
$where = [ Structure::DBTABLE_SKINS_LINK . '.' . Structure::SKIN_LINK_VID => $versionId ];
69-
$res = $dbr->newSelectQueryBuilder()->select( $select )->from( $from )->join( Structure::DBTABLE_SKINS,
70-
null,
71-
Structure::DBTABLE_SKINS_LINK . '.' . Structure::SKIN_LINK_ID . ' = ' . Structure::DBTABLE_SKINS . '.' . Structure::SKIN_ID )
72-
->where( $where )->caller( __METHOD__ )->fetchResultSet();
72+
$res = $dbr->newSelectQueryBuilder()->
73+
select( $select )->
74+
from( $from )->
75+
join( Structure::DBTABLE_SKINS, null, Structure::DBTABLE_SKINS_LINK . '.' . Structure::SKIN_LINK_ID . ' = ' . Structure::DBTABLE_SKINS . '.' . Structure::SKIN_ID )->
76+
where( $where )->
77+
caller( __METHOD__ )->
78+
fetchResultSet();
7379

7480
$ret = [];
7581
$t = 0;
@@ -143,10 +149,16 @@ public function doQuery( int $pageID, string $export = "table" ): mixed {
143149
return $result;
144150
}
145151
$result['wiki']['w8y_pageTitle'] = Utils::getPageTitleFromID( $pageID );
146-
$result['extensions'] = $this->getExtensions( $result['scrape'][Structure::SCRAPE_VR_ID], $dbr );
152+
if ( $result['scrape'][Structure::SCRAPE_IS_ALIVE] === 0 ) {
153+
$result['extensions'] = [];
154+
$result['skins'] = [];
155+
} else {
156+
$result['extensions'] = $this->getExtensions( $result['scrape'][Structure::SCRAPE_VR_ID], $dbr );
157+
$result['skins'] = $this->getSkins( $result['scrape'][Structure::SCRAPE_VR_ID], $dbr );
158+
}
147159
return match ( $export ) {
148160
"table" => Utils::renderTable( $result,
149-
'Results for ' . $result['wiki']['pageTitle'] . ' ( pageID: ' . $pageID . ' )' ),
161+
'Results for ' . $result['wiki']['w8y_pageTitle'] . ' ( pageID: ' . $pageID . ' )' ),
150162
"arrayfunctions" => [ Utils::exportArrayFunction( $result ), 'nowiki' => true ],
151163
"lua" => $result,
152164
default => "",

0 commit comments

Comments
 (0)