问:
magento2.3.7 Cart additional_options parameter lost after switching user
After opening and exiting the reserved shopping cart, I switch between different accounts in the browser, and the additional_options field in the quote_item_options table is lost, resulting in incomplete display of product specifications

How to modify the core file to add the additional_options field

```<code><?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Checkout\Model;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteIdMaskFactory;
use Psr\Log\LoggerInterface;

/**
 * Represents the session data for the checkout process
 *
 * @api
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
 * @SuppressWarnings(PHPMD.TooManyFields)
 * @since 100.0.2
 */
class Session extends \Magento\Framework\Session\SessionManager
{
    const CHECKOUT_STATE_BEGIN = 'begin';

    /**
     * Quote instance
     *
     * @var Quote
     */
    protected $_quote;

    /**
     * Customer Data Object
     *
     * @var CustomerInterface|null
     */
    protected $_customer;

    /**
     * Whether load only active quote
     *
     * @var bool
     */
    protected $_loadInactive = false;

    /**
     * A flag to track when the quote is being loaded and attached to the session object.
     *
     * Used in trigger_recollect infinite loop detection.
     *
     * @var bool
     */
    private $isLoading = false;

    /**
     * Loaded order instance
     *
     * @var \Magento\Sales\Model\Order
     */
    protected $_order;

    /**
     * @var \Magento\Sales\Model\OrderFactory
     */
    protected $_orderFactory;

    /**
     * @var \Magento\Customer\Model\Session
     */
    protected $_customerSession;

    /**
     * @var \Magento\Quote\Api\CartRepositoryInterface
     */
    protected $quoteRepository;

    /**
     * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress
     */
    protected $_remoteAddress;

    /**
     * @var \Magento\Framework\Event\ManagerInterface
     */
    protected $_eventManager;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    protected $_storeManager;

    /**
     * @var \Magento\Customer\Api\CustomerRepositoryInterface
     */
    protected $customerRepository;

    /**
     * @param QuoteIdMaskFactory
     */
    protected $quoteIdMaskFactory;

    /**
     * @param bool
     */
    protected $isQuoteMasked;

    /**
     * @var \Magento\Quote\Model\QuoteFactory
     */
    protected $quoteFactory;

    /**
     * @var LoggerInterface|null
     */
    private $logger;

    /**
     * @param \Magento\Framework\App\Request\Http $request
     * @param \Magento\Framework\Session\SidResolverInterface $sidResolver
     * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig
     * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler
     * @param \Magento\Framework\Session\ValidatorInterface $validator
     * @param \Magento\Framework\Session\StorageInterface $storage
     * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
     * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
     * @param \Magento\Framework\App\State $appState
     * @param \Magento\Sales\Model\OrderFactory $orderFactory
     * @param \Magento\Customer\Model\Session $customerSession
     * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
     * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
     * @param \Magento\Framework\Event\ManagerInterface $eventManager
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
     * @param QuoteIdMaskFactory $quoteIdMaskFactory
     * @param \Magento\Quote\Model\QuoteFactory $quoteFactory
     * @param LoggerInterface|null $logger
     * @throws \Magento\Framework\Exception\SessionException
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        \Magento\Framework\App\Request\Http $request,
        \Magento\Framework\Session\SidResolverInterface $sidResolver,
        \Magento\Framework\Session\Config\ConfigInterface $sessionConfig,
        \Magento\Framework\Session\SaveHandlerInterface $saveHandler,
        \Magento\Framework\Session\ValidatorInterface $validator,
        \Magento\Framework\Session\StorageInterface $storage,
        \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
        \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
        \Magento\Framework\App\State $appState,
        \Magento\Sales\Model\OrderFactory $orderFactory,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
        \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress,
        \Magento\Framework\Event\ManagerInterface $eventManager,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
        QuoteIdMaskFactory $quoteIdMaskFactory,
        \Magento\Quote\Model\QuoteFactory $quoteFactory,
        LoggerInterface $logger = null
    ) {
        $this->_orderFactory = $orderFactory;
        $this->_customerSession = $customerSession;
        $this->quoteRepository = $quoteRepository;
        $this->_remoteAddress = $remoteAddress;
        $this->_eventManager = $eventManager;
        $this->_storeManager = $storeManager;
        $this->customerRepository = $customerRepository;
        $this->quoteIdMaskFactory = $quoteIdMaskFactory;
        $this->quoteFactory = $quoteFactory;
        parent::__construct(
            $request,
            $sidResolver,
            $sessionConfig,
            $saveHandler,
            $validator,
            $storage,
            $cookieManager,
            $cookieMetadataFactory,
            $appState
        );
        $this->logger = $logger ?: ObjectManager::getInstance()
            ->get(LoggerInterface::class);
    }

    /**
     * Set customer data.
     *
     * @param CustomerInterface|null $customer
     * @return \Magento\Checkout\Model\Session
     * @codeCoverageIgnore
     */
    public function setCustomerData($customer)
    {
        $this->_customer = $customer;
        return $this;
    }

    /**
     * Check whether current session has quote
     *
     * @return bool
     * @codeCoverageIgnore
     */
    public function hasQuote()
    {
        return isset($this->_quote);
    }

    /**
     * Set quote to be loaded even if inactive
     *
     * @param bool $load
     * @return $this
     * @codeCoverageIgnore
     */
    public function setLoadInactive($load = true)
    {
        $this->_loadInactive = $load;
        return $this;
    }

    /**
     * Get checkout quote instance by current session
     *
     * @return Quote
     * @throws \Magento\Framework\Exception\LocalizedException
     * @throws NoSuchEntityException
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function getQuote()
    {
        $this->_eventManager->dispatch('custom_quote_process', ['checkout_session' => $this]);

        if ($this->_quote === null) {
            if ($this->isLoading) {
                throw new \LogicException("Infinite loop detected, review the trace for the looping path");
            }
            $this->isLoading = true;
            $quote = $this->quoteFactory->create();
            if ($this->getQuoteId()) {
                try {
                    if ($this->_loadInactive) {
                        $quote = $this->quoteRepository->get($this->getQuoteId());
                    } else {
                        $quote = $this->quoteRepository->getActive($this->getQuoteId());
                    }

                    $customerId = $this->_customer
                        ? $this->_customer->getId()
                        : $this->_customerSession->getCustomerId();

                    if ($quote->getData('customer_id') && (int)$quote->getData('customer_id') !== (int)$customerId) {
                        $quote = $this->quoteFactory->create();
                        $this->setQuoteId(null);
                    }

                    /**
                     * If current currency code of quote is not equal current currency code of store,
                     * need recalculate totals of quote. It is possible if customer use currency switcher or
                     * store switcher.
                     */
                    if ($quote->getQuoteCurrencyCode() != $this->_storeManager->getStore()->getCurrentCurrencyCode()) {
                        $quote->setStore($this->_storeManager->getStore());
                        $this->quoteRepository->save($quote->collectTotals());
                        /*
                         * We mast to create new quote object, because collectTotals()
                         * can to create links with other objects.
                         */
                        $quote = $this->quoteRepository->get($this->getQuoteId());
                    }

                    if ($quote->getTotalsCollectedFlag() === false) {
                        $quote->collectTotals();
                    }
                } catch (NoSuchEntityException $e) {
                    $this->setQuoteId(null);
                }
            }

            if (!$this->getQuoteId()) {
                if ($this->_customerSession->isLoggedIn() || $this->_customer) {
                    $quoteByCustomer = $this->getQuoteByCustomer();
                    if ($quoteByCustomer !== null) {
                        $this->setQuoteId($quoteByCustomer->getId());
                        $quote = $quoteByCustomer;
                    }
                } else {
                    $quote->setIsCheckoutCart(true);
                    $quote->setCustomerIsGuest(1);
                    $this->_eventManager->dispatch('checkout_quote_init', ['quote' => $quote]);
                }
            }

            if ($this->_customer) {
                $quote->setCustomer($this->_customer);
            } elseif ($this->_customerSession->isLoggedIn()) {
                $quote->setCustomer($this->customerRepository->getById($this->_customerSession->getCustomerId()));
            }

            $quote->setStore($this->_storeManager->getStore());
            $this->_quote = $quote;
            $this->isLoading = false;
        }

        if (!$this->isQuoteMasked() && !$this->_customerSession->isLoggedIn() && $this->getQuoteId()) {
            $quoteId = $this->getQuoteId();
            /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
            $quoteIdMask = $this->quoteIdMaskFactory->create()->load($quoteId, 'quote_id');
            if ($quoteIdMask->getMaskedId() === null) {
                $quoteIdMask->setQuoteId($quoteId)->save();
            }
            $this->setIsQuoteMasked(true);
        }

        $remoteAddress = $this->_remoteAddress->getRemoteAddress();
        if ($remoteAddress) {
            $this->_quote->setRemoteIp($remoteAddress);
            $xForwardIp = $this->request->getServer('HTTP_X_FORWARDED_FOR');
            $this->_quote->setXForwardedFor($xForwardIp);
        }

        return $this->_quote;
    }

    /**
     * Return the quote's key
     *
     * @return string
     * @codeCoverageIgnore
     */
    protected function _getQuoteIdKey()
    {
        return 'quote_id_' . $this->_storeManager->getStore()->getWebsiteId();
    }

    /**
     * Set the current session's quote id
     *
     * @param int $quoteId
     * @return void
     * @codeCoverageIgnore
     */
    public function setQuoteId($quoteId)
    {
        $this->storage->setData($this->_getQuoteIdKey(), $quoteId);
    }

    /**
     * Return the current quote's ID
     *
     * @return int
     * @codeCoverageIgnore
     */
    public function getQuoteId()
    {
        return $this->getData($this->_getQuoteIdKey());
    }

    /**
     * Load data for customer quote and merge with current quote
     *
     * @return $this
     */
    public function loadCustomerQuote()
    {
        if (!$this->_customerSession->getCustomerId()) {
            return $this;
        }

        $this->_eventManager->dispatch('load_customer_quote_before', ['checkout_session' => $this]);

        try {
            $customerQuote = $this->quoteRepository->getForCustomer($this->_customerSession->getCustomerId());
        } catch (NoSuchEntityException $e) {
            $customerQuote = $this->quoteFactory->create();
        }
        $customerQuote->setStoreId($this->_storeManager->getStore()->getId());

        if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) {
            if ($this->getQuoteId()) {
                $quote = $this->getQuote();
                $quote->setCustomerIsGuest(0);
                $this->quoteRepository->save(
                    $customerQuote->merge($quote)->collectTotals()
                );
                $newQuote = $this->quoteRepository->get($customerQuote->getId());
                $this->quoteRepository->save(
                    $newQuote->collectTotals()
                );
                $customerQuote = $newQuote;
            }

            $this->setQuoteId($customerQuote->getId());

            if ($this->_quote) {
                $this->quoteRepository->delete($this->_quote);
            }
            $this->_quote = $customerQuote;
        } else {
            $this->getQuote()->getBillingAddress();
            $this->getQuote()->getShippingAddress();
            $this->getQuote()->setCustomer($this->_customerSession->getCustomerDataObject())
                ->setCustomerIsGuest(0)
                ->setTotalsCollectedFlag(false)
                ->collectTotals();
            $this->quoteRepository->save($this->getQuote());
        }
        return $this;
    }

    /**
     * Associate data to a specified step of the checkout process
     *
     * @param string $step
     * @param array|string $data
     * @param bool|string|null $value
     * @return $this
     */
    public function setStepData($step, $data, $value = null)
    {
        $steps = $this->getSteps();
        if ($value === null) {
            if (is_array($data)) {
                $steps[$step] = $data;
            }
        } else {
            if (!isset($steps[$step])) {
                $steps[$step] = [];
            }
            if (is_string($data)) {
                $steps[$step][$data] = $value;
            }
        }
        $this->setSteps($steps);

        return $this;
    }

    /**
     * Return the data associated to a specified step
     *
     * @param string|null $step
     * @param string|null $data
     * @return array|string|bool
     */
    public function getStepData($step = null, $data = null)
    {
        $steps = $this->getSteps();
        if ($step === null) {
            return $steps;
        }
        if (!isset($steps[$step])) {
            return false;
        }
        if ($data === null) {
            return $steps[$step];
        }
        if (!is_string($data) || !isset($steps[$step][$data])) {
            return false;
        }
        return $steps[$step][$data];
    }

    /**
     * Destroy/end a session and unset all data associated with it
     *
     * @return $this
     */
    public function clearQuote()
    {
        $this->_eventManager->dispatch('checkout_quote_destroy', ['quote' => $this->getQuote()]);
        $this->_quote = null;
        $this->setQuoteId(null);
        $this->setLastSuccessQuoteId(null);
        return $this;
    }

    /**
     * Unset all session data and quote
     *
     * @return $this
     */
    public function clearStorage()
    {
        parent::clearStorage();
        $this->_quote = null;
        return $this;
    }

    /**
     * Clear misc checkout parameters
     *
     * @return void
     */
    public function clearHelperData()
    {
        $this->setRedirectUrl(null)->setLastOrderId(null)->setLastRealOrderId(null)->setAdditionalMessages(null);
    }

    /**
     * Revert the state of the checkout to the beginning
     *
     * @return $this
     * @codeCoverageIgnore
     */
    public function resetCheckout()
    {
        $this->setCheckoutState(self::CHECKOUT_STATE_BEGIN);
        return $this;
    }

    /**
     * Replace the quote in the session with a specified object
     *
     * @param Quote $quote
     * @return $this
     */
    public function replaceQuote($quote)
    {
        $this->_quote = $quote;
        $this->setQuoteId($quote->getId());
        return $this;
    }

    /**
     * Get order instance based on last order ID
     *
     * @return \Magento\Sales\Model\Order
     */
    public function getLastRealOrder()
    {
        $orderId = $this->getLastRealOrderId();
        if ($this->_order !== null && $orderId == $this->_order->getIncrementId()) {
            return $this->_order;
        }
        $this->_order = $this->_orderFactory->create();
        if ($orderId) {
            $this->_order->loadByIncrementId($orderId);
        }
        return $this->_order;
    }

    /**
     * Restore last active quote
     *
     * @return bool True if quote restored successfully, false otherwise
     */
    public function restoreQuote()
    {
        /** @var \Magento\Sales\Model\Order $order */
        $order = $this->getLastRealOrder();
        if ($order->getId()) {
            try {
                $quote = $this->quoteRepository->get($order->getQuoteId());
                $quote->setIsActive(1)->setReservedOrderId(null);
                $this->quoteRepository->save($quote);
                $this->replaceQuote($quote)->unsLastRealOrderId();
                $this->_eventManager->dispatch('restore_quote', ['order' => $order, 'quote' => $quote]);
                return true;
            } catch (NoSuchEntityException $e) {
                $this->logger->critical($e);
            }
        }

        return false;
    }

    /**
     * Flag whether or not the quote uses a masked quote id
     *
     * @param bool $isQuoteMasked
     * @return void
     * @codeCoverageIgnore
     */
    protected function setIsQuoteMasked($isQuoteMasked)
    {
        $this->isQuoteMasked = $isQuoteMasked;
    }

    /**
     * Return if the quote has a masked quote id
     *
     * @return bool|null
     * @codeCoverageIgnore
     */
    protected function isQuoteMasked()
    {
        return $this->isQuoteMasked;
    }

    /**
     * Returns quote for customer if there is any
     */
    private function getQuoteByCustomer(): ?CartInterface
    {
        $customerId = $this->_customer
            ? $this->_customer->getId()
            : $this->_customerSession->getCustomerId();

        try {
            $quote = $this->quoteRepository->getActiveForCustomer($customerId);
        } catch (NoSuchEntityException $e) {
            $quote = null;
        }

        return $quote;
    }
}

</code>```

Body:
After opening and exiting the reserved shopping cart, I switch between different accounts in the browser, and the additional_options field in the quote_item_options table is lost, resulting in incomplete display of product specifications

How to modify the core file to add the additional_options field

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\Checkout\Model;

use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteIdMaskFactory;
use Psr\Log\LoggerInterface;

/**
 * Represents the session data for the checkout process
 *
 * @api
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
 * @SuppressWarnings(PHPMD.TooManyFields)
 * @since 100.0.2
 */
class Session extends \Magento\Framework\Session\SessionManager
{
    const CHECKOUT_STATE_BEGIN = 'begin';

    /**
     * Quote instance
     *
     * @var Quote
     */
    protected $_quote;

    /**
     * Customer Data Object
     *
     * @var CustomerInterface|null
     */
    protected $_customer;

    /**
     * Whether load only active quote
     *
     * @var bool
     */
    protected $_loadInactive = false;

    /**
     * A flag to track when the quote is being loaded and attached to the session object.
     *
     * Used in trigger_recollect infinite loop detection.
     *
     * @var bool
     */
    private $isLoading = false;

    /**
     * Loaded order instance
     *
     * @var \Magento\Sales\Model\Order
     */
    protected $_order;

    /**
     * @var \Magento\Sales\Model\OrderFactory
     */
    protected $_orderFactory;

    /**
     * @var \Magento\Customer\Model\Session
     */
    protected $_customerSession;

    /**
     * @var \Magento\Quote\Api\CartRepositoryInterface
     */
    protected $quoteRepository;

    /**
     * @var \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress
     */
    protected $_remoteAddress;

    /**
     * @var \Magento\Framework\Event\ManagerInterface
     */
    protected $_eventManager;

    /**
     * @var \Magento\Store\Model\StoreManagerInterface
     */
    protected $_storeManager;

    /**
     * @var \Magento\Customer\Api\CustomerRepositoryInterface
     */
    protected $customerRepository;

    /**
     * @param QuoteIdMaskFactory
     */
    protected $quoteIdMaskFactory;

    /**
     * @param bool
     */
    protected $isQuoteMasked;

    /**
     * @var \Magento\Quote\Model\QuoteFactory
     */
    protected $quoteFactory;

    /**
     * @var LoggerInterface|null
     */
    private $logger;

    /**
     * @param \Magento\Framework\App\Request\Http $request
     * @param \Magento\Framework\Session\SidResolverInterface $sidResolver
     * @param \Magento\Framework\Session\Config\ConfigInterface $sessionConfig
     * @param \Magento\Framework\Session\SaveHandlerInterface $saveHandler
     * @param \Magento\Framework\Session\ValidatorInterface $validator
     * @param \Magento\Framework\Session\StorageInterface $storage
     * @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
     * @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
     * @param \Magento\Framework\App\State $appState
     * @param \Magento\Sales\Model\OrderFactory $orderFactory
     * @param \Magento\Customer\Model\Session $customerSession
     * @param \Magento\Quote\Api\CartRepositoryInterface $quoteRepository
     * @param \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress
     * @param \Magento\Framework\Event\ManagerInterface $eventManager
     * @param \Magento\Store\Model\StoreManagerInterface $storeManager
     * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
     * @param QuoteIdMaskFactory $quoteIdMaskFactory
     * @param \Magento\Quote\Model\QuoteFactory $quoteFactory
     * @param LoggerInterface|null $logger
     * @throws \Magento\Framework\Exception\SessionException
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        \Magento\Framework\App\Request\Http $request,
        \Magento\Framework\Session\SidResolverInterface $sidResolver,
        \Magento\Framework\Session\Config\ConfigInterface $sessionConfig,
        \Magento\Framework\Session\SaveHandlerInterface $saveHandler,
        \Magento\Framework\Session\ValidatorInterface $validator,
        \Magento\Framework\Session\StorageInterface $storage,
        \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager,
        \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory,
        \Magento\Framework\App\State $appState,
        \Magento\Sales\Model\OrderFactory $orderFactory,
        \Magento\Customer\Model\Session $customerSession,
        \Magento\Quote\Api\CartRepositoryInterface $quoteRepository,
        \Magento\Framework\HTTP\PhpEnvironment\RemoteAddress $remoteAddress,
        \Magento\Framework\Event\ManagerInterface $eventManager,
        \Magento\Store\Model\StoreManagerInterface $storeManager,
        \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
        QuoteIdMaskFactory $quoteIdMaskFactory,
        \Magento\Quote\Model\QuoteFactory $quoteFactory,
        LoggerInterface $logger = null
    ) {
        $this->_orderFactory = $orderFactory;
        $this->_customerSession = $customerSession;
        $this->quoteRepository = $quoteRepository;
        $this->_remoteAddress = $remoteAddress;
        $this->_eventManager = $eventManager;
        $this->_storeManager = $storeManager;
        $this->customerRepository = $customerRepository;
        $this->quoteIdMaskFactory = $quoteIdMaskFactory;
        $this->quoteFactory = $quoteFactory;
        parent::__construct(
            $request,
            $sidResolver,
            $sessionConfig,
            $saveHandler,
            $validator,
            $storage,
            $cookieManager,
            $cookieMetadataFactory,
            $appState
        );
        $this->logger = $logger ?: ObjectManager::getInstance()
            ->get(LoggerInterface::class);
    }

    /**
     * Set customer data.
     *
     * @param CustomerInterface|null $customer
     * @return \Magento\Checkout\Model\Session
     * @codeCoverageIgnore
     */
    public function setCustomerData($customer)
    {
        $this->_customer = $customer;
        return $this;
    }

    /**
     * Check whether current session has quote
     *
     * @return bool
     * @codeCoverageIgnore
     */
    public function hasQuote()
    {
        return isset($this->_quote);
    }

    /**
     * Set quote to be loaded even if inactive
     *
     * @param bool $load
     * @return $this
     * @codeCoverageIgnore
     */
    public function setLoadInactive($load = true)
    {
        $this->_loadInactive = $load;
        return $this;
    }

    /**
     * Get checkout quote instance by current session
     *
     * @return Quote
     * @throws \Magento\Framework\Exception\LocalizedException
     * @throws NoSuchEntityException
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     */
    public function getQuote()
    {
        $this->_eventManager->dispatch('custom_quote_process', ['checkout_session' => $this]);

        if ($this->_quote === null) {
            if ($this->isLoading) {
                throw new \LogicException("Infinite loop detected, review the trace for the looping path");
            }
            $this->isLoading = true;
            $quote = $this->quoteFactory->create();
            if ($this->getQuoteId()) {
                try {
                    if ($this->_loadInactive) {
                        $quote = $this->quoteRepository->get($this->getQuoteId());
                    } else {
                        $quote = $this->quoteRepository->getActive($this->getQuoteId());
                    }

                    $customerId = $this->_customer
                        ? $this->_customer->getId()
                        : $this->_customerSession->getCustomerId();

                    if ($quote->getData('customer_id') && (int)$quote->getData('customer_id') !== (int)$customerId) {
                        $quote = $this->quoteFactory->create();
                        $this->setQuoteId(null);
                    }

                    /**
                     * If current currency code of quote is not equal current currency code of store,
                     * need recalculate totals of quote. It is possible if customer use currency switcher or
                     * store switcher.
                     */
                    if ($quote->getQuoteCurrencyCode() != $this->_storeManager->getStore()->getCurrentCurrencyCode()) {
                        $quote->setStore($this->_storeManager->getStore());
                        $this->quoteRepository->save($quote->collectTotals());
                        /*
                         * We mast to create new quote object, because collectTotals()
                         * can to create links with other objects.
                         */
                        $quote = $this->quoteRepository->get($this->getQuoteId());
                    }

                    if ($quote->getTotalsCollectedFlag() === false) {
                        $quote->collectTotals();
                    }
                } catch (NoSuchEntityException $e) {
                    $this->setQuoteId(null);
                }
            }

            if (!$this->getQuoteId()) {
                if ($this->_customerSession->isLoggedIn() || $this->_customer) {
                    $quoteByCustomer = $this->getQuoteByCustomer();
                    if ($quoteByCustomer !== null) {
                        $this->setQuoteId($quoteByCustomer->getId());
                        $quote = $quoteByCustomer;
                    }
                } else {
                    $quote->setIsCheckoutCart(true);
                    $quote->setCustomerIsGuest(1);
                    $this->_eventManager->dispatch('checkout_quote_init', ['quote' => $quote]);
                }
            }

            if ($this->_customer) {
                $quote->setCustomer($this->_customer);
            } elseif ($this->_customerSession->isLoggedIn()) {
                $quote->setCustomer($this->customerRepository->getById($this->_customerSession->getCustomerId()));
            }

            $quote->setStore($this->_storeManager->getStore());
            $this->_quote = $quote;
            $this->isLoading = false;
        }

        if (!$this->isQuoteMasked() && !$this->_customerSession->isLoggedIn() && $this->getQuoteId()) {
            $quoteId = $this->getQuoteId();
            /** @var $quoteIdMask \Magento\Quote\Model\QuoteIdMask */
            $quoteIdMask = $this->quoteIdMaskFactory->create()->load($quoteId, 'quote_id');
            if ($quoteIdMask->getMaskedId() === null) {
                $quoteIdMask->setQuoteId($quoteId)->save();
            }
            $this->setIsQuoteMasked(true);
        }

        $remoteAddress = $this->_remoteAddress->getRemoteAddress();
        if ($remoteAddress) {
            $this->_quote->setRemoteIp($remoteAddress);
            $xForwardIp = $this->request->getServer('HTTP_X_FORWARDED_FOR');
            $this->_quote->setXForwardedFor($xForwardIp);
        }

        return $this->_quote;
    }

    /**
     * Return the quote's key
     *
     * @return string
     * @codeCoverageIgnore
     */
    protected function _getQuoteIdKey()
    {
        return 'quote_id_' . $this->_storeManager->getStore()->getWebsiteId();
    }

    /**
     * Set the current session's quote id
     *
     * @param int $quoteId
     * @return void
     * @codeCoverageIgnore
     */
    public function setQuoteId($quoteId)
    {
        $this->storage->setData($this->_getQuoteIdKey(), $quoteId);
    }

    /**
     * Return the current quote's ID
     *
     * @return int
     * @codeCoverageIgnore
     */
    public function getQuoteId()
    {
        return $this->getData($this->_getQuoteIdKey());
    }

    /**
     * Load data for customer quote and merge with current quote
     *
     * @return $this
     */
    public function loadCustomerQuote()
    {
        if (!$this->_customerSession->getCustomerId()) {
            return $this;
        }

        $this->_eventManager->dispatch('load_customer_quote_before', ['checkout_session' => $this]);

        try {
            $customerQuote = $this->quoteRepository->getForCustomer($this->_customerSession->getCustomerId());
        } catch (NoSuchEntityException $e) {
            $customerQuote = $this->quoteFactory->create();
        }
        $customerQuote->setStoreId($this->_storeManager->getStore()->getId());

        if ($customerQuote->getId() && $this->getQuoteId() != $customerQuote->getId()) {
            if ($this->getQuoteId()) {
                $quote = $this->getQuote();
                $quote->setCustomerIsGuest(0);
                $this->quoteRepository->save(
                    $customerQuote->merge($quote)->collectTotals()
                );
                $newQuote = $this->quoteRepository->get($customerQuote->getId());
                $this->quoteRepository->save(
                    $newQuote->collectTotals()
                );
                $customerQuote = $newQuote;
            }

            $this->setQuoteId($customerQuote->getId());

            if ($this->_quote) {
                $this->quoteRepository->delete($this->_quote);
            }
            $this->_quote = $customerQuote;
        } else {
            $this->getQuote()->getBillingAddress();
            $this->getQuote()->getShippingAddress();
            $this->getQuote()->setCustomer($this->_customerSession->getCustomerDataObject())
                ->setCustomerIsGuest(0)
                ->setTotalsCollectedFlag(false)
                ->collectTotals();
            $this->quoteRepository->save($this->getQuote());
        }
        return $this;
    }

    /**
     * Associate data to a specified step of the checkout process
     *
     * @param string $step
     * @param array|string $data
     * @param bool|string|null $value
     * @return $this
     */
    public function setStepData($step, $data, $value = null)
    {
        $steps = $this->getSteps();
        if ($value === null) {
            if (is_array($data)) {
                $steps[$step] = $data;
            }
        } else {
            if (!isset($steps[$step])) {
                $steps[$step] = [];
            }
            if (is_string($data)) {
                $steps[$step][$data] = $value;
            }
        }
        $this->setSteps($steps);

        return $this;
    }

    /**
     * Return the data associated to a specified step
     *
     * @param string|null $step
     * @param string|null $data
     * @return array|string|bool
     */
    public function getStepData($step = null, $data = null)
    {
        $steps = $this->getSteps();
        if ($step === null) {
            return $steps;
        }
        if (!isset($steps[$step])) {
            return false;
        }
        if ($data === null) {
            return $steps[$step];
        }
        if (!is_string($data) || !isset($steps[$step][$data])) {
            return false;
        }
        return $steps[$step][$data];
    }

    /**
     * Destroy/end a session and unset all data associated with it
     *
     * @return $this
     */
    public function clearQuote()
    {
        $this->_eventManager->dispatch('checkout_quote_destroy', ['quote' => $this->getQuote()]);
        $this->_quote = null;
        $this->setQuoteId(null);
        $this->setLastSuccessQuoteId(null);
        return $this;
    }

    /**
     * Unset all session data and quote
     *
     * @return $this
     */
    public function clearStorage()
    {
        parent::clearStorage();
        $this->_quote = null;
        return $this;
    }

    /**
     * Clear misc checkout parameters
     *
     * @return void
     */
    public function clearHelperData()
    {
        $this->setRedirectUrl(null)->setLastOrderId(null)->setLastRealOrderId(null)->setAdditionalMessages(null);
    }

    /**
     * Revert the state of the checkout to the beginning
     *
     * @return $this
     * @codeCoverageIgnore
     */
    public function resetCheckout()
    {
        $this->setCheckoutState(self::CHECKOUT_STATE_BEGIN);
        return $this;
    }

    /**
     * Replace the quote in the session with a specified object
     *
     * @param Quote $quote
     * @return $this
     */
    public function replaceQuote($quote)
    {
        $this->_quote = $quote;
        $this->setQuoteId($quote->getId());
        return $this;
    }

    /**
     * Get order instance based on last order ID
     *
     * @return \Magento\Sales\Model\Order
     */
    public function getLastRealOrder()
    {
        $orderId = $this->getLastRealOrderId();
        if ($this->_order !== null && $orderId == $this->_order->getIncrementId()) {
            return $this->_order;
        }
        $this->_order = $this->_orderFactory->create();
        if ($orderId) {
            $this->_order->loadByIncrementId($orderId);
        }
        return $this->_order;
    }

    /**
     * Restore last active quote
     *
     * @return bool True if quote restored successfully, false otherwise
     */
    public function restoreQuote()
    {
        /** @var \Magento\Sales\Model\Order $order */
        $order = $this->getLastRealOrder();
        if ($order->getId()) {
            try {
                $quote = $this->quoteRepository->get($order->getQuoteId());
                $quote->setIsActive(1)->setReservedOrderId(null);
                $this->quoteRepository->save($quote);
                $this->replaceQuote($quote)->unsLastRealOrderId();
                $this->_eventManager->dispatch('restore_quote', ['order' => $order, 'quote' => $quote]);
                return true;
            } catch (NoSuchEntityException $e) {
                $this->logger->critical($e);
            }
        }

        return false;
    }

    /**
     * Flag whether or not the quote uses a masked quote id
     *
     * @param bool $isQuoteMasked
     * @return void
     * @codeCoverageIgnore
     */
    protected function setIsQuoteMasked($isQuoteMasked)
    {
        $this->isQuoteMasked = $isQuoteMasked;
    }

    /**
     * Return if the quote has a masked quote id
     *
     * @return bool|null
     * @codeCoverageIgnore
     */
    protected function isQuoteMasked()
    {
        return $this->isQuoteMasked;
    }

    /**
     * Returns quote for customer if there is any
     */
    private function getQuoteByCustomer(): ?CartInterface
    {
        $customerId = $this->_customer
            ? $this->_customer->getId()
            : $this->_customerSession->getCustomerId();

        try {
            $quote = $this->quoteRepository->getActiveForCustomer($customerId);
        } catch (NoSuchEntityException $e) {
            $quote = null;
        }

        return $quote;
    }
}


来源: stackexchange

问:
How can I write an if/else loop that searches for an newRecord in a table and clicks it, or goes to the next page?
Scenario:
I'm using CodeceptJS to automate:

creating a new record on a table (paginates on 20 records)

searching the table for the record

if the record can be found on the first page, click it

else click the next button and try search until the record is found.

I can easily find the record if it's on the first page by searching the table div and inserting the newRecordID.
But I'm struggling to write an if/else loop that'll iterate through each page until the record is found.
The below code also doesn't click the next button for some reason.

My best attempt:

```<code>let searchID = {xpath: "//div[normalize-space()= '"+ newRecordID +"'][1]"};

if (searchID) {
    I.click(searchID); //I click the id if found
    I.wait(2);
    I.say("found it");
}
else {
   I.click(locatorsPage.locators.nextButton); //clicks the next page button
   I.click(searchID);
    I.wait(2);
    I.say("found it on another page");
}
</code>```

I tried something along this line but no luck yet:

```<code>do {
    I.click(searchID);
        I.wait(2);
        I.say("found it");

    if (searchID) {
        I.seeElementInDOM(searchID);

    } else {
        I.click(locatorsPage.locators.nextBtn);
        I.click(searchID);
         I.wait(2);
         I.say("found it second page")
        }}
         while (!searchID);

});
</code>```

ContentLicense: CC BY-SA 4.0

Body:
Scenario:
I'm using CodeceptJS to automate:

creating a new record on a table (paginates on 20 records)

searching the table for the record

if the record can be found on the first page, click it

else click the next button and try search until the record is found.

I can easily find the record if it's on the first page by searching the table div and inserting the newRecordID.
But I'm struggling to write an if/else loop that'll iterate through each page until the record is found.
The below code also doesn't click the next button for some reason.

My best attempt:

let searchID = {xpath: "//div[normalize-space()= '"+ newRecordID +"'][1]"};

if (searchID) {
    I.click(searchID); //I click the id if found
    I.wait(2);
    I.say("found it");
}
else {
   I.click(locatorsPage.locators.nextButton); //clicks the next page button
   I.click(searchID);
    I.wait(2);
    I.say("found it on another page");
}

I tried something along this line but no luck yet:

do {
    I.click(searchID);
        I.wait(2);
        I.say("found it");

    if (searchID) {
        I.seeElementInDOM(searchID);

    } else {
        I.click(locatorsPage.locators.nextBtn);
        I.click(searchID);
         I.wait(2);
         I.say("found it second page")
        }}
         while (!searchID);

});


问:
How to embed a Google form survey into my R Markdown website?
I wanted to embed a Google Form survey to my R Markdown website. However, I could not find a solution here in Stack overflow. I eventually figured it out and so I decided to ask and answer this question to help somebody out in the future. I would appreciate if somebody else could add a better and more detailed answer to the question!

Paste the HTML embed link (...) from the google form inside the Rmd file and then just knit the file.
You can find the embed link here: Send → Send via "< >" (while in your google form editor).

Here is a minimum working example (MWE):

```<code>---
title: "Google Form"
output:
  html_document
---

Please take a few minutes to answer the following survey.

<iframe src="https://docs.google.com/forms/d/e/1FAIpQLSd9gYiUPMeav4H7jh2_8FdTtLCQ8ROYiF1I5y-kN4y5JhoDDw/viewform?embedded=true" width="640" height="1200" frameborder="0" marginheight="0" marginwidth="0">Loading…</iframe>
</code>```

This will render a full page view of the form.

If you want to place it inside a vertically scrollable container, use the following code (adding the style attributes):

```<code><iframe src="https://docs.google.com/forms/d/e/1FAIpQLSd9gYiUPMeav4H7jh2_8FdTtLCQ8ROYiF1I5y-kN4y5JhoDDw/viewform?embedded=true" width="640" height="1200" frameborder="0" marginheight="0" marginwidth="0" style= "border: none; max-width:100%; max-height:100vh" allowfullscreen webkitallowfullscreen mozallowfullscreen msallowfullscreen>Loading…</iframe>
</code>```

This is a very minimalistic answer. I am sure those with more experience can add more insights below!

Body:
I wanted to embed a Google Form survey to my R Markdown website. However, I could not find a solution here in Stack overflow. I eventually figured it out and so I decided to ask and answer this question to help somebody out in the future. I would appreciate if somebody else could add a better and more detailed answer to the question!

Paste the HTML embed link (...) from the google form inside the Rmd file and then just knit the file.
You can find the embed link here: Send → Send via "< >" (while in your google form editor).

Here is a minimum working example (MWE):

---
title: "Google Form"
output:
  html_document
---

Please take a few minutes to answer the following survey.

Loading…

This will render a full page view of the form.

If you want to place it inside a vertically scrollable container, use the following code (adding the style attributes):

Loading…

This is a very minimalistic answer. I am sure those with more experience can add more insights below!


问:
How can I use emotion/styled in my react project on codepen?
I need to be able to use @emotion/styled CSS-in-JS library so I can pass props to the background-color and color properties of my Button component. The background-color and color of the buttons are supposed to change with the rest of the app.

The commented out section that starts the JS section:

```<code>import EmotionStyled from "https://cdn.skypack.dev/@emotion/styled@11.10.5";
import styled from "https://cdn.skypack.dev/@emotion/styled@11.10.5"

function Button(props) {
  const Button = styled.button`
    margin-top: 2rem;
    background-color: ${props.colorChange};
    color: white;
    border: none;
    height: 2.5rem;
    border-radius: 4px;
    padding: 0 1rem;
    font-size: 1rem;
    &:nth-of-type(1) {
      margin-right: 0.5rem;
    }
    &:hover {
      background-color: ${props.colorChange};
      opacity: 0.9;
    }
  `

  return (
    <div className='buttons'>
      <div className='left'>
        <Button><a href='https://twitter.com/intent/tweet?hashtags=quotes&related=freecodecamp&text=%22Everything%20has%20beauty%2C%20but%20not%20everyone%20can%20see.%22%20Confucius' id='tweet-quote'
        target='_blank'
        rel='noreferrer'><i className="fa-brands fa-twitter"></i></a></Button>
        <Button><a href='https://www.tumblr.com/login?redirect_to=https%3A%2F%2Fwww.tumblr.com%2Fwidgets%2Fshare%2Ftool%3Fposttype%3Dquote%26tags%3Dquotes%252Cfreecodecamp%26caption%3DConfucius%26content%3DEverything%2Bhas%2Bbeauty%252C%2Bbut%2Bnot%2Beveryone%2Bcan%2Bsee.%26canonicalUrl%3Dhttps%253A%252F%252Fwww.tumblr.com%252Fbuttons%26shareSource%3Dtumblr_share_button' id='tumblr-quote'
        target='_blank'
        rel='noreferrer'><i className="fa-brands fa-tumblr"></i></a></Button>
      </div>
      <Button id='new-quote'
      onClick={props.handleChange}
      >New quote</Button>
    </div>
  )
}
</code>```

is supposed to replace the Button component I have in place at the moment. Whenever I use this emotion-styled Button component, everything goes blank. Please help!

Here is a link to the codepen project: https://codepen.io/lawlessIndi/pen/gOKjNMG.

Body:
I need to be able to use @emotion/styled CSS-in-JS library so I can pass props to the background-color and color properties of my Button component. The background-color and color of the buttons are supposed to change with the rest of the app.

The commented out section that starts the JS section:

import EmotionStyled from "https://cdn.skypack.dev/@emotion/styled@11.10.5";
import styled from "https://cdn.skypack.dev/@emotion/styled@11.10.5"

function Button(props) {
  const Button = styled.button`
    margin-top: 2rem;
    background-color: ${props.colorChange};
    color: white;
    border: none;
    height: 2.5rem;
    border-radius: 4px;
    padding: 0 1rem;
    font-size: 1rem;
    &:nth-of-type(1) {
      margin-right: 0.5rem;
    }
    &:hover {
      background-color: ${props.colorChange};
      opacity: 0.9;
    }
  `

  return (

        <Button></Button>
        <Button></Button>

      <Button id='new-quote'
      onClick={props.handleChange}
      >New quote</Button>

  )
}

is supposed to replace the Button component I have in place at the moment. Whenever I use this emotion-styled Button component, everything goes blank. Please help!

Here is a link to the codepen project: https://codepen.io/lawlessIndi/pen/gOKjNMG.


问:
I want to sum all the cells where the amount is and add them in the total field

I have a table in HTML with input fields and I am adding and deleting new rows on button clicks events, What I want every time new fields are created when I type in the price input then the value of each cell with a price is taken, and placed inside the total field.

Because I'm new to the world of JQuery, I'm having trouble getting the theme into the input fields.

// Special increase cells each time by clicking on add
$('#add').click(function() {
  var size = $('#table_field tbody').children().length + 1;
  var html = '
' + '' + size + '	' + '<input type="text" class="code" name="code">	<input type="text" class=" form-control totalprice" name="pvu_price[]">	<input type="button" class="btn btn-danger" name="remove" id="remove" value="delete" style="color:white;">
';
  $('#table_field').append(html);
});

$('#table_field').on('click', '#remove', function() {
  $(this).closest('tr').remove();
});```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<table class="table table-bordered table_field" id="table_field">
  <thead>
    <tr class="thead-dark">
      <th> #</th>
      <th style="width: 150px; !important"> code</th>
      <th style="width: 150px; !important"> price</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>1</td>
      <td>
        <input type="text" class="code" name="code">
        <td>
          <input type="text" value="" class="sub_code form-control totalprice" id="count" name="pvu_price[]">
        </td>
        <td>
          <input type="button" class="btn btn-success" name="add" id="add" value="add" style="color: white">
        </td>
    </tr>
  </tbody>
  <tfoot>
    <tr>
    </tr>
  </tfoot>
</table></code>```

Body:
I have a table in HTML with input fields and I am adding and deleting new rows on button clicks events, What I want every time new fields are created when I type in the price input then the value of each cell with a price is taken, and placed inside the total field.

Because I'm new to the world of JQuery, I'm having trouble getting the theme into the input fields.

// Special increase cells each time by clicking on add
$('#add').click(function() {
  var size = $('#table_field tbody').children().length + 1;
  var html = '
' + '' + size + '	' + '<input type="text" class="code" name="code">	<input type="text" class=" form-control totalprice" name="pvu_price[]">	<input type="button" class="btn btn-danger" name="remove" id="remove" value="delete" style="color:white;">
';
  $('#table_field').append(html);
});

$('#table_field').on('click', '#remove', function() {
  $(this).closest('tr').remove();
});

       #
       code
       price

      1

        <input type="text" class="code" name="code">

          <input type="text" value="" class="sub_code form-control totalprice" id="count" name="pvu_price[]">

          <input type="button" class="btn btn-success" name="add" id="add" value="add" style="color: white">


问:
Symfony WebTestCase hook into database listeners
So Im trying to hook into the database events of doctrine from the WebTestCase of Symfony.

I setup the client like this:

```<code>self::$client = static::createClient();
self::$client->followRedirects(true);
self::$client->setMaxRedirects(10);

$doctrineDefaultManager = self::getContainer()->get('doctrine.orm.default_entity_manager');
$doctrineDefaultManager->getConnection()->getConfiguration()->getSQLLogger();

/** some other code loading database and fixtures etc **/

// Im adding the event listener to the defaultmanager here
$doctrineDefaultManager->getEventManager()->addEventListener([Events::onFlush], new FlushExampleListener());
</code>```

https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/events.html#listening-and-subscribing-to-lifecycle-events

Then I have the example class to: (this class never get logged or fired or dumped)

```<code>use Doctrine\ORM\Event\OnFlushEventArgs;

class FlushExampleListener
{
    /**
     * @param OnFlushEventArgs $eventArgs
     * @return void
     */
    public function onFlush(OnFlushEventArgs $eventArgs): void
    {
        $em = $eventArgs->getObjectManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            dd($entity);
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            dd($entity);
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            dd($entity);
        }

        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            dd($col);
        }

        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            dd($col);
        }
    }
}
</code>```

https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/events.html#reference-events-on-flush

Then I post a form with the WebTestCase like this:

```<code>public function iSubmitAFormOnPageValue(string $url, string $btn): void
{
    $crawler = self::$client->request('GET', $this->getHost() . $url, [], [], []);

    $form = $crawler->selectButton($btn)->form();

    $this->crawler = self::$client->submit($form, $this->formData);
    $this->response = self::$client->getResponse();
}
</code>```

What works fine and in this case if I hit the /entity/new route it works. I see a new record in the database. Also can I see with a new GET request that indeed the webpage is updated. Only does the onFlush event not get fired? So how can I see what get inserted into the database from the WebCaseTest or does symfony use another doctrine manager to insert stuff into the database where I need to put the event listener on?

Body:
So Im trying to hook into the database events of doctrine from the WebTestCase of Symfony.

I setup the client like this:

self::$client = static::createClient();
self::$client->followRedirects(true);
self::$client->setMaxRedirects(10);

$doctrineDefaultManager = self::getContainer()->get('doctrine.orm.default_entity_manager');
$doctrineDefaultManager->getConnection()->getConfiguration()->getSQLLogger();

/** some other code loading database and fixtures etc **/

// Im adding the event listener to the defaultmanager here
$doctrineDefaultManager->getEventManager()->addEventListener([Events::onFlush], new FlushExampleListener());

https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/events.html#listening-and-subscribing-to-lifecycle-events

Then I have the example class to: (this class never get logged or fired or dumped)

use Doctrine\ORM\Event\OnFlushEventArgs;

class FlushExampleListener
{
    /**
     * @param OnFlushEventArgs $eventArgs
     * @return void
     */
    public function onFlush(OnFlushEventArgs $eventArgs): void
    {
        $em = $eventArgs->getObjectManager();
        $uow = $em->getUnitOfWork();

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            dd($entity);
        }

        foreach ($uow->getScheduledEntityUpdates() as $entity) {
            dd($entity);
        }

        foreach ($uow->getScheduledEntityDeletions() as $entity) {
            dd($entity);
        }

        foreach ($uow->getScheduledCollectionDeletions() as $col) {
            dd($col);
        }

        foreach ($uow->getScheduledCollectionUpdates() as $col) {
            dd($col);
        }
    }
}

https://www.doctrine-project.org/projects/doctrine-orm/en/2.13/reference/events.html#reference-events-on-flush

Then I post a form with the WebTestCase like this:

public function iSubmitAFormOnPageValue(string $url, string $btn): void
{
    $crawler = self::$client->request('GET', $this->getHost() . $url, [], [], []);

    $form = $crawler->selectButton($btn)->form();

    $this->crawler = self::$client->submit($form, $this->formData);
    $this->response = self::$client->getResponse();
}

What works fine and in this case if I hit the /entity/new route it works. I see a new record in the database. Also can I see with a new GET request that indeed the webpage is updated. Only does the onFlush event not get fired? So how can I see what get inserted into the database from the WebCaseTest or does symfony use another doctrine manager to insert stuff into the database where I need to put the event listener on?


问:
3D Curved Text in Flutter
I need to make a widget with a 3d text style in Flutter, but not a regular one, I want it like a text around a tube, curved and it will have x, y, and z, not just rounded around a circle. And the text itself won't be 3d.
I found a picture on the Internet somehow similar to what I want.

Image

Could anyone help me with that?

I've tried, 3d classes in the pub.dev, CustomPainter, TextPainter, and they didn't have all options that I needed.

Title: 3D Curved Text in Flutter


问:
.net 7 BadRequestObjectResult uses CamelCase Policy
I have configured the JsonSerializerOptions's PropertyNamingPolicy as null, OData all results gets as expected, but BadRequestObjectResult is still using camelcase policy.

```<code>builder.Services.AddControllers()
     .AddJsonOptions(options => {

            options.JsonSerializerOptions.PropertyNamingPolicy = null; // to don't change property names lowercase
            options.JsonSerializerOptions.DictionaryKeyPolicy = null;
    })
</code>```
```<code>protected ActionResult ValidationFailed()
    {
        var err = new ODataError
        {
            Message = "Validation error",
            Details = ModelState.ToDictionary(
                kvp => kvp.Key, //.ToCamelCase(),
                kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()
            ).Select(e => new ODataErrorDetail() {
                ErrorCode = e.Key,
                Message = string.Join("\n", e.Value.ToArray())
            }).ToList()
        };

        return new BadRequestObjectResult(err);
    }
</code>```
```<code>{
    "error": {
        "code": "",
        "message": "Validation error",
        "details": [
            {
                "code": "person.corpid",
                "message": "Corpid field must be value"
            }
        ]
    }
}
</code>```

I want to get all results without changed like following.

```<code>{
    "Error": {
        "Code": "",
        "Message": "Validation error",
        "Details": [
            {
                "Code": "Person.Corpid",
                "Message": "Corpid field must be value"
            }
        ]
    }
}
</code>```

Body:
I have configured the JsonSerializerOptions's PropertyNamingPolicy as null, OData all results gets as expected, but BadRequestObjectResult is still using camelcase policy.

builder.Services.AddControllers()
     .AddJsonOptions(options => {

            options.JsonSerializerOptions.PropertyNamingPolicy = null; // to don't change property names lowercase
            options.JsonSerializerOptions.DictionaryKeyPolicy = null;
    })

protected ActionResult ValidationFailed()
    {
        var err = new ODataError
        {
            Message = "Validation error",
            Details = ModelState.ToDictionary(
                kvp => kvp.Key, //.ToCamelCase(),
                kvp => kvp.Value.Errors.Select(e => e.ErrorMessage).ToArray()
            ).Select(e => new ODataErrorDetail() {
                ErrorCode = e.Key,
                Message = string.Join("\n", e.Value.ToArray())
            }).ToList()
        };

        return new BadRequestObjectResult(err);
    }

{
    "error": {
        "code": "",
        "message": "Validation error",
        "details": [
            {
                "code": "person.corpid",
                "message": "Corpid field must be value"
            }
        ]
    }
}

I want to get all results without changed like following.

{
    "Error": {
        "Code": "",
        "Message": "Validation error",
        "Details": [
            {
                "Code": "Person.Corpid",
                "Message": "Corpid field must be value"
            }
        ]
    }
}


问:
What is the difference between new and old type library (TLB) format?
I just cannot find any explanation about the difference between new TLB file format and old TLB file format. This option is available for Visual Studio C++ projects, under Midl compiler options.

In the project file (.vcxproj), the option looks like this:

```<code><Midl>
  <TypeLibFormat>OldFormat</TypeLibFormat>
</Midl>
</code>```

Does anyone know the difference between new TLB file format and old TLB file format, and any possible collateral effects of changing to the new file format (e.g. COM issues, old VB6 projects requiring old format, etc)?

Body:
I just cannot find any explanation about the difference between new TLB file format and old TLB file format. This option is available for Visual Studio C++ projects, under Midl compiler options.

In the project file (.vcxproj), the option looks like this:

<Midl>
  <TypeLibFormat>OldFormat</TypeLibFormat>
</Midl>

Does anyone know the difference between new TLB file format and old TLB file format, and any possible collateral effects of changing to the new file format (e.g. COM issues, old VB6 projects requiring old format, etc)?


问:
Cannot reference to an external assembly in KAXAML
I am absolutely new to WPF and trying to create some sample UIs in KAXAML. I need to have some emojis in the buttons therefore, I installed the emoji.wpf nuget package. By doing that, I am able to reference the emoji.wpf assembly in a Visual Studio project but if I try to refence the same assembly in a KAXAML file, it does not work.

As per this SO answer's suggestion, I have already copied the emoji.wpf.dll into the KAXAML folder (C:\Program Files (x86)\Kaxaml)

My Sample Code:

```<code><Page
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf">

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition/>
  </Grid.RowDefinitions>

  <Button Grid.Row="0">
    <StackPanel Orientation="Horizontal">
      <emoji:TextBlock Text=""/>
      <Label>MyLabel</Label>
    </StackPanel>
  </Button>

</Grid>
</Page>
</code>```

Error in KAXAML
'Cannot create unknown type '{clr-namespace:Emoji.Wpf;assembly=emoji.Wpf}TextBlock'.'

Body:
I am absolutely new to WPF and trying to create some sample UIs in KAXAML. I need to have some emojis in the buttons therefore, I installed the emoji.wpf nuget package. By doing that, I am able to reference the emoji.wpf assembly in a Visual Studio project but if I try to refence the same assembly in a KAXAML file, it does not work.

As per this SO answer's suggestion, I have already copied the emoji.wpf.dll into the KAXAML folder (C:\Program Files (x86)\Kaxaml)

My Sample Code:

<Page
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf">

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto"/>
    <RowDefinition/>
  </Grid.RowDefinitions>

  <Button Grid.Row="0">
    <StackPanel Orientation="Horizontal">
      <emoji:TextBlock Text=""/>
      MyLabel
    </StackPanel>
  </Button>

</Grid>
</Page>

Error in KAXAML
'Cannot create unknown type '{clr-namespace:Emoji.Wpf;assembly=emoji.Wpf}TextBlock'.'


问:
How to make the ERPNext auto clicked the button in client side?
How to auto clicked once on the Generate Payables when there is a value in Sales Agent Name?

Generate Payables


问:
clang-format indents X macros
I'm using c-style X macros to create two way enums like this:

```<code>namespace ns
{
#define CFG_INT_TABLE                                                          \
    X(CFG_1, "cfg_1", invalid_int_value),                                      \
    X(CFG_2, "cfg_2", invalid_int_value),                                      \
    X(CFG_3, "cfg_3", 10)

#define X(a,b,c) a
    enum class IntegerConfigs : int
    {
        CFG_INT_TABLE,
        TOTAL_ELEMENTS
    }
#undef X

#define X(a,b,c) b
   array ...
#undef X
    [...]
}
</code>```

however when running clang-format, It indents the lines like this:

```<code>#define CFG_INT_TABLE                                                           \
    X(CFG_1, "cfg_1", invalid_int_value),                                       \
        X(CFG_2, "cfg_2", invalid_int_value),                                   \
        X(CFG_3, "cfg_3", 10)
</code>```

I couldn't understand from clang-format's options how to indent the code properly, I prefer a fix that only changes .clang-format file and not the code itself if possible.

this is my .clang-format file:

```<code>BasedOnStyle: GNU
AccessModifierOffset: -2
ColumnLimit: 100
IndentWidth: 4
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
FixNamespaceComments: true
SpaceBeforeParens: ControlStatements
AllowShortFunctionsOnASingleLine: Empty
NamespaceIndentation: All
BreakConstructorInitializers: AfterColon
ReferenceAlignment: Left
BreakBeforeBraces: Custom
Standard: c++20
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
  AfterClass: true
  AfterControlStatement: false
  AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false
</code>```

Thank you!

Title: clang-format indents X macros

Body:
I'm using c-style X macros to create two way enums like this:

namespace ns
{
#define CFG_INT_TABLE                                                          \
    X(CFG_1, "cfg_1", invalid_int_value),                                      \
    X(CFG_2, "cfg_2", invalid_int_value),                                      \
    X(CFG_3, "cfg_3", 10)

#define X(a,b,c) a
    enum class IntegerConfigs : int
    {
        CFG_INT_TABLE,
        TOTAL_ELEMENTS
    }
#undef X

#define X(a,b,c) b
   array ...
#undef X
    [...]
}

however when running clang-format, It indents the lines like this:

#define CFG_INT_TABLE                                                           \
    X(CFG_1, "cfg_1", invalid_int_value),                                       \
        X(CFG_2, "cfg_2", invalid_int_value),                                   \
        X(CFG_3, "cfg_3", 10)

I couldn't understand from clang-format's options how to indent the code properly, I prefer a fix that only changes .clang-format file and not the code itself if possible.

this is my .clang-format file:

BasedOnStyle: GNU
AccessModifierOffset: -2
ColumnLimit: 100
IndentWidth: 4
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
FixNamespaceComments: true
SpaceBeforeParens: ControlStatements
AllowShortFunctionsOnASingleLine: Empty
NamespaceIndentation: All
BreakConstructorInitializers: AfterColon
ReferenceAlignment: Left
BreakBeforeBraces: Custom
Standard: c++20
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
  AfterClass: true
  AfterControlStatement: false
  AfterEnum: true
  AfterFunction: true
  AfterNamespace: true
  AfterStruct: true
  AfterUnion: true
  BeforeCatch: false
  BeforeElse: false
  IndentBraces: false

Thank you!


问:
purchasing consumable item using flutter_inapp_purchase?
I am trying to make an in app purchase function,
and I faced this error: "you already own this item".
I found out that this is because the store considers the item as non-consumable item.

Unlike in_app_purchase package, this package doesn't support buyConsumable and buyNonConsumable functions.

so how to execute purchasing consumable item using that package?

also I assume that this is because of what's said above
items that are purchased keep being refunded automatically.

anyway my code is based on their example code but there it is:

storeController.dart

```<code>
late StreamSubscription purchaseUpdatedSubscription;
late StreamSubscription purchaseErrorSubscription;
late StreamSubscription connectionSubscription;
// just followed the example
final List<String> productLists = Platform.isAndroid
    ? [
  'point1',
  'point2',
  'point3',
]
    : [
      'point1',
  'point2',
  'point3'
];

String platformVersion = Platform.operatingSystem;
RxList<IAPItem> itemsList = <IAPItem>[].obs;
RxList<PurchasedItem> purchasesList = <PurchasedItem>[].obs;
@override
void onInit() async {
  init();
  await initPlatformState();
  await getProduct();
  await getPurchaseHistory();
}

Future<void> initPlatformState() async {

  // Platform messages may fail, so we use a try/catch PlatformException.

  // prepare
  var result = await FlutterInappPurchase.instance.initialize();
  print('result: $result');

  // refresh items for android
  try {
    String msg = await FlutterInappPurchase.instance.consumeAll();
    print('consumeAllItems: $msg');
  } catch (err) {
    print('consumeAllItems error: $err');
  }

  connectionSubscription =
      FlutterInappPurchase.connectionUpdated.listen((connected) async {
        print('connected: $connected');
      });

  purchaseUpdatedSubscription =
      FlutterInappPurchase.purchaseUpdated.listen((productItem) async {
        print('purchase-updated: $productItem');
        await getPurchaseHistory();
      });

  purchaseErrorSubscription =
      FlutterInappPurchase.purchaseError.listen((purchaseError)async {
        print('purchase-error: $purchaseError');
      });
}

Future getProduct() async {
  List<IAPItem> items =
  await FlutterInappPurchase.instance.getProducts(productLists);
  for (var item in items) {
    print('${item.toString()}');
    itemsList.add(item);
  }
}

Future getPurchaseHistory() async {
  List<PurchasedItem>? items =
  await FlutterInappPurchase.instance.getPurchaseHistory();
  for (var item in items!) {
    print('${item.toString()}');
    purchasesList.add(item);
  }
}
</code>```

and the productListWidget:

```<code>Widget productList(context) {
  return GridView.builder(
      shrinkWrap: true,
      itemCount: controller.itemsList.length,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
        mainAxisExtent: Get.width * 0.4 + 70,
      ),
      itemBuilder: (BuildContext context, int index) {
      final item = controller.itemsList[index];
        return
          Container(
              width: Get.width * 0.5,
              alignment: Alignment.center,
              color: Colors.transparent,
              margin: const EdgeInsets.fromLTRB(10,0,10,0),
              child: Stack(
                  children: [
                    Container(
                      color: const Color(0xff353535),
                      child:  Column(
                          children: [
                            const SizedBox(height: 10),
                            const Text('Name', style: TextStyle(color: Colors.white)),
                            Text(
                              item.title ?? '',
                              style: const TextStyle(
                                color: Colors.white,
                                fontSize: 15,
                                fontWeight: FontWeight.w600,
                                fontStyle: FontStyle.normal,
                              ),
                              textAlign: TextAlign.center,
                            ),
                            const SizedBox(height: 10),
                            const Text('Desc', style: TextStyle(color: Colors.white)),
                            Text(
                              item.description ?? '',
                              style: const TextStyle(
                                color: Colors.grey,
                                fontSize: 13,
                                fontStyle: FontStyle.normal,
                              ),
                              textAlign: TextAlign.center,
                            ),
                            const SizedBox(height: 10),
                            const Text('Price', style: TextStyle(color: Colors.white)),
                            Text(
                                '${item.currency ?? ''} ${item.originalPrice}',
                                style: const TextStyle(
                                    color: Colors.white,
                                    fontSize: 12,
                                    fontStyle: FontStyle.normal,
                                    overflow: TextOverflow.ellipsis
                                )
                            ),
                            const SizedBox(height: 10),
                            GestureDetector(
                              onTap: () async {
                                controller.requestPurchase(item);
                              },
                              child: Container(
                                alignment: Alignment.center,
                                width: 100,
                                height: 30,
                                color: const Color(0xffE1FD2E),
                                child: const Text('Purchase')
                              )
                            )
                          ]
                      ),
                    ),

                  ]
              )
          );
      }
  );
}
</code>```

Body:
I am trying to make an in app purchase function,
and I faced this error: "you already own this item".
I found out that this is because the store considers the item as non-consumable item.

Unlike in_app_purchase package, this package doesn't support buyConsumable and buyNonConsumable functions.

so how to execute purchasing consumable item using that package?

also I assume that this is because of what's said above
items that are purchased keep being refunded automatically.

anyway my code is based on their example code but there it is:

storeController.dart

late StreamSubscription purchaseUpdatedSubscription;
late StreamSubscription purchaseErrorSubscription;
late StreamSubscription connectionSubscription;
// just followed the example
final List<String> productLists = Platform.isAndroid
    ? [
  'point1',
  'point2',
  'point3',
]
    : [
      'point1',
  'point2',
  'point3'
];

String platformVersion = Platform.operatingSystem;
RxList<IAPItem> itemsList = <IAPItem>[].obs;
RxList<PurchasedItem> purchasesList = <PurchasedItem>[].obs;
@override
void onInit() async {
  init();
  await initPlatformState();
  await getProduct();
  await getPurchaseHistory();
}

Future<void> initPlatformState() async {

  // Platform messages may fail, so we use a try/catch PlatformException.

  // prepare
  var result = await FlutterInappPurchase.instance.initialize();
  print('result: $result');

  // refresh items for android
  try {
    String msg = await FlutterInappPurchase.instance.consumeAll();
    print('consumeAllItems: $msg');
  } catch (err) {
    print('consumeAllItems error: $err');
  }

  connectionSubscription =
      FlutterInappPurchase.connectionUpdated.listen((connected) async {
        print('connected: $connected');
      });

  purchaseUpdatedSubscription =
      FlutterInappPurchase.purchaseUpdated.listen((productItem) async {
        print('purchase-updated: $productItem');
        await getPurchaseHistory();
      });

  purchaseErrorSubscription =
      FlutterInappPurchase.purchaseError.listen((purchaseError)async {
        print('purchase-error: $purchaseError');
      });
}

Future getProduct() async {
  List<IAPItem> items =
  await FlutterInappPurchase.instance.getProducts(productLists);
  for (var item in items) {
    print('${item.toString()}');
    itemsList.add(item);
  }
}

Future getPurchaseHistory() async {
  List<PurchasedItem>? items =
  await FlutterInappPurchase.instance.getPurchaseHistory();
  for (var item in items!) {
    print('${item.toString()}');
    purchasesList.add(item);
  }
}

and the productListWidget:

Widget productList(context) {
  return GridView.builder(
      shrinkWrap: true,
      itemCount: controller.itemsList.length,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
        mainAxisSpacing: 10,
        crossAxisSpacing: 10,
        mainAxisExtent: Get.width * 0.4 + 70,
      ),
      itemBuilder: (BuildContext context, int index) {
      final item = controller.itemsList[index];
        return
          Container(
              width: Get.width * 0.5,
              alignment: Alignment.center,
              color: Colors.transparent,
              margin: const EdgeInsets.fromLTRB(10,0,10,0),
              child: Stack(
                  children: [
                    Container(
                      color: const Color(0xff353535),
                      child:  Column(
                          children: [
                            const SizedBox(height: 10),
                            const Text('Name', style: TextStyle(color: Colors.white)),
                            Text(
                              item.title ?? '',
                              style: const TextStyle(
                                color: Colors.white,
                                fontSize: 15,
                                fontWeight: FontWeight.w600,
                                fontStyle: FontStyle.normal,
                              ),
                              textAlign: TextAlign.center,
                            ),
                            const SizedBox(height: 10),
                            const Text('Desc', style: TextStyle(color: Colors.white)),
                            Text(
                              item.description ?? '',
                              style: const TextStyle(
                                color: Colors.grey,
                                fontSize: 13,
                                fontStyle: FontStyle.normal,
                              ),
                              textAlign: TextAlign.center,
                            ),
                            const SizedBox(height: 10),
                            const Text('Price', style: TextStyle(color: Colors.white)),
                            Text(
                                '${item.currency ?? ''} ${item.originalPrice}',
                                style: const TextStyle(
                                    color: Colors.white,
                                    fontSize: 12,
                                    fontStyle: FontStyle.normal,
                                    overflow: TextOverflow.ellipsis
                                )
                            ),
                            const SizedBox(height: 10),
                            GestureDetector(
                              onTap: () async {
                                controller.requestPurchase(item);
                              },
                              child: Container(
                                alignment: Alignment.center,
                                width: 100,
                                height: 30,
                                color: const Color(0xffE1FD2E),
                                child: const Text('Purchase')
                              )
                            )
                          ]
                      ),
                    ),

                  ]
              )
          );
      }
  );
}


问:
Android ContentResolver how to specify the sort order?
I am trying to sort alphabetically mp3 files in correct order but no success.
I tried using different sort order and it doesn't work.

```<code>List<Uri> listUriSub = new ArrayList<>();
ContentResolver contentResolver = mContext.getContentResolver();
Timber.tag("SUB_FOLDER_NODE").e(" %s", rootUri.getPath());
String sortOrder = DocumentsContract.Document.COLUMN_DISPLAY_NAME + " DESC";
String sortOrder2 = DocumentsContract.Document.COLUMN_DISPLAY_NAME + " COLLATE NOCASE ASC";
Cursor c = contentResolver.query(rootUri, new String[]{
                DocumentsContract.Document.COLUMN_DOCUMENT_ID,
                DocumentsContract.Document.COLUMN_DISPLAY_NAME,
                DocumentsContract.Document.COLUMN_MIME_TYPE},
        null, null, sortOrder2);
try {
    while (c.moveToNext()) {
        final String docId = c.getString(0);
        final String name = c.getString(1);
        final String mime = c.getString(2);
        // Timber.tag("SCAN_FILE_ID").e( "docId: " + docId + ", name: " + name + ", mime: " + mime);
        Timber.tag("FILE_ORDER_NAME").e(name);
        //IS DIRECTORY
        if (isDirectory(mime)) {
            final Uri newNode = DocumentsContract.buildChildDocumentsUriUsingTree(rootUri, docId);
            // Timber.tag("FOLDER: ").e(name);
        }
        //IS FILE
        else {
            Timber.tag("FILE: ").e(name);
            if (name.contains(".mp3") || name.contains(".MP3")) {
                final Uri newNode = DocumentsContract.buildChildDocumentsUriUsingTree(rootUri, docId);
                listUriSub.add(newNode);

            }
        }
    }
}
</code>```

Exampe OTPUT 1

```<code>02a_WP_Druzyna_Pierscienia_Prolog_O_fajkowym_zielu.mp3
01a_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
01b_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
</code>```

Should be

```<code>01a_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
01b_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
02a_WP_Druzyna_Pierscienia_Prolog_O_fajkowym_zielu.mp3
</code>```

Exampe OTPUT

```<code>02_metro_2035.mp3
05_metro_2035.mp3
03_metro_2035.mp3
04_metro_2035.mp3
01_metro_2035.mp3
</code>```

Should be

```<code>01_metro_2035.mp3
02_metro_2035.mp3
03_metro_2035.mp3
04_metro_2035.mp3
05_metro_2035.mp3
</code>```

The problem could be "_" in title or numbers ?

Body:
I am trying to sort alphabetically mp3 files in correct order but no success.
I tried using different sort order and it doesn't work.

List<Uri> listUriSub = new ArrayList<>();
ContentResolver contentResolver = mContext.getContentResolver();
Timber.tag("SUB_FOLDER_NODE").e(" %s", rootUri.getPath());
String sortOrder = DocumentsContract.Document.COLUMN_DISPLAY_NAME + " DESC";
String sortOrder2 = DocumentsContract.Document.COLUMN_DISPLAY_NAME + " COLLATE NOCASE ASC";
Cursor c = contentResolver.query(rootUri, new String[]{
                DocumentsContract.Document.COLUMN_DOCUMENT_ID,
                DocumentsContract.Document.COLUMN_DISPLAY_NAME,
                DocumentsContract.Document.COLUMN_MIME_TYPE},
        null, null, sortOrder2);
try {
    while (c.moveToNext()) {
        final String docId = c.getString(0);
        final String name = c.getString(1);
        final String mime = c.getString(2);
        // Timber.tag("SCAN_FILE_ID").e( "docId: " + docId + ", name: " + name + ", mime: " + mime);
        Timber.tag("FILE_ORDER_NAME").e(name);
        //IS DIRECTORY
        if (isDirectory(mime)) {
            final Uri newNode = DocumentsContract.buildChildDocumentsUriUsingTree(rootUri, docId);
            // Timber.tag("FOLDER: ").e(name);
        }
        //IS FILE
        else {
            Timber.tag("FILE: ").e(name);
            if (name.contains(".mp3") || name.contains(".MP3")) {
                final Uri newNode = DocumentsContract.buildChildDocumentsUriUsingTree(rootUri, docId);
                listUriSub.add(newNode);

            }
        }
    }
}

Exampe OTPUT 1

02a_WP_Druzyna_Pierscienia_Prolog_O_fajkowym_zielu.mp3
01a_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
01b_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3

Should be

01a_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
01b_WP_Druzyna_Pierscienia_Prolog_W_sprawie_hobbitow.mp3
02a_WP_Druzyna_Pierscienia_Prolog_O_fajkowym_zielu.mp3

Exampe OTPUT

02_metro_2035.mp3
05_metro_2035.mp3
03_metro_2035.mp3
04_metro_2035.mp3
01_metro_2035.mp3

Should be

01_metro_2035.mp3
02_metro_2035.mp3
03_metro_2035.mp3
04_metro_2035.mp3
05_metro_2035.mp3

The problem could be "_" in title or numbers ?


问:
Adding scripts in react + server side rendered app
I am trying to follow this integration for Experian QAS service: https://github.com/experianplc/Experian-Address-Validation

It's not really designed for React, so I am trying to find a way to integrate it.
So far, I have downloaded the script file 'experian-address-validation.js' and I have tried to run it by few methods:

Using react-helmet and simply adding

Using  component

Creating a script element, adding .src property to it and then appending it to the body

None of these methods work. Also, when looking over 'Sources' tab, I can not find the JS script file, as if it does not exist.


问:
imgui-sfml on cmake clion projest
I linked SFML and imgui, and I get no errors, but when I run I get errors like

undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'

This is my cmake:

```<code>cmake_minimum_required(VERSION 3.22)
project(ImGuiT)

set(CMAKE_CXX_STANDARD 20)

add_executable(ImGuiT main.cpp
        imgui/imgui_widgets.cpp
        imgui/imgui.cpp
        imgui/imgui-SFML.cpp
        imgui/imgui_draw.cpp
        imgui/imgui_tables.cpp
        imgui/imconfig.h
        imgui/imstb_rectpack.h
        imgui/imstb_textedit.h
        imgui/imstb_truetype.h
        imgui/imconfig-SFML.h
        imgui/imgui-SFML.h
        imgui/imgui-SFML_export.h
        imgui/imgui_internal.h
        imgui/imgui.h)

include_directories(headers /usr/include c:/SFML/include imgui)

set(SFML_ROOT c:/SFML)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(ImGuiT ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()

file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})

# Copy dlls to build
if(WIN32)
    file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
    file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
    file(GLOB MINGW_DEP_DLLS "C:/mingw64/bin/*.dll")
    file(COPY ${MINGW_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif()
</code>```

I use sfml that I linked from drive and imgui files are in folder in project.
I guess the imgui-sfml can't see sfml, but I linked that, so I don't know how to link it properly
I also added

```<code>#include "imconfig-SFML.h"
</code>```

to the imconfig.h for imgui to see sfml extension

And this is just a simple test main that I can't run:

```<code>#include "imgui.h"
#include "imgui-SFML.h"

#include "SFML/Graphics.hpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 800), "Window Title");
    ImGui::SFML::Init(window);

    bool circleExists = true;
    float circleRadius = 200.0f;
    int circleSegments = 100;
    float circleColor[3] = { (float)204 / 255, (float)77 / 255, (float)5 / 255 };
    sf::CircleShape shape(circleRadius, circleSegments);
    shape.setFillColor(sf::Color
                               (
                                       (int)(circleColor[0] * 255),
                                       (int)(circleColor[1] * 255),
                                       (int)(circleColor[2] * 255)
                               )); // Color circle
    shape.setOrigin(circleRadius, circleRadius);
    shape.setPosition(400, 400); // Center circle

    sf::Clock deltaClock;
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            ImGui::SFML::ProcessEvent(event);
            if (event.type == sf::Event::Closed)
                window.close();
        }
        ImGui::SFML::Update(window, deltaClock.restart());

        ImGui::Begin("Window title");
        ImGui::Text("Window text!");
        ImGui::Checkbox("Circle", &circleExists);
        ImGui::SliderFloat("Radius", &circleRadius, 100.0f, 300.0f);
        ImGui::SliderInt("Sides", &circleSegments, 3, 150);
        ImGui::ColorEdit3("Color Circle", circleColor);
        ImGui::End();

        shape.setRadius(circleRadius);
        shape.setOrigin(circleRadius, circleRadius);
        shape.setPointCount(circleSegments);
        shape.setFillColor(sf::Color
                                   (
                                           (int)(circleColor[0] * 255),
                                           (int)(circleColor[1] * 255),
                                           (int)(circleColor[2] * 255)
                                   )); // Color circle

        window.clear(sf::Color(18, 33, 43)); // Color background
        if (circleExists)
            window.draw(shape);
        ImGui::SFML::Render(window);
        window.display();
    }

    ImGui::SFML::Shutdown();
    return 0;
}
</code>```

Title: imgui-sfml on cmake clion projest

Body:
I linked SFML and imgui, and I get no errors, but when I run I get errors like

undefined reference to `__imp__ZN2sf6StringC1EPKcRKSt6locale'

This is my cmake:

cmake_minimum_required(VERSION 3.22)
project(ImGuiT)

set(CMAKE_CXX_STANDARD 20)

add_executable(ImGuiT main.cpp
        imgui/imgui_widgets.cpp
        imgui/imgui.cpp
        imgui/imgui-SFML.cpp
        imgui/imgui_draw.cpp
        imgui/imgui_tables.cpp
        imgui/imconfig.h
        imgui/imstb_rectpack.h
        imgui/imstb_textedit.h
        imgui/imstb_truetype.h
        imgui/imconfig-SFML.h
        imgui/imgui-SFML.h
        imgui/imgui-SFML_export.h
        imgui/imgui_internal.h
        imgui/imgui.h)

include_directories(headers /usr/include c:/SFML/include imgui)

set(SFML_ROOT c:/SFML)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake_modules")
find_package(SFML REQUIRED system window graphics network audio)
if (SFML_FOUND)
    include_directories(${SFML_INCLUDE_DIR})
    target_link_libraries(ImGuiT ${SFML_LIBRARIES} ${SFML_DEPENDENCIES})
endif()

file(COPY assets DESTINATION ${CMAKE_BINARY_DIR})

# Copy dlls to build
if(WIN32)
    file(GLOB BINARY_DEP_DLLS "${SFML_INCLUDE_DIR}/../bin/*.dll")
    file(COPY ${BINARY_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
    file(GLOB MINGW_DEP_DLLS "C:/mingw64/bin/*.dll")
    file(COPY ${MINGW_DEP_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
endif()

I use sfml that I linked from drive and imgui files are in folder in project.
I guess the imgui-sfml can't see sfml, but I linked that, so I don't know how to link it properly
I also added

#include "imconfig-SFML.h"

to the imconfig.h for imgui to see sfml extension

And this is just a simple test main that I can't run:

#include "imgui.h"
#include "imgui-SFML.h"

#include "SFML/Graphics.hpp"

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 800), "Window Title");
    ImGui::SFML::Init(window);

    bool circleExists = true;
    float circleRadius = 200.0f;
    int circleSegments = 100;
    float circleColor[3] = { (float)204 / 255, (float)77 / 255, (float)5 / 255 };
    sf::CircleShape shape(circleRadius, circleSegments);
    shape.setFillColor(sf::Color
                               (
                                       (int)(circleColor[0] * 255),
                                       (int)(circleColor[1] * 255),
                                       (int)(circleColor[2] * 255)
                               )); // Color circle
    shape.setOrigin(circleRadius, circleRadius);
    shape.setPosition(400, 400); // Center circle

    sf::Clock deltaClock;
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            ImGui::SFML::ProcessEvent(event);
            if (event.type == sf::Event::Closed)
                window.close();
        }
        ImGui::SFML::Update(window, deltaClock.restart());

        ImGui::Begin("Window title");
        ImGui::Text("Window text!");
        ImGui::Checkbox("Circle", &circleExists);
        ImGui::SliderFloat("Radius", &circleRadius, 100.0f, 300.0f);
        ImGui::SliderInt("Sides", &circleSegments, 3, 150);
        ImGui::ColorEdit3("Color Circle", circleColor);
        ImGui::End();

        shape.setRadius(circleRadius);
        shape.setOrigin(circleRadius, circleRadius);
        shape.setPointCount(circleSegments);
        shape.setFillColor(sf::Color
                                   (
                                           (int)(circleColor[0] * 255),
                                           (int)(circleColor[1] * 255),
                                           (int)(circleColor[2] * 255)
                                   )); // Color circle

        window.clear(sf::Color(18, 33, 43)); // Color background
        if (circleExists)
            window.draw(shape);
        ImGui::SFML::Render(window);
        window.display();
    }

    ImGui::SFML::Shutdown();
    return 0;
}


问:
Express subroute on subdirectory not reachable
I have an express server on a subdirectory "mydomain.com/express". My express app has 2 routes '/' and '/subroute_a' (see my code below). A wordpress site is hosted on mydomain.com, but also my hostingprovider has an application "Passenger" running, redirecting requests to ports 80/443 to my express app.

mydomain.com/express returns "hello world" as expected. Also on localhost I can reach "localhost:3000/express/subroute_a" as expected, but "mydomain.com/express/subroute_a" seems te be recognized as a subpage of mydomain.com and returns a (wordpress) 404 not found error.

Does anyone know how to make express "subroute_a" reachable on "mydomain.com/express/subroute_a"?

Thanks!
Tim

folder structure:

```<code>/
├─ bin/
│  ├─ www
├─ config.js
</code>```

www:

```<code>#!/usr/bin/env node
const config = require('../config.js');

const express = require('express')
const app = express()

var indexRouter = express.Router();

indexRouter.get('/', function(req, res) {
  res.send('Hello World!');
});

indexRouter.get('/subroute_a', function (req, res) {
  res.send('Hello subroute')
})

app.use(config.baseUrl, indexRouter);

const port = process.env.PORT || 3000;

const server = app.listen(port, () => {
  console.log('Listening', server.address());
});
</code>```

config.js:

```<code>module.exports  = {
    baseUrl: '/express',
}
</code>```

Body:
I have an express server on a subdirectory "mydomain.com/express". My express app has 2 routes '/' and '/subroute_a' (see my code below). A wordpress site is hosted on mydomain.com, but also my hostingprovider has an application "Passenger" running, redirecting requests to ports 80/443 to my express app.

mydomain.com/express returns "hello world" as expected. Also on localhost I can reach "localhost:3000/express/subroute_a" as expected, but "mydomain.com/express/subroute_a" seems te be recognized as a subpage of mydomain.com and returns a (wordpress) 404 not found error.

Does anyone know how to make express "subroute_a" reachable on "mydomain.com/express/subroute_a"?

Thanks!
Tim

folder structure:

/
├─ bin/
│  ├─ www
├─ config.js

www:

#!/usr/bin/env node
const config = require('../config.js');

const express = require('express')
const app = express()

var indexRouter = express.Router();

indexRouter.get('/', function(req, res) {
  res.send('Hello World!');
});

indexRouter.get('/subroute_a', function (req, res) {
  res.send('Hello subroute')
})

app.use(config.baseUrl, indexRouter);

const port = process.env.PORT || 3000;

const server = app.listen(port, () => {
  console.log('Listening', server.address());
});

config.js:

module.exports  = {
    baseUrl: '/express',
}


问:
I am inserting data from user defined table(UDT) into another table but currently if the UDT has duplicate values coming it is also updating them
I want if the duplicate row is coming from UDT it should stop updating them and skip</p>
```<code>MERGE INTO Contact AS T
using @NameChangeSchedulerUDT  AS S
on CAST(T.EMPLOYEENUMBER AS INT) = CAST(S.EMPLOYEENUMBER AS INT)
WHEN MATCHED  THEN
UPDATE SET
T.FirstName = S.FirstName,
T.MiddleName = S.MiddleName,
T.LastName = S.LastName;
</code>```

Body:
I want if the duplicate row is coming from UDT it should stop updating them and skip

MERGE INTO Contact AS T
using @NameChangeSchedulerUDT  AS S
on CAST(T.EMPLOYEENUMBER AS INT) = CAST(S.EMPLOYEENUMBER AS INT)
WHEN MATCHED  THEN
UPDATE SET
T.FirstName = S.FirstName,
T.MiddleName = S.MiddleName,
T.LastName = S.LastName;


问:
Error in mtc.network.validate(network) : Treatment name " C" invalid. Treatment names may only contain letters, digits, and underscore (_)
I want to prepare my data set as "network set up" using mtc,network function in gemtc package. i have labeled five of my treatments as "A", "B" ,"C" "D" and "E" in data frame "data_b_bin" under treatment column. but when I run the following command
network_b_bin<-mtc.network(data.ab = data_b_bin,description = "Bayesian NMA binary data" ) to set data to mtc.network the following error is displayed:-
Error in mtc.network.validate(network) :
Treatment name " C" invalid.
Treatment names may only contain letters, digits, and underscore (_).

I expect the  “mtc.network” function to perform network setup with the previously set “data_b_bin” and to declares it as “network_b_bin”.
I am wondering who can HELP ME.


问:
Strings in C array or Pointer
I've a question regarding strings. As far as I knew, strings in C is are arrays of Characters. Now I've learned that it is in fact just a pointer to the first Character. As far as I know, arrays don't need pointers because the just can be treated as one themself. So what is a strings now?

Thank you!

Research and reading up

Title: Strings in C array or Pointer