Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improvement]: Prepare for Doctrine v4 #537

Draft
wants to merge 5 commits into
base: 4.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"require": {
"php": "~8.1.0 || ~8.2.0",
"openspout/openspout": "^4.0",
"doctrine/dbal": "^3.4.2",
"doctrine/dbal": "^3.4.2 || ^4.0",
"doctrine/migrations": "^3.0.2",
"dragonmantank/cron-expression": "^3.0.2",
"drewm/mailchimp-api": "^2.2",
Expand All @@ -26,7 +26,7 @@
"pimcore/number-sequence-generator": "^2.0",
"pimcore/admin-ui-classic-bundle": "^1.0",
"pimcore/object-merger": "^4.0",
"pimcore/pimcore": "^11.0",
"pimcore/pimcore": "dev-doctrine4 as 11.99",
"pimcore/search-query-parser": "^1.3",
"pimcore/personalization-bundle": "^1.0",
"symfony/asset": "^6.2",
Expand Down
4 changes: 2 additions & 2 deletions src/ActivityStore/MariaDb.php
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ public function getDeletionsData($entityType, $deletionsSinceTimestamp)

$sql = 'select * from '.self::DELETIONS_TABLE.' where entityType = '.$db->quote(
$entityType
).' and creationDate >= '.$db->quote($deletionsSinceTimestamp);
).' and creationDate >= '.$db->quote((string)$deletionsSinceTimestamp);

$data = $db->fetchAllAssociative($sql);

Expand Down Expand Up @@ -369,7 +369,7 @@ public function deleteEntry(ActivityStoreEntryInterface $entry)
public function deleteCustomer(CustomerInterface $customer)
{
$db = Db::get();
$db->exec(
$db->executeQuery(
sprintf('delete from %s where customerId = %d', self::ACTIVITIES_TABLE, $customer->getId())
);
}
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Admin/ActivitiesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public function listAction(Request $request, CustomerProviderInterface $customer
$list->setOrder('desc');

$select = $list->getQueryBuilder()
->resetQueryParts(['select', 'from'])
->from(MariaDb::ACTIVITIES_TABLE)
->select('type')
->distinct();
Expand Down
1 change: 0 additions & 1 deletion src/Controller/Admin/CustomersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public function exportAction(Request $request): JsonResponse

$idField = Service::getVersionDependentDatabaseColumnName('id');
$query = $listing->getQueryBuilder()
->resetQueryPart('select')
->select($idField);
$ids = Db::get()->fetchFirstColumn((string)$query);

Expand Down
1 change: 0 additions & 1 deletion src/DuplicatesIndex/DefaultMariaDbDuplicatesIndex.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,6 @@ public function getPotentialDuplicates($page, $pageSize = 100, $declined = false

if (!is_null($filterCustomerList)) {
$query = $filterCustomerList->getQueryBuilder()
->resetQueryPart('select')
->select('id');
$joinTable = 'object_' . $filterCustomerList->getClassId();
$joinIdField = $joinTable . '.id';
Expand Down
13 changes: 8 additions & 5 deletions src/Listing/Filter/AbstractFieldBetween.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
namespace CustomerManagementFrameworkBundle\Listing\Filter;

use Doctrine\DBAL\Query\QueryBuilder;
use Pimcore\Db;
use Pimcore\Model\DataObject\Listing as CoreListing;

abstract class AbstractFieldBetween extends AbstractFilter implements OnCreateQueryFilterInterface
Expand Down Expand Up @@ -110,18 +109,22 @@ public function applyOnCreateQuery(CoreListing\Concrete $listing, QueryBuilder $
}

$tableName = $this->getTableName($listing->getClassId());
$subSelect = Db::getConnection()->createQueryBuilder();
$whereCondition = [];
$whereSql = '';

if (null !== $from) {
$operator = $this->getOperator(static::TYPE_FROM);
$subSelect->andWhere(sprintf('`%s`.`%s` %s %s', $tableName, $this->field, $operator, $listing->quote($from)));
$whereCondition[] = sprintf('`%s`.`%s` %s %s', $tableName, $this->field, $operator, $listing->quote($from));
}

if (null !== $to) {
$operator = $this->getOperator(static::TYPE_TO);
$subSelect->andWhere(sprintf('`%s`.`%s` %s %s', $tableName, $this->field, $operator, $listing->quote($to)));
$whereCondition[] = sprintf('`%s`.`%s` %s %s', $tableName, $this->field, $operator, $listing->quote($to));
}
if ($whereCondition) {
$whereSql = implode(' AND ', $whereCondition);
}

$queryBuilder->andWhere((string) $subSelect->getQueryPart('where'));
$queryBuilder->andWhere($whereSql);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ public function getCount()
$query = $this->getQueryBuilder();
$query->setFirstResult(0);
$query->setMaxResults(null);
$query->resetQueryPart('from');
$query->from(MariaDb::ACTIVITIES_TABLE);
$query->select('count(*) totalCount');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ public function getCount()
{
$query = $this->getQueryBuilder()
->setMaxResults(null)
->setFirstResult(0)
->resetQueryPart('from');

->setFirstResult(0);
$query
->from(MariaDb::ACTIVITIES_TABLE)
->select('count(*) totalCount');
Expand Down
1 change: 0 additions & 1 deletion src/Newsletter/ProviderHandler/Mailchimp.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,6 @@ protected function getAllExportableSegments()
$groups = $this->getExportableSegmentGroups();
$idField = Service::getVersionDependentDatabaseColumnName('id');
$select = $groups->getQueryBuilder()
->resetQueryPart('select')
->select($idField);

$segments = $this->segmentManager->getSegments();
Expand Down