Completed
Push — master ( 26f8aa...e860de )
by
unknown
02:28
created

maintenance/UpdateExternalData.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 10.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace WikibaseQuality\ExternalValidation\Maintenance;
4
5
use Maintenance;
6
use WikibaseQuality\ExternalValidation\ExternalValidationServices;
7
use WikibaseQuality\ExternalValidation\UpdateExternalData\CsvImportSettings;
8
use WikibaseQuality\ExternalValidation\UpdateExternalData\ExternalDataImporter;
9
10
$basePath = getenv( 'MW_INSTALL_PATH' ) !== false
11
	? getenv( 'MW_INSTALL_PATH' )
12
	: __DIR__ . '/../../..';
13
require_once $basePath . '/maintenance/Maintenance.php';
14
15
/**
16
 * Maintenance script that evokes updates of wbqev_external_data, wbqev_dump_information, wbqev_identifier_properties
17
 * Input data is taken from tar file, which can be generated by DumpConverter tool.
18
 *
19
 * @package WikibaseQuality\ExternalValidation\Maintenance
20
 * @author BP2014N1
21
 * @license GNU GPL v2+
22
 */
23
class UpdateExternalData extends Maintenance {
24
25
	public function __construct() {
26
		parent::__construct();
27
28
		$this->addDescription( "Imports external entities from given CSV files into the local database. CSV files can be generated using the DumpConverter." );
29
		$this->addOption( 'external-values-file', 'CSV file containing external values for import.', true, true );
30
		$this->addOption( 'dump-information-file', 'CSV file containing dump meta information for import.', true, true );
31
		$this->setBatchSize( 1000 );
32
	}
33
34
	public function execute() {
35
		$context = new CsvImportSettings(
36
			$this->getOption( 'external-values-file' ),
37
			$this->getOption( 'dump-information-file' ),
38
			$this->mBatchSize,
39
			$this->isQuiet()
40
		);
41
		$importer = new ExternalDataImporter(
42
			$context,
43
			ExternalValidationServices::getDefaultInstance()->getDumpMetaInformationStore(),
44
			ExternalValidationServices::getDefaultInstance()->getExternalDataRepo()
45
		);
46
		$importer->import();
47
	}
48
}
49
50
// @codeCoverageIgnoreStart
51
$maintClass = 'WikibaseQuality\ExternalValidation\Maintenance\UpdateExternalData';
52
require_once RUN_MAINTENANCE_IF_MAIN;
53
// @codeCoverageIgnoreEnd
54