Replace PDO types with Doctrine's ParameterType
[MAILPOET-6142]
This commit is contained in:
@@ -8,6 +8,7 @@ use MailPoet\Entities\SubscriberEntity;
|
|||||||
use MailPoet\Subscribers\SubscribersRepository;
|
use MailPoet\Subscribers\SubscribersRepository;
|
||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
@@ -31,7 +32,7 @@ class SubscriberLinkTokens extends SimpleWorker {
|
|||||||
$connection->executeStatement(
|
$connection->executeStatement(
|
||||||
"UPDATE {$subscribersTable} SET link_token = SUBSTRING(MD5(CONCAT(:authKey, email)), 1, :tokenLength) WHERE link_token IS NULL LIMIT :limit",
|
"UPDATE {$subscribersTable} SET link_token = SUBSTRING(MD5(CONCAT(:authKey, email)), 1, :tokenLength) WHERE link_token IS NULL LIMIT :limit",
|
||||||
['authKey' => $authKey, 'tokenLength' => SubscriberEntity::OBSOLETE_LINK_TOKEN_LENGTH, 'limit' => self::BATCH_SIZE],
|
['authKey' => $authKey, 'tokenLength' => SubscriberEntity::OBSOLETE_LINK_TOKEN_LENGTH, 'limit' => self::BATCH_SIZE],
|
||||||
['authKey' => \PDO::PARAM_STR, 'tokenLength' => \PDO::PARAM_INT, 'limit' => \PDO::PARAM_INT]
|
['authKey' => ParameterType::STRING, 'tokenLength' => ParameterType::INTEGER, 'limit' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->schedule();
|
$this->schedule();
|
||||||
|
@@ -2,9 +2,9 @@
|
|||||||
|
|
||||||
namespace MailPoet\Doctrine\Types;
|
namespace MailPoet\Doctrine\Types;
|
||||||
|
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform;
|
use MailPoetVendor\Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Types\BigIntType as DoctrineBigIntType;
|
use MailPoetVendor\Doctrine\DBAL\Types\BigIntType as DoctrineBigIntType;
|
||||||
use PDO;
|
|
||||||
|
|
||||||
class BigIntType extends DoctrineBigIntType {
|
class BigIntType extends DoctrineBigIntType {
|
||||||
// override Doctrine's bigint type that historically maps DB's "bigint" to PHP's "string"
|
// override Doctrine's bigint type that historically maps DB's "bigint" to PHP's "string"
|
||||||
@@ -12,7 +12,7 @@ class BigIntType extends DoctrineBigIntType {
|
|||||||
const NAME = 'bigint';
|
const NAME = 'bigint';
|
||||||
|
|
||||||
public function getBindingType() {
|
public function getBindingType() {
|
||||||
return PDO::PARAM_INT;
|
return ParameterType::INTEGER;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function convertToPHPValue($value, AbstractPlatform $platform) {
|
public function convertToPHPValue($value, AbstractPlatform $platform) {
|
||||||
|
@@ -9,6 +9,7 @@ use MailPoet\InvalidStateException;
|
|||||||
use MailPoet\Util\Helpers;
|
use MailPoet\Util\Helpers;
|
||||||
use MailPoet\WP\Functions;
|
use MailPoet\WP\Functions;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -115,8 +116,8 @@ class LogRepository extends Repository {
|
|||||||
'limit' => $limit,
|
'limit' => $limit,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'date' => \PDO::PARAM_STR,
|
'date' => ParameterType::STRING,
|
||||||
'limit' => \PDO::PARAM_INT,
|
'limit' => ParameterType::INTEGER,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,7 @@ use MailPoet\NotFoundException;
|
|||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
use MailPoetVendor\Doctrine\ORM\ORMException;
|
use MailPoetVendor\Doctrine\ORM\ORMException;
|
||||||
|
|
||||||
@@ -267,7 +268,7 @@ class SegmentsRepository extends Repository {
|
|||||||
->where('s.id IN (:ids)')
|
->where('s.id IN (:ids)')
|
||||||
->andWhere('s.type = :type')
|
->andWhere('s.type = :type')
|
||||||
->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY)
|
->setParameter('ids', $ids, Connection::PARAM_INT_ARRAY)
|
||||||
->setParameter('type', $type, \PDO::PARAM_STR)
|
->setParameter('type', $type, ParameterType::STRING)
|
||||||
->getQuery()->execute();
|
->getQuery()->execute();
|
||||||
|
|
||||||
$queryBuilder = $entityManager->createQueryBuilder();
|
$queryBuilder = $entityManager->createQueryBuilder();
|
||||||
|
@@ -17,6 +17,7 @@ use MailPoet\WooCommerce\Subscription;
|
|||||||
use MailPoet\WP\Functions as WPFunctions;
|
use MailPoet\WP\Functions as WPFunctions;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
class WooCommerce {
|
class WooCommerce {
|
||||||
@@ -287,8 +288,8 @@ class WooCommerce {
|
|||||||
'highestOrderId' => $lastProcessedOrderId + $batchSize,
|
'highestOrderId' => $lastProcessedOrderId + $batchSize,
|
||||||
];
|
];
|
||||||
$parametersType = [
|
$parametersType = [
|
||||||
'lowestOrderId' => \PDO::PARAM_INT,
|
'lowestOrderId' => ParameterType::INTEGER,
|
||||||
'highestOrderId' => \PDO::PARAM_INT,
|
'highestOrderId' => ParameterType::INTEGER,
|
||||||
];
|
];
|
||||||
|
|
||||||
if ($this->woocommerceHelper->isWooCommerceCustomOrdersTableEnabled()) {
|
if ($this->woocommerceHelper->isWooCommerceCustomOrdersTableEnabled()) {
|
||||||
@@ -441,7 +442,7 @@ class WooCommerce {
|
|||||||
WHERE is_woocommerce_user = 1
|
WHERE is_woocommerce_user = 1
|
||||||
",
|
",
|
||||||
['segmentId' => $wcSegment->getId()],
|
['segmentId' => $wcSegment->getId()],
|
||||||
['segmentId' => \PDO::PARAM_INT]
|
['segmentId' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +458,7 @@ class WooCommerce {
|
|||||||
WHERE mpss.segment_id = :segmentId AND (mps.is_woocommerce_user = 0 OR mps.email = '' OR mps.email IS NULL)
|
WHERE mpss.segment_id = :segmentId AND (mps.is_woocommerce_user = 0 OR mps.email = '' OR mps.email IS NULL)
|
||||||
",
|
",
|
||||||
['segmentId' => $wcSegment->getId()],
|
['segmentId' => $wcSegment->getId()],
|
||||||
['segmentId' => \PDO::PARAM_INT]
|
['segmentId' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -475,7 +476,7 @@ class WooCommerce {
|
|||||||
AND mps.is_woocommerce_user = 1
|
AND mps.is_woocommerce_user = 1
|
||||||
",
|
",
|
||||||
['statusUnsubscribed' => SubscriberEntity::STATUS_UNSUBSCRIBED],
|
['statusUnsubscribed' => SubscriberEntity::STATUS_UNSUBSCRIBED],
|
||||||
['statusUnsubscribed' => \PDO::PARAM_STR]
|
['statusUnsubscribed' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
// SET global status unsubscribed to all woocommerce users who have only 1 segment and it is woocommerce segment and they are not subscribed
|
// SET global status unsubscribed to all woocommerce users who have only 1 segment and it is woocommerce segment and they are not subscribed
|
||||||
// You can't specify target table 'mps' for update in FROM clause
|
// You can't specify target table 'mps' for update in FROM clause
|
||||||
@@ -493,7 +494,7 @@ class WooCommerce {
|
|||||||
)
|
)
|
||||||
",
|
",
|
||||||
['statusUnsubscribed' => SubscriberEntity::STATUS_UNSUBSCRIBED, 'segmentId' => $wcSegment->getId()],
|
['statusUnsubscribed' => SubscriberEntity::STATUS_UNSUBSCRIBED, 'segmentId' => $wcSegment->getId()],
|
||||||
['statusUnsubscribed' => \PDO::PARAM_STR, 'segmentId' => \PDO::PARAM_INT]
|
['statusUnsubscribed' => ParameterType::STRING, 'segmentId' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -620,7 +621,7 @@ class WooCommerce {
|
|||||||
AND mps.is_woocommerce_user = 1
|
AND mps.is_woocommerce_user = 1
|
||||||
",
|
",
|
||||||
['status' => $status, 'segmentId' => $wcSegment->getId()],
|
['status' => $status, 'segmentId' => $wcSegment->getId()],
|
||||||
['status' => \PDO::PARAM_STR, 'segmentId' => \PDO::PARAM_INT]
|
['status' => ParameterType::STRING, 'segmentId' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,7 @@ use MailPoet\Entities\SendingQueueEntity;
|
|||||||
use MailPoet\Entities\SubscriberEntity;
|
use MailPoet\Entities\SubscriberEntity;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
class InactiveSubscribersController {
|
class InactiveSubscribersController {
|
||||||
@@ -165,7 +166,7 @@ class InactiveSubscribersController {
|
|||||||
'thresholdDate' => $thresholdDate,
|
'thresholdDate' => $thresholdDate,
|
||||||
'statusInactive' => SubscriberEntity::STATUS_INACTIVE,
|
'statusInactive' => SubscriberEntity::STATUS_INACTIVE,
|
||||||
'batchSize' => $batchSize,
|
'batchSize' => $batchSize,
|
||||||
], ['batchSize' => \PDO::PARAM_INT])->fetchAllAssociative();
|
], ['batchSize' => ParameterType::INTEGER])->fetchAllAssociative();
|
||||||
|
|
||||||
$idsToActivate = array_map(
|
$idsToActivate = array_map(
|
||||||
function($id) {
|
function($id) {
|
||||||
|
@@ -6,6 +6,7 @@ use MailPoet\Entities\ScheduledTaskEntity;
|
|||||||
use MailPoet\Entities\ScheduledTaskSubscriberEntity;
|
use MailPoet\Entities\ScheduledTaskSubscriberEntity;
|
||||||
use MailPoet\Entities\SubscriberEntity;
|
use MailPoet\Entities\SubscriberEntity;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
|
|
||||||
class SubscribersEmailCountsController {
|
class SubscribersEmailCountsController {
|
||||||
@@ -122,8 +123,8 @@ class SubscribersEmailCountsController {
|
|||||||
'batchSize' => $batchSize,
|
'batchSize' => $batchSize,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'startId' => \PDO::PARAM_INT,
|
'startId' => ParameterType::INTEGER,
|
||||||
'batchSize' => \PDO::PARAM_INT,
|
'batchSize' => ParameterType::INTEGER,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ use MailPoet\WP\Functions as WPFunctions;
|
|||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
use MailPoetVendor\Carbon\CarbonImmutable;
|
use MailPoetVendor\Carbon\CarbonImmutable;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Connection;
|
use MailPoetVendor\Doctrine\DBAL\Connection;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
use MailPoetVendor\Doctrine\ORM\Query\Expr\Join;
|
use MailPoetVendor\Doctrine\ORM\Query\Expr\Join;
|
||||||
|
|
||||||
@@ -574,7 +575,7 @@ class SubscribersRepository extends Repository {
|
|||||||
LEFT JOIN {$wpdb->users} u ON s.wp_user_id = u.id
|
LEFT JOIN {$wpdb->users} u ON s.wp_user_id = u.id
|
||||||
WHERE ss.segment_id = :segmentId AND (u.id IS NULL OR s.email = '')",
|
WHERE ss.segment_id = :segmentId AND (u.id IS NULL OR s.email = '')",
|
||||||
['segmentId' => $segmentId],
|
['segmentId' => $segmentId],
|
||||||
['segmentId' => \PDO::PARAM_INT]
|
['segmentId' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,6 +18,7 @@ use MailPoet\Segments\DynamicSegments\Filters\Filter;
|
|||||||
use MailPoet\Util\Security;
|
use MailPoet\Util\Security;
|
||||||
use MailPoet\WooCommerce\Helper;
|
use MailPoet\WooCommerce\Helper;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Query\QueryBuilder;
|
use MailPoetVendor\Doctrine\DBAL\Query\QueryBuilder;
|
||||||
use MailPoetVendor\Doctrine\DBAL\Result;
|
use MailPoetVendor\Doctrine\DBAL\Result;
|
||||||
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
use MailPoetVendor\Doctrine\ORM\EntityManager;
|
||||||
@@ -95,7 +96,7 @@ class IntegrationTester extends \Codeception\Actor {
|
|||||||
$this->entityManager->getConnection()->executeStatement(
|
$this->entityManager->getConnection()->executeStatement(
|
||||||
"DELETE FROM {$wpdb->users} WHERE id = :id",
|
"DELETE FROM {$wpdb->users} WHERE id = :id",
|
||||||
['id' => $id],
|
['id' => $id],
|
||||||
['id' => \PDO::PARAM_INT]
|
['id' => ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -20,6 +20,7 @@ use MailPoet\WooCommerce\Helper;
|
|||||||
use MailPoet\WooCommerce\Subscription;
|
use MailPoet\WooCommerce\Subscription;
|
||||||
use MailPoet\WP\Functions;
|
use MailPoet\WP\Functions;
|
||||||
use MailPoetVendor\Carbon\Carbon;
|
use MailPoetVendor\Carbon\Carbon;
|
||||||
|
use MailPoetVendor\Doctrine\DBAL\ParameterType;
|
||||||
|
|
||||||
class WPTest extends \MailPoetTest {
|
class WPTest extends \MailPoetTest {
|
||||||
/** @var array<int> */
|
/** @var array<int> */
|
||||||
@@ -717,7 +718,7 @@ class WPTest extends \MailPoetTest {
|
|||||||
$this->entityManager->getConnection()->executeQuery(
|
$this->entityManager->getConnection()->executeQuery(
|
||||||
"UPDATE {$wpdb->users} SET user_email = :userEmail WHERE id = :id",
|
"UPDATE {$wpdb->users} SET user_email = :userEmail WHERE id = :id",
|
||||||
['userEmail' => $email, 'id' => $id],
|
['userEmail' => $email, 'id' => $id],
|
||||||
[\PDO::PARAM_STR, \PDO::PARAM_INT]
|
[ParameterType::STRING, ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,7 +728,7 @@ class WPTest extends \MailPoetTest {
|
|||||||
$this->entityManager->getConnection()->executeQuery(
|
$this->entityManager->getConnection()->executeQuery(
|
||||||
"UPDATE {$wpdb->users} SET display_name = :displayName WHERE id = :id",
|
"UPDATE {$wpdb->users} SET display_name = :displayName WHERE id = :id",
|
||||||
['displayName' => $name, 'id' => $id],
|
['displayName' => $name, 'id' => $id],
|
||||||
[\PDO::PARAM_STR, \PDO::PARAM_INT]
|
[ParameterType::STRING, ParameterType::INTEGER]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user