Skip to content

Commit 8ff8281

Browse files
committed
Testing with all new versions of WB
1 parent b3661e9 commit 8ff8281

File tree

13 files changed

+4786
-9
lines changed

13 files changed

+4786
-9
lines changed

docker-compose.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ services:
66
- ./:/code-repo
77
- ./settings/${PROFILE_SETTINGS}.sh:/code-settings.sh
88
- ./apache.extra.conf:/etc/apache2/conf-available/wb-profile.extra.conf
9+
# Get the right file from an image, then modify it...
10+
# docker run --rm -it --entrypoint cat wikibase/wikibase:1.40.3-wmde.19 /var/www/html/extensions/Wikibase/extension-repo.json > modifications/fastimportapi/wikibase/wikibase:1.40.3-wmde.19/extension-repo.json
911
- type: bind
10-
source: ./modifications/wikibase-fast-import-proof-of-concept-2022/${PROFILE_IMAGE}/extension-repo.json
12+
source: ./modifications/fastimportapi/${PROFILE_IMAGE}/extension-repo.json
1113
target: /var/www/html/extensions/Wikibase/extension-repo.json
1214
- type: bind
13-
source: ./modifications/wikibase-fast-import-proof-of-concept-2022/${PROFILE_IMAGE}/FastImport.php
15+
source: ./modifications/fastimportapi/${PROFILE_IMAGE}/FastImport.php
1416
target: /var/www/html/extensions/Wikibase/repo/includes/Api/FastImport.php
1517

1618
links:
@@ -27,10 +29,10 @@ services:
2729
- ./settings/${PROFILE_SETTINGS}.sh:/code-settings.sh
2830
- ./apache.extra.conf:/etc/apache2/conf-available/wb-profile.extra.conf
2931
- type: bind
30-
source: ./modifications/wikibase-fast-import-proof-of-concept-2022/${PROFILE_IMAGE}/extension-repo.json
32+
source: ./modifications/fastimportapi/${PROFILE_IMAGE}/extension-repo.json
3133
target: /var/www/html/extensions/Wikibase/extension-repo.json
3234
- type: bind
33-
source: ./modifications/wikibase-fast-import-proof-of-concept-2022/${PROFILE_IMAGE}/FastImport.php
35+
source: ./modifications/fastimportapi/${PROFILE_IMAGE}/FastImport.php
3436
target: /var/www/html/extensions/Wikibase/repo/includes/Api/FastImport.php
3537
links:
3638
- mysql

matrix.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ instances:
33
# - 2
44
async:
55
# - 1
6-
- 5
6+
# - 5
77
- 10
88
# - 30
99
# - 60
1010
# - 100
1111
images:
12-
- wikibase/wikibase:1.39.1-wmde.11
12+
# - wikibase/wikibase:1.39.1-wmde.11
1313
# - wikibase/wikibase:1.40.3-wmde.19
1414
# - wikibase/wikibase:1.41.1-wmde.20
1515
# - wikibase/wikibase:mw1.42.5
16-
# - wikibase/wikibase:mw1.43.0
16+
- wikibase/wikibase:mw1.43.0
1717
sql:
1818
# - mariadb:10.9
1919
- mariadb:11.7
@@ -22,8 +22,8 @@ settings:
2222
- wbOwnIdConnection
2323
# - lightweight
2424
loads:
25-
# - wbeditentityFullishItems
26-
- wbfastimportFullishItems
25+
# - wbeditentity-FullishItems
26+
- wbfastimport-FullishItems
2727
entity_groups:
2828
# - 1
2929
# - 2

modifications/wikibase-fast-import-proof-of-concept-2022/wikibase/wikibase:1.39.1-wmde.11/FastImport.php renamed to modifications/fastimportapi/wikibase/wikibase:1.39.1-wmde.11/FastImport.php

File renamed without changes.

modifications/wikibase-fast-import-proof-of-concept-2022/wikibase/wikibase:1.39.1-wmde.11/extension-repo.json renamed to modifications/fastimportapi/wikibase/wikibase:1.39.1-wmde.11/extension-repo.json

File renamed without changes.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
<?php
2+
# https://github.com/wmde/wikibase-fast-import-proof-of-concept-2022/blob/4050571039823c1b23a08a4cd1a8d166f2337bb4/FastImport.php
3+
# With modifications removing the need for a secret to ease configuration
4+
5+
declare( strict_types = 1 );
6+
7+
namespace Wikibase\Repo\Api;
8+
9+
use ApiMain;
10+
use Wikibase\Lib\SettingsArray;
11+
use ApiBase;
12+
use User;
13+
use Wikibase\Repo\WikibaseRepo;
14+
15+
/**
16+
* @license GPL-2.0-or-later
17+
*/
18+
class FastImport extends ApiBase {
19+
protected $importSecret;
20+
21+
public function __construct(
22+
ApiMain $mainModule,
23+
string $moduleName,
24+
SettingsArray $settings
25+
) {
26+
parent::__construct( $mainModule, $moduleName );
27+
// $this->importSecret = $settings->getSetting( 'importSecret' );
28+
}
29+
30+
public static function factory(
31+
ApiMain $mainModule,
32+
string $moduleName,
33+
SettingsArray $settings
34+
): self {
35+
return new self(
36+
$mainModule,
37+
$moduleName,
38+
$settings
39+
);
40+
}
41+
42+
public function isWriteMode(): bool {
43+
return true;
44+
}
45+
46+
public function execute(): void {
47+
$params = $this->extractRequestParams();
48+
49+
if( !isset( $params['data'] ) ) {
50+
die('must provide data');
51+
}
52+
// if( !isset( $params['secret'] ) ) {
53+
// die('must provide secret');
54+
// }
55+
56+
// if( !$this->importSecret || !strlen( $this->importSecret ) >= 32 ) {
57+
// die('invalid secret configured');
58+
// }
59+
// if( $params['secret'] !== $this->importSecret ) {
60+
// die('invalid secret provided');
61+
// }
62+
63+
$user = User::newSystemUser( 'Wikibase Fast Import User (alpha)', [ 'steal' => true ] );
64+
$deserializer = WikibaseRepo::getAllTypesEntityDeserializer();
65+
$store = WikibaseRepo::getEntityStore();
66+
67+
$results = [];
68+
foreach ( json_decode( $params['data'], true ) as $key => $possibleEntity ) {
69+
try{
70+
$entity = $deserializer->deserialize($possibleEntity);
71+
$revision = $store->saveEntity(
72+
$entity,
73+
'Fast import',
74+
$user,
75+
EDIT_NEW,
76+
false,
77+
[]
78+
);
79+
$results[$key] = [
80+
'id' => $revision->getEntity()->getId()->getSerialization(),
81+
'rev' => $revision->getRevisionId(),
82+
# success added for wikibase-profile to detect...
83+
'success' => 1,
84+
];
85+
} catch ( \Exception $e ) {
86+
$results[$key] = [
87+
'error' => $e->getMessage(),
88+
];
89+
}
90+
}
91+
92+
$this->getResult()->addValue( null, 'results', $results );
93+
}
94+
95+
protected function getAllowedParams(): array {
96+
return [
97+
'data' => [
98+
self::PARAM_TYPE => 'text',
99+
self::PARAM_REQUIRED => true,
100+
],
101+
// 'secret' => [
102+
// self::PARAM_TYPE => 'text',
103+
// self::PARAM_REQUIRED => true,
104+
// ]
105+
];
106+
}
107+
}

0 commit comments

Comments
 (0)