|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2018-2021 |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
|
|
9
|
|
|
namespace Aimeos\MW\Setup\Task; |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
/** |
|
13
|
|
|
* Removes address and list records without user entry |
|
14
|
|
|
*/ |
|
15
|
|
|
class CustomerRemoveLostUserDataTypo3 extends \Aimeos\MW\Setup\Task\Base |
|
16
|
|
|
{ |
|
17
|
|
|
private $sql = [ |
|
18
|
|
|
'fe_users_address' => [ |
|
19
|
|
|
'fk_mcusad_pid' => 'DELETE FROM "fe_users_address" WHERE NOT EXISTS ( SELECT "uid" FROM "fe_users" AS u WHERE "parentid"=u."uid" )' |
|
20
|
|
|
], |
|
21
|
|
|
'fe_users_list' => [ |
|
22
|
|
|
'fk_mcusli_pid' => 'DELETE FROM "fe_users_list" WHERE NOT EXISTS ( SELECT "uid" FROM "fe_users" AS u WHERE "parentid"=u."uid" )' |
|
23
|
|
|
], |
|
24
|
|
|
'fe_users_property' => [ |
|
25
|
|
|
'fk_mcuspr_pid' => 'DELETE FROM "fe_users_property" WHERE NOT EXISTS ( SELECT "uid" FROM "fe_users" AS u WHERE "parentid"=u."uid" )' |
|
26
|
|
|
] |
|
27
|
|
|
]; |
|
28
|
|
|
|
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Returns the list of task names which depends on this task. |
|
32
|
|
|
* |
|
33
|
|
|
* @return string[] List of task names |
|
34
|
|
|
*/ |
|
35
|
|
|
public function getPostDependencies() : array |
|
36
|
|
|
{ |
|
37
|
|
|
return ['TablesCreateMShop']; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Migrate database schema |
|
43
|
|
|
*/ |
|
44
|
|
|
public function migrate() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->msg( 'Remove left over TYPO3 fe_users references', 0, '' ); |
|
47
|
|
|
|
|
48
|
|
|
$schema = $this->getSchema( 'db-customer' ); |
|
49
|
|
|
|
|
50
|
|
|
foreach( $this->sql as $table => $map ) |
|
51
|
|
|
{ |
|
52
|
|
|
foreach( $map as $constraint => $sql ) |
|
53
|
|
|
{ |
|
54
|
|
|
$this->msg( sprintf( 'Remove records from %1$s', $table ), 1 ); |
|
55
|
|
|
|
|
56
|
|
|
if( $schema->tableExists( 'fe_users' ) && $schema->tableExists( $table ) |
|
57
|
|
|
&& $schema->constraintExists( $table, $constraint ) === false |
|
58
|
|
|
) { |
|
59
|
|
|
$this->execute( $sql, 'db-customer' ); |
|
60
|
|
|
$this->status( 'done' ); |
|
61
|
|
|
} |
|
62
|
|
|
else |
|
63
|
|
|
{ |
|
64
|
|
|
$this->status( 'OK' ); |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
} |
|
70
|
|
|
|