Prestashop: "Orders > Delivery Slips" page crashing

Created on 11 Feb 2019  路  10Comments  路  Source: PrestaShop/PrestaShop

"Orders > Delivery Slips" page crashing - Error 500

To Reproduce
Steps to reproduce the behavior:
I my system, I just go to 'Orders > Delivery Slips and see the error

Additionnal information
PrestaShop version: 1.7.5.0
PHP version: 7.1.26

Stack Trace:
Symfony\Component\Form\Exception\UnexpectedTypeException:
Expected argument of type "object, array or empty", "string" given
at vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php:41
at Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper->mapDataToForms('#DE', object(RecursiveIteratorIterator))
(vendor/symfony/symfony/src/Symfony/Component/Form/Form.php:379)
at Symfony\Component\Form\Form->setData('#DE')
(vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php:49)
at Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper->mapDataToForms(array('prefix' => '#DE', 'number' => 0, 'enable_product_image' => false), object(RecursiveIteratorIterator))
(vendor/symfony/symfony/src/Symfony/Component/Form/Form.php:379)
at Symfony\Component\Form\Form->setData(array('prefix' => '#DE', 'number' => 0, 'enable_product_image' => false))
(vendor/symfony/symfony/src/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php:49)
at Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper->mapDataToForms(array('options' => array('prefix' => '#DE', 'number' => 0, 'enable_product_image' => false)), object(RecursiveIteratorIterator))
(vendor/symfony/symfony/src/Symfony/Component/Form/Form.php:379)
at Symfony\Component\Form\Form->setData(array('options' => array('prefix' => '#DE', 'number' => 0, 'enable_product_image' => false)))
(vendor/symfony/symfony/src/Symfony/Component/Form/Form.php:483)
at Symfony\Component\Form\Form->initialize()
(vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php:226)
at Symfony\Component\Form\FormBuilder->getForm()
(src/Core/Form/FormHandler.php:114)
at PrestaShop\PrestaShop\Core\Form\FormHandler->getForm()
(src/PrestaShopBundle/Controller/Admin/Sell/Order/DeliveryController.php:57)
at PrestaShopBundle\Controller\Admin\Sell\Order\DeliveryController->slipAction(object(Request))
(vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:151)
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), 1)
(vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php:68)
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), 1, false)
(vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:200)
at Symfony\Component\HttpKernel\Kernel->handle(object(Request), 1, false)
(admcip/index.php:88)

1.7.5.0 BO Bug Delivery slip No change required

Most helpful comment

@khouloudbelguith Here a tutorial to fix this issue

If you have an error 500 on Orders > Delivery Slips with this error

Symfony\Component\Form\Exception\UnexpectedTypeException:
Expected argument of type "object, array or empty", "string" given

Execute this query

SELECT * FROM `ps_configuration_lang` WHERE `id_configuration` = (SELECT `id_configuration` FROM `ps_configuration` WHERE `name` LIKE 'PS_DELIVERY_PREFIX')

If no result, here is the issue.

So you can execute this query to create the language entry in ps_configuration_lang to solve the issue.

INSERT INTO `ps_configuration_lang` (`id_configuration`, `id_lang`, `value`) VALUES
(
    (SELECT `id_configuration` FROM `ps_configuration` WHERE `name` = 'PS_DELIVERY_PREFIX'),
    (SELECT `value` FROM `ps_configuration` WHERE `name` = 'PS_LANG_DEFAULT'),
    (SELECT `value` FROM `ps_configuration` WHERE `name` = 'PS_DELIVERY_PREFIX')
)

Of course you have to check if you use ps_ as table prefix before

All 10 comments

Hi @rblaurin,

Did you make an upgrade?
If yes, could you please try to replace the ps_configuration_lang table and the ps_configuration table in the Database with the one from clean PS1.7.5.0 installation.
Thanks to check & feedback.

Hi @khouloudbelguith
Thanks for the answer.

Yes, I made an upgrade. I can't just replace these full tables in database, are there any specific rows I should delete or modify?

This is due to missing language for PS_DELIVERY_PREFIX configuration key

SELECT * FROM `ps_configuration_lang` WHERE `id_configuration` = (SELECT `id_configuration` FROM `ps_configuration` WHERE `name` LIKE 'PS_DELIVERY_PREFIX')
If this query return any result, here is the issue.

You can make a backup of ps_configuration and delete this key. After that, this page work again and Prestashop can recreate it properly.
DELETE FROM `ps_configuration` WHERE `name` = 'PS_DELIVERY_PREFIX'

When you can access to the page, don't forget to fill the Delivery prefix field with #DE

Thanks @Matt75
Solved!

Just a clarification: There was no return in the query you suggested. The 'PS_DELIVERY_PREFIX' key was only in ps_configuration. I deleted this row and filled the delivery prefix with #DE in BO as you suggested.

Yes this is the problem, when you have only one language.
Prestashop previous version don't create always the line in ps_configuration_lang but the newest version need it...

@khouloudbelguith Here a tutorial to fix this issue

If you have an error 500 on Orders > Delivery Slips with this error

Symfony\Component\Form\Exception\UnexpectedTypeException:
Expected argument of type "object, array or empty", "string" given

Execute this query

SELECT * FROM `ps_configuration_lang` WHERE `id_configuration` = (SELECT `id_configuration` FROM `ps_configuration` WHERE `name` LIKE 'PS_DELIVERY_PREFIX')

If no result, here is the issue.

So you can execute this query to create the language entry in ps_configuration_lang to solve the issue.

INSERT INTO `ps_configuration_lang` (`id_configuration`, `id_lang`, `value`) VALUES
(
    (SELECT `id_configuration` FROM `ps_configuration` WHERE `name` = 'PS_DELIVERY_PREFIX'),
    (SELECT `value` FROM `ps_configuration` WHERE `name` = 'PS_LANG_DEFAULT'),
    (SELECT `value` FROM `ps_configuration` WHERE `name` = 'PS_DELIVERY_PREFIX')
)

Of course you have to check if you use ps_ as table prefix before

@Matt75, thanks a lot for your feedback.
@rblaurin, since it is fixed I close the issue, feel free to open a new one when needed.

ps: I installed fresh PrestaShop 1.7.4.4 French language/ France country, I created a delivery slips => make an upgrade with the 1-click upgrade v4.5.1. => OK => I checked the Orders > Delivery Slips" page & it is OK.
Thanks!

@khouloudbelguith Yes I think the problem come when you make an upgrade from 1.6 or previous with only one language

@rblaurin Before upgrade to 1.7.5 which version did you use ? Did you make others upgrade from previous version before ? With which version did you start on Prestashop ?

@Matt75 Before upgrade to 1.7.5 I was using 1.7.4.4, but I use Prestashop since 2009 (v1.2, I think).
I don't think this is a solved issue. It seems an upgrade bug for me.
I think something like the following code should be added to SQL upgrade scripts for 1.7.5 in 1-click upgrade module:

INSERT INTO `ps_configuration_lang` (`id_configuration`, `id_lang`, `value`) VALUES
(
    SELECT
        `id_configuration`,
        (SELECT `value` FROM `ps_configuration` WHERE `name` = 'PS_LANG_DEFAULT'),
        `value`
    FROM `ps_configuration` c WHERE `name` = 'PS_DELIVERY_PREFIX'
    AND NOT EXISTS (SELECT 1 FROM `ps_configuration_lang` WHERE `id_configuration` = c.`id_configuration`)
)
Was this page helpful?
0 / 5 - 0 ratings