Skip to content

Commit

Permalink
Doctrine ORM3.0ではサポートされないので、flushにエンティティを指定している処理を修正。
Browse files Browse the repository at this point in the history
  • Loading branch information
kurozumi committed Feb 17, 2021
1 parent 6e33056 commit 9687191
Show file tree
Hide file tree
Showing 21 changed files with 56 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/Eccube/Command/GenerateDummyDataCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$output->writeln('Order: id='.$Order->getId());
break;
}
$this->entityManager->flush($Order);
$this->entityManager->flush();
$j++;
if ($output->getVerbosity() >= OutputInterface::VERBOSITY_NORMAL && ($j % 100) === 0 && $j > 0) {
$output->writeln(' ...'.$j);
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Command/PluginGenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ public function index(Request \$request)
if (\$form->isSubmitted() && \$form->isValid()) {
\$Config = \$form->getData();
\$this->entityManager->persist(\$Config);
\$this->entityManager->flush(\$Config);
\$this->entityManager->flush();
\$this->addSuccess('登録しました。', 'admin');
return \$this->redirectToRoute('${snakecased}_admin_config');
Expand Down
6 changes: 3 additions & 3 deletions src/Eccube/Controller/Admin/Content/LayoutController.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public function delete(Layout $Layout, CacheUtil $cacheUtil)
}

$this->entityManager->remove($Layout);
$this->entityManager->flush($Layout);
$this->entityManager->flush();

$this->addSuccess('admin.common.delete_complete', 'admin');

Expand Down Expand Up @@ -180,15 +180,15 @@ public function edit(Request $request, $id = null, $previewPageId = null, CacheU
// Layoutの更新
$Layout = $form->getData();
$this->entityManager->persist($Layout);
$this->entityManager->flush($Layout);
$this->entityManager->flush();

// BlockPositionの更新
// delete/insertのため一度削除する.
$BlockPositions = $Layout->getBlockPositions();
foreach ($BlockPositions as $BlockPosition) {
$Layout->removeBlockPosition($BlockPosition);
$this->entityManager->remove($BlockPosition);
$this->entityManager->flush($BlockPosition);
$this->entityManager->flush();
}

// ブロックの個数分登録を行う.
Expand Down
6 changes: 3 additions & 3 deletions src/Eccube/Controller/Admin/Content/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function edit(Request $request, $id = null, Environment $twig, RouterInte
foreach ($Page->getPageLayouts() as $PageLayout) {
$Page->removePageLayout($PageLayout);
$this->entityManager->remove($PageLayout);
$this->entityManager->flush($PageLayout);
$this->entityManager->flush();
}

$Layout = $form['PcLayout']->getData();
Expand All @@ -195,7 +195,7 @@ public function edit(Request $request, $id = null, Environment $twig, RouterInte
$PageLayout->setPage($Page);

$this->entityManager->persist($PageLayout);
$this->entityManager->flush($PageLayout);
$this->entityManager->flush();
}

$Layout = $form['SpLayout']->getData();
Expand All @@ -208,7 +208,7 @@ public function edit(Request $request, $id = null, Environment $twig, RouterInte
$PageLayout->setPage($Page);

$this->entityManager->persist($PageLayout);
$this->entityManager->flush($PageLayout);
$this->entityManager->flush();
}

$event = new EventArgs(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ public function delete(Request $request, $id, TranslatorInterface $translator)

try {
$this->entityManager->remove($Customer);
$this->entityManager->flush($Customer);
$this->entityManager->flush();
$this->addSuccess('admin.common.delete_complete', 'admin');
} catch (ForeignKeyConstraintViolationException $e) {
log_error('会員削除失敗', [$e]);
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Controller/Admin/Order/EditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public function index(Request $request, $id = null, RouterInterface $router)
// 会員の場合購入回数購入金額などを更新
if ($Customer = $TargetOrder->getCustomer()) {
$this->orderRepository->updateOrderSummary($Customer);
$this->entityManager->flush($Customer);
$this->entityManager->flush();
}

$event = new EventArgs(
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Controller/Admin/Order/MailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public function index(Request $request, Order $Order)
->setOrder($Order);

$this->entityManager->persist($MailHistory);
$this->entityManager->flush($MailHistory);
$this->entityManager->flush();

$event = new EventArgs(
[
Expand Down
17 changes: 11 additions & 6 deletions src/Eccube/Controller/Admin/Order/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,23 @@ public function updateOrderStatus(Request $request, Shipping $Shipping)
foreach ($Order->getOrderItems() as $OrderItem) {
$ProductClass = $OrderItem->getProductClass();
if ($OrderItem->isProduct() && !$ProductClass->isStockUnlimited()) {
$this->entityManager->flush($ProductClass);
$this->entityManager->persist($ProductClass);
$this->entityManager->flush();
$ProductStock = $this->productStockRepository->findOneBy(['ProductClass' => $ProductClass]);
$this->entityManager->flush($ProductStock);
$this->entityManager->persist($ProductStock);
$this->entityManager->flush();
}
}
}
$this->entityManager->flush($Order);
$this->entityManager->flush($Shipping);
$this->entityManager->persist($Order);
$this->entityManager->persist($Shipping);
$this->entityManager->flush();

// 会員の場合購入回数購入金額などを更新
if ($Customer = $Order->getCustomer()) {
$this->orderRepository->updateOrderSummary($Customer);
$this->entityManager->flush($Customer);
$this->entityManager->persist($Customer);
$this->entityManager->flush();
}
} else {
$from = $Order->getOrderStatus()->getName();
Expand Down Expand Up @@ -593,7 +597,8 @@ public function updateTrackingNumber(Request $request, Shipping $shipping)

try {
$shipping->setTrackingNumber($trackingNumber);
$this->entityManager->flush($shipping);
$this->entityManager->persist($shipping);
$this->entityManager->flush();
log_info('送り状番号変更処理完了', [$shipping->getId()]);
$message = ['status' => 'OK', 'shipping_id' => $shipping->getId(), 'tracking_number' => $trackingNumber];

Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Controller/ShippingMultipleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ public function shippingMultipleEdit(Request $request)

$CustomerAddress->setCustomer($Customer);
$this->entityManager->persist($CustomerAddress);
$this->entityManager->flush($CustomerAddress);
$this->entityManager->flush();
} else {
// 非会員用のセッションに追加
$CustomerAddresses = $this->session->get(OrderHelper::SESSION_NON_MEMBER_ADDRESSES);
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Repository/BlockPositionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function register($data, $Blocks, $UnusedBlocks, $Layout)
->setLayout($Layout);
$Layout->addBlockPosition($BlockPosition);
$em->persist($BlockPosition);
$em->flush($BlockPosition);
$em->flush();
}
}
}
4 changes: 2 additions & 2 deletions src/Eccube/Repository/CategoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function save($Category)

$em = $this->getEntityManager();
$em->persist($Category);
$em->flush($Category);
$em->flush();
}

/**
Expand All @@ -160,6 +160,6 @@ public function delete($Category)

$em = $this->getEntityManager();
$em->remove($Category);
$em->flush($Category);
$em->flush();
}
}
6 changes: 3 additions & 3 deletions src/Eccube/Repository/ClassCategoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function save($ClassCategory)

$em = $this->getEntityManager();
$em->persist($ClassCategory);
$em->flush($ClassCategory);
$em->flush();
}

/**
Expand All @@ -103,7 +103,7 @@ public function delete($ClassCategory)

$em = $this->getEntityManager();
$em->remove($ClassCategory);
$em->flush($ClassCategory);
$em->flush();
}

/**
Expand All @@ -121,6 +121,6 @@ public function toggleVisibility($ClassCategory)

$em = $this->getEntityManager();
$em->persist($ClassCategory);
$em->flush($ClassCategory);
$em->flush();
}
}
4 changes: 2 additions & 2 deletions src/Eccube/Repository/ClassNameRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function save($ClassName)

$em = $this->getEntityManager();
$em->persist($ClassName);
$em->flush([$ClassName]);
$em->flush();
}

/**
Expand All @@ -92,6 +92,6 @@ public function delete($ClassName)

$em = $this->getEntityManager();
$em->remove($ClassName);
$em->flush($ClassName);
$em->flush();
}
}
2 changes: 1 addition & 1 deletion src/Eccube/Repository/CustomerAddressRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ public function delete($CustomerAddress)
{
$em = $this->getEntityManager();
$em->remove($CustomerAddress);
$em->flush($CustomerAddress);
$em->flush();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ public function delete($CustomerFavoriteProduct)
{
$em = $this->getEntityManager();
$em->remove($CustomerFavoriteProduct);
$em->flush($CustomerFavoriteProduct);
$em->flush();
}
}
12 changes: 8 additions & 4 deletions src/Eccube/Repository/MemberRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function up(Member $Member)
$Member2->setSortNo($sortNo);

$em = $this->getEntityManager();
$em->flush([$Member, $Member2]);
$em->persist($Member);
$em->persist($Member2);
$em->flush();
}

/**
Expand All @@ -74,7 +76,9 @@ public function down(Member $Member)
$Member2->setSortNo($sortNo);

$em = $this->getEntityManager();
$em->flush([$Member, $Member2]);
$em->persist($Member);
$em->persist($Member2);
$em->flush();
}

/**
Expand All @@ -95,7 +99,7 @@ public function save($Member)

$em = $this->getEntityManager();
$em->persist($Member);
$em->flush($Member);
$em->flush();
}

/**
Expand All @@ -118,6 +122,6 @@ public function delete($Member)

$em = $this->getEntityManager();
$em->remove($Member);
$em->flush($Member);
$em->flush();
}
}
4 changes: 2 additions & 2 deletions src/Eccube/Repository/NewsRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function save($News)
{
$em = $this->getEntityManager();
$em->persist($News);
$em->flush($News);
$em->flush();
}

/**
Expand All @@ -57,7 +57,7 @@ public function delete($News)
{
$em = $this->getEntityManager();
$em->remove($News);
$em->flush($News);
$em->flush();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Repository/OrderPdfRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function save($arrData)
->setNote3($arrData['note3'])
->setVisible(true);
$this->getEntityManager()->persist($OrderPdf);
$this->getEntityManager()->flush($OrderPdf);
$this->getEntityManager()->flush();

return true;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Eccube/Repository/TagRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function save($tag)

$em = $this->getEntityManager();
$em->persist($tag);
$em->flush($tag);
$em->flush();
}

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ public function delete($Tag)
->execute();

$em->remove($Tag);
$em->flush($Tag);
$em->flush();

$em->commit();
}
Expand Down
17 changes: 9 additions & 8 deletions src/Eccube/Service/CartService.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function getCarts($empty_delete = false)
$cartKeys[] = $Cart->getCartKey();
} else {
$this->entityManager->remove($this->carts[$index]);
$this->entityManager->flush($this->carts[$index]);
$this->entityManager->flush();
unset($this->carts[$index]);
}
}
Expand Down Expand Up @@ -281,10 +281,10 @@ protected function restoreCarts($cartItems)
foreach ($this->getCarts() as $Cart) {
foreach ($Cart->getCartItems() as $i) {
$this->entityManager->remove($i);
$this->entityManager->flush($i);
$this->entityManager->flush();
}
$this->entityManager->remove($Cart);
$this->entityManager->flush($Cart);
$this->entityManager->flush();
}
$this->carts = [];

Expand All @@ -305,10 +305,10 @@ protected function restoreCarts($cartItems)
if ($Cart) {
foreach ($Cart->getCartItems() as $i) {
$this->entityManager->remove($i);
$this->entityManager->flush($i);
$this->entityManager->flush();
}
$this->entityManager->remove($Cart);
$this->entityManager->flush($Cart);
$this->entityManager->flush();
}
$Cart = new Cart();
$Cart->setCartKey($cartKey);
Expand Down Expand Up @@ -400,9 +400,10 @@ public function save()
$this->entityManager->persist($Cart);
foreach ($Cart->getCartItems() as $item) {
$this->entityManager->persist($item);
$this->entityManager->flush($item);
$this->entityManager->flush();
}
$this->entityManager->flush($Cart);
$this->entityManager->persist($Cart);
$this->entityManager->flush();
$cartKeys[] = $Cart->getCartKey();
}

Expand Down Expand Up @@ -446,7 +447,7 @@ public function clear()
$removed = $this->getCart();
if ($removed && UnitOfWork::STATE_MANAGED === $this->entityManager->getUnitOfWork()->getEntityState($removed)) {
$this->entityManager->remove($removed);
$this->entityManager->flush($removed);
$this->entityManager->flush();

$cartKeys = [];
foreach ($Carts as $key => $Cart) {
Expand Down
2 changes: 1 addition & 1 deletion src/Eccube/Service/PluginService.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ public function registerPlugin($meta, $source = 0)
->setCode($meta['code']);

$this->entityManager->persist($p);
$this->entityManager->flush($p);
$this->entityManager->flush();

$this->pluginApiService->pluginInstalled($p);
} catch (\Exception $e) {
Expand Down

0 comments on commit 9687191

Please sign in to comment.