From 3d7a04be8eb86e14027218ba51acb762d367530f Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 18 Aug 2020 20:01:13 +0300 Subject: [PATCH] query executor method rename --- application/Espo/Core/Cleanup/Reminders.php | 2 +- .../Espo/Core/Repositories/CategoryTree.php | 10 ++++----- application/Espo/Core/Repositories/Event.php | 2 +- application/Espo/Core/Utils/Cron/Job.php | 2 +- .../Schema/rebuildActions/Currency.php | 2 +- application/Espo/Jobs/Cleanup.php | 22 +++++++++---------- .../Espo/Modules/Crm/Services/Activities.php | 14 ++++++------ .../Espo/Modules/Crm/Services/MassEmail.php | 4 ++-- application/Espo/ORM/QueryExecutor.php | 7 ++++-- .../Espo/Repositories/EmailAddress.php | 8 +++---- application/Espo/Repositories/Import.php | 2 +- application/Espo/Repositories/PhoneNumber.php | 8 +++---- application/Espo/Repositories/Preferences.php | 8 +++---- application/Espo/Services/Email.php | 20 ++++++++--------- application/Espo/Services/GlobalSearch.php | 2 +- application/Espo/Services/Notification.php | 4 ++-- application/Espo/Services/Stream.php | 6 ++--- 17 files changed, 63 insertions(+), 60 deletions(-) diff --git a/application/Espo/Core/Cleanup/Reminders.php b/application/Espo/Core/Cleanup/Reminders.php index 5eeccdbc84..7d290afb3a 100644 --- a/application/Espo/Core/Cleanup/Reminders.php +++ b/application/Espo/Core/Cleanup/Reminders.php @@ -62,6 +62,6 @@ class Reminders ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } } diff --git a/application/Espo/Core/Repositories/CategoryTree.php b/application/Espo/Core/Repositories/CategoryTree.php index a3c0a0966a..6eda3f1d59 100644 --- a/application/Espo/Core/Repositories/CategoryTree.php +++ b/application/Espo/Core/Repositories/CategoryTree.php @@ -70,7 +70,7 @@ class CategoryTree extends Database ->valuesQuery($select) ->build(); - $em->getQueryExecutor()->run($insert); + $em->getQueryExecutor()->execute($insert); return; } @@ -85,7 +85,7 @@ class CategoryTree extends Database ]) ->build(); - $em->getQueryExecutor()->run($insert); + $em->getQueryExecutor()->execute($insert); return; } @@ -118,7 +118,7 @@ class CategoryTree extends Database ]) ->build(); - $em->getQueryExecutor()->run($delete); + $em->getQueryExecutor()->execute($delete); if (!empty($parentId)) { $select = $em->getQueryBuilder() @@ -139,7 +139,7 @@ class CategoryTree extends Database ->valuesQuery($select) ->build(); - $em->getQueryExecutor()->run($insert); + $em->getQueryExecutor()->execute($insert); } } @@ -159,7 +159,7 @@ class CategoryTree extends Database ]) ->build(); - $em->getQueryExecutor()->run($delete); + $em->getQueryExecutor()->execute($delete); $em->getMapper()->deleteFromDb($entity->getEntityType(), $entity->id); } diff --git a/application/Espo/Core/Repositories/Event.php b/application/Espo/Core/Repositories/Event.php index f4664d48a2..81710022ae 100644 --- a/application/Espo/Core/Repositories/Event.php +++ b/application/Espo/Core/Repositories/Event.php @@ -134,7 +134,7 @@ class Event extends Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); } protected function afterSave(Entity $entity, array $options = []) diff --git a/application/Espo/Core/Utils/Cron/Job.php b/application/Espo/Core/Utils/Cron/Job.php index 2c5547a8e1..a6fb29bc98 100644 --- a/application/Espo/Core/Utils/Cron/Job.php +++ b/application/Espo/Core/Utils/Cron/Job.php @@ -358,7 +358,7 @@ class Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } } diff --git a/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php b/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php index 99a5852d08..f686fd39e3 100644 --- a/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php +++ b/application/Espo/Core/Utils/Database/Schema/rebuildActions/Currency.php @@ -49,7 +49,7 @@ class Currency extends \Espo\Core\Utils\Database\Schema\BaseRebuildActions ->from('Currency') ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); foreach ($currencyRates as $currencyName => $rate) { $this->getEntityManager()->createEntity('Currency', [ diff --git a/application/Espo/Jobs/Cleanup.php b/application/Espo/Jobs/Cleanup.php index d8f22ab9cf..c668de6f1d 100644 --- a/application/Espo/Jobs/Cleanup.php +++ b/application/Espo/Jobs/Cleanup.php @@ -126,7 +126,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); $delete = $this->entityManager->getQueryBuilder()->delete() ->from('Job') @@ -137,7 +137,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } protected function cleanupUniqueIds() @@ -150,7 +150,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } protected function cleanupScheduledJobLog() @@ -189,7 +189,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } } @@ -206,7 +206,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } protected function cleanupAuthToken() @@ -223,7 +223,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } protected function cleanupAuthLog() @@ -239,7 +239,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } protected function getCleanupJobFromDate() @@ -356,7 +356,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } protected function cleanupEmails() @@ -391,7 +391,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); $delete = $this->entityManager->getQueryBuilder()->delete() ->from('EmailUser') @@ -400,7 +400,7 @@ class Cleanup implements Job ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } } @@ -497,7 +497,7 @@ class Cleanup implements Job ->where($where) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } catch (\Exception $e) { $GLOBALS['log']->error("Cleanup: " . $e->getMessage()); diff --git a/application/Espo/Modules/Crm/Services/Activities.php b/application/Espo/Modules/Crm/Services/Activities.php index 85cd3cf92b..91b6a14d5f 100644 --- a/application/Espo/Modules/Crm/Services/Activities.php +++ b/application/Espo/Modules/Crm/Services/Activities.php @@ -769,7 +769,7 @@ class Activities implements ->select('COUNT:(c.id)', 'count') ->build(); - $sth = $this->entityManager->getQueryExecutor()->run($countQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($countQuery); $row = $sth->fetch(PDO::FETCH_ASSOC); @@ -791,7 +791,7 @@ class Activities implements $unionQuery = $builder->build(); - $sth = $this->entityManager->getQueryExecutor()->run($unionQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($unionQuery); $rowList = $sth->fetchAll(PDO::FETCH_ASSOC); @@ -923,7 +923,7 @@ class Activities implements ->select('COUNT:(c.id)', 'count') ->build(); - $sth = $this->entityManager->getQueryExecutor()->run($countQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($countQuery); $row = $sth->fetch(\PDO::FETCH_ASSOC); @@ -1702,7 +1702,7 @@ class Activities implements $unionQuery = $builder->build(); - $sth = $this->entityManager->getQueryExecutor()->run($unionQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($unionQuery); $rowList = $sth->fetchAll(PDO::FETCH_ASSOC); @@ -1731,7 +1731,7 @@ class Activities implements $deleteQuery = $builder->build(); - $this->getEntityManager()->getQueryExecutor()->run($deleteQuery); + $this->getEntityManager()->getQueryExecutor()->execute($deleteQuery); return true; } @@ -1945,7 +1945,7 @@ class Activities implements ->select('COUNT:(c.id)', 'count') ->build(); - $sth = $this->entityManager->getQueryExecutor()->run($countQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($countQuery); $row = $sth->fetch(PDO::FETCH_ASSOC); @@ -1961,7 +1961,7 @@ class Activities implements ->limit($offset, $maxSize) ->build(); - $sth = $this->entityManager->getQueryExecutor()->run($unionQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($unionQuery); $rows = $sth->fetchAll(PDO::FETCH_ASSOC); diff --git a/application/Espo/Modules/Crm/Services/MassEmail.php b/application/Espo/Modules/Crm/Services/MassEmail.php index 2a52c72b26..10c8098700 100644 --- a/application/Espo/Modules/Crm/Services/MassEmail.php +++ b/application/Espo/Modules/Crm/Services/MassEmail.php @@ -94,7 +94,7 @@ class MassEmail extends \Espo\Services\Record implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); } protected function cleanupQueueItems(Entity $massEmail) @@ -108,7 +108,7 @@ class MassEmail extends \Espo\Services\Record implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); } public function createQueue(Entity $massEmail, bool $isTest = false, $additionalTargetList = []) diff --git a/application/Espo/ORM/QueryExecutor.php b/application/Espo/ORM/QueryExecutor.php index 1aa75cba69..fd45e79cdc 100644 --- a/application/Espo/ORM/QueryExecutor.php +++ b/application/Espo/ORM/QueryExecutor.php @@ -36,7 +36,7 @@ use Espo\ORM\{ use PDOStatement; /** - * Runs queries by given query params instances. + * Executes queries by given query params instances. */ class QueryExecutor { @@ -47,7 +47,10 @@ class QueryExecutor $this->entityManager = $entityManager; } - public function run(Query $query) : PDOStatement + /** + * Execute a query. + */ + public function execute(Query $query) : PDOStatement { $sql = $this->entityManager->getQueryComposer()->compose($query); diff --git a/application/Espo/Repositories/EmailAddress.php b/application/Espo/Repositories/EmailAddress.php index 0b989456ee..52f02b0fc7 100644 --- a/application/Espo/Repositories/EmailAddress.php +++ b/application/Espo/Repositories/EmailAddress.php @@ -420,7 +420,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); } foreach ($toUpdateList as $address) { @@ -508,7 +508,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($update); + $this->getEntityManager()->getQueryExecutor()->execute($update); $update = $this->getEntityManager()->getQueryBuilder() ->update() @@ -522,7 +522,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($update); + $this->getEntityManager()->getQueryExecutor()->execute($update); } } @@ -587,7 +587,7 @@ class EmailAddress extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($update); + $this->getEntityManager()->getQueryExecutor()->execute($update); } else { if ( diff --git a/application/Espo/Repositories/Import.php b/application/Espo/Repositories/Import.php index b8a8b9cab9..bb623263ad 100644 --- a/application/Espo/Repositories/Import.php +++ b/application/Espo/Repositories/Import.php @@ -105,7 +105,7 @@ class Import extends \Espo\Core\Repositories\Database ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); parent::afterRemove($entity, $options); } diff --git a/application/Espo/Repositories/PhoneNumber.php b/application/Espo/Repositories/PhoneNumber.php index 76f34e927c..b8b97c04b5 100644 --- a/application/Espo/Repositories/PhoneNumber.php +++ b/application/Espo/Repositories/PhoneNumber.php @@ -347,7 +347,7 @@ class PhoneNumber extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); } foreach ($toUpdateList as $number) { @@ -438,7 +438,7 @@ class PhoneNumber extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($update); + $this->getEntityManager()->getQueryExecutor()->execute($update); $update = $this->getEntityManager()->getQueryBuilder() ->update() @@ -452,7 +452,7 @@ class PhoneNumber extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($update); + $this->getEntityManager()->getQueryExecutor()->execute($update); } } @@ -517,7 +517,7 @@ class PhoneNumber extends \Espo\Core\Repositories\Database implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($update); + $this->getEntityManager()->getQueryExecutor()->execute($update); } else { if ( diff --git a/application/Espo/Repositories/Preferences.php b/application/Espo/Repositories/Preferences.php index 2c9db41c03..8e46f7811b 100644 --- a/application/Espo/Repositories/Preferences.php +++ b/application/Espo/Repositories/Preferences.php @@ -93,7 +93,7 @@ class Preferences extends Repository implements ->limit(0, 1) ->build(); - $sth = $this->getEntityManager()->getQueryExecutor()->run($select); + $sth = $this->getEntityManager()->getQueryExecutor()->execute($select); while ($row = $sth->fetch(PDO::FETCH_ASSOC)) { $data = Json::decode($row['data']); @@ -174,7 +174,7 @@ class Preferences extends Repository implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); $entityTypeList = array_filter($entityTypeList, function ($item) { return (bool) $this->metadata->get(['scopes', $item, 'stream']); @@ -218,7 +218,7 @@ class Preferences extends Repository implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($insert); + $this->getEntityManager()->getQueryExecutor()->execute($insert); $user = $this->entityManager->getEntity('User', $entity->id); if ($user && !$user->isPortal()) { @@ -238,7 +238,7 @@ class Preferences extends Repository implements ]) ->build(); - $this->getEntityManager()->getQueryExecutor()->run($delete); + $this->getEntityManager()->getQueryExecutor()->execute($delete); } public function remove(Entity $entity, array $options = []) diff --git a/application/Espo/Services/Email.php b/application/Espo/Services/Email.php index 6c1d959196..5fbd3207f7 100644 --- a/application/Espo/Services/Email.php +++ b/application/Espo/Services/Email.php @@ -532,7 +532,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); $update = $this->entityManager->getQueryBuilder()->update() ->from('Notification') @@ -546,7 +546,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } @@ -565,7 +565,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); $this->markNotificationAsRead($id, $userId); @@ -586,7 +586,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } @@ -605,7 +605,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } @@ -624,7 +624,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } @@ -643,7 +643,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); $this->markNotificationAsRead($id, $userId); @@ -664,7 +664,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } @@ -684,7 +684,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); } public function moveToFolder(string $id, ?string $folderId, ?string $userId = null) @@ -705,7 +705,7 @@ class Email extends Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } diff --git a/application/Espo/Services/GlobalSearch.php b/application/Espo/Services/GlobalSearch.php index 1c80f15a2e..907d0f5719 100644 --- a/application/Espo/Services/GlobalSearch.php +++ b/application/Espo/Services/GlobalSearch.php @@ -139,7 +139,7 @@ class GlobalSearch implements $sql = $this->entityManager->getQueryComposer()->compose($unionQuery); - $sth = $this->entityManager->getQueryExecutor()->run($unionQuery); + $sth = $this->entityManager->getQueryExecutor()->execute($unionQuery); $rows = $sth->fetchAll(PDO::FETCH_ASSOC); diff --git a/application/Espo/Services/Notification.php b/application/Espo/Services/Notification.php index 58561a8888..ce20c7354b 100644 --- a/application/Espo/Services/Notification.php +++ b/application/Espo/Services/Notification.php @@ -184,7 +184,7 @@ class Notification extends \Espo\Services\Record implements ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); return true; } @@ -284,7 +284,7 @@ class Notification extends \Espo\Services\Record implements 'id' => $ids, ]) ->build(); - $this->entityManager->getQueryExecutor()->run($update); + $this->entityManager->getQueryExecutor()->execute($update); } return new RecordCollection($collection, $count); diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index 2e29199a5f..07ecc4ef57 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -252,7 +252,7 @@ class Stream ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); $collection = new EntityCollection(); @@ -321,7 +321,7 @@ class Stream ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); return true; } @@ -341,7 +341,7 @@ class Stream ]) ->build(); - $this->entityManager->getQueryExecutor()->run($delete); + $this->entityManager->getQueryExecutor()->execute($delete); } public function findUserStream($userId, $params = [])