85 lines
2.1 KiB
PHP
85 lines
2.1 KiB
PHP
<?php
|
|
|
|
class stSecurityMigrationTask extends stTask
|
|
{
|
|
const LIMIT = 20;
|
|
|
|
const PEER_CLASS_MAPPING = array(
|
|
'security_migration_order_user_data_billing' => 'OrderUserDataBillingPeer',
|
|
'security_migration_order_user_data_delivery' => 'OrderUserDataDeliveryPeer',
|
|
'security_migration_order_user_data' => 'UserDataPeer',
|
|
'security_migration_invoice_customer_data' => 'InvoiceUserCustomerPeer',
|
|
'security_migration_invoice_seller_data' => 'InvoiceUserSellerPeer',
|
|
'security_migration_mail_account' => 'MailAccountPeer',
|
|
);
|
|
|
|
public function count(): int
|
|
{
|
|
$c = new Criteria();
|
|
$c->add($this->getPeerClassConstant('CRYPT'), 2, Criteria::LESS_THAN);
|
|
$count = call_user_func(array($this->getPeerClass(), 'doCount'), $c);
|
|
|
|
if (!$count && $this->checkStatus())
|
|
{
|
|
stLock::isPHP72Ready(true);
|
|
}
|
|
|
|
return $count;
|
|
}
|
|
|
|
public function execute(int $offset): int
|
|
{
|
|
$c = new Criteria();
|
|
$c->add($this->getPeerClassConstant('CRYPT'), 2, Criteria::LESS_THAN);
|
|
$c->setLimit(self::LIMIT);
|
|
|
|
$results = call_user_func(array($this->getPeerClass(), 'doSelect'), $c);
|
|
|
|
foreach ($results as $result)
|
|
{
|
|
$result->save();
|
|
usleep(250000);
|
|
$offset++;
|
|
}
|
|
|
|
return $offset;
|
|
}
|
|
|
|
public function finished()
|
|
{
|
|
if ($this->checkStatus())
|
|
{
|
|
stLock::isPHP72Ready(true);
|
|
}
|
|
}
|
|
|
|
protected function getPeerClassConstant($constant, $peerClass = null)
|
|
{
|
|
if (null === $peerClass)
|
|
{
|
|
$peerClass = $this->getPeerClass();
|
|
}
|
|
|
|
return constant($peerClass.'::'.$constant);
|
|
}
|
|
|
|
protected function getPeerClass()
|
|
{
|
|
return self::PEER_CLASS_MAPPING[$this->getTask()->getTaskId()];
|
|
}
|
|
|
|
protected function checkStatus()
|
|
{
|
|
foreach (self::PEER_CLASS_MAPPING as $peer)
|
|
{
|
|
$c = new Criteria();
|
|
$c->add($this->getPeerClassConstant('CRYPT', $peer), 2, Criteria::LESS_THAN);
|
|
if (call_user_func(array($peer, 'doCount'), $c) > 0)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
} |