Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix Cannot use object of type ParameterBag as array #15805

Merged
merged 1 commit into from Oct 17, 2019

Conversation

@davidglezz
Copy link
Contributor

davidglezz commented Oct 3, 2019

Questions Answers
Branch? develop
Description? I got an exception when saving a product: Cannot use object of type ParameterBag as array and I have fixed it using ParameterBag "has" method.
Type? bug fix
Category? CO
BC breaks? no
Deprecations? no
Fixed ticket? Fixes #15815
How to test? if it exists, Run this file unit test.
[Tue Oct 01 14:45:05.873957 2019] [php7:error] [pid 15296] [client 172.19.0.2:47756] script '/var/www/html/admin/themes/new-theme/public/index.php' not found or unable to stat, referer: https://myshop.com/admin/index.php/sell/catalog/products/9018?_token=Tl8ItvVRfaL46AdjUjhk5F52XFRuJjsQPfPQPS7X9FY
[Tue Oct 01 14:45:15.704399 2019] [php7:error] [pid 19] [client 172.19.0.2:47768] PHP Fatal error:  Uncaught Symfony\\Component\\Debug\\Exception\\FatalThrowableError: Cannot use object of type Symfony\\Component\\HttpFoundation\\ParameterBag as array in /var/www/html/src/Adapter/Security/Admin.php:91
Stack trace:
#0 /var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php(212): PrestaShop\\PrestaShop\\Adapter\\Security\\Admin->onKernelRequest(Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent), 'kernel.request', Object(Symfony\\Component\\EventDispatcher\\ContainerAwareEventDispatcher))
#1 /var/www/html/vendor/symfony/symfony/src/Symfony/Component/EventDispatcher/EventDispatcher.php(44): Symfony\\Component\\EventDispatcher\\EventDispatcher->doDispatch(Array, 'kernel.request', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#2 /var/www/html/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php(127): Symfony\\Component\\EventDispatcher\\EventDispatcher->dispatch('kernel.request', Object(Symfony\\Component\\HttpKernel\\Event\\GetResponseEvent))
#3 /var/www/h in /var/www/html/src/Adapter/Security/Admin.php on line 91, referer: https://myshop.com/admin/index.php/sell/catalog/products/9018?_token=Tl8ItvVRfaL46AdjUjhk5F52XFRuJjsQPfPQPS7X9FY

This change is Reviewable

@davidglezz davidglezz requested a review from PrestaShop/prestashop-core-developers as a code owner Oct 3, 2019
@matthieu-rolland

This comment has been minimized.

Copy link
Contributor

matthieu-rolland commented Oct 3, 2019

Hi @davidglezz, thank you for your contribution !

Could you please create an issue explaining what you are fixing, and reference the issue in this PR?

@PierreRambaud

This comment has been minimized.

Copy link
Contributor

PierreRambaud commented Oct 4, 2019

The fix is logic. We just need to understand how it can happened 😅

@sarahdib

This comment has been minimized.

Copy link

sarahdib commented Oct 16, 2019

Hello @davidglezz

Can you provide us the steps to reproduce the issue and check that the PR is ok.

Thank you for your contribution

@davidglezz

This comment has been minimized.

Copy link
Contributor Author

davidglezz commented Oct 17, 2019

I think it is difficult to reproduce. And I'm sorry, I'm not going to try.
I simply saw an exception with a logical and well-documented error. I think this problem does not require reproduction, the code itself proves it.

I will tell you what I did and my conclusions:

I modified a module that called a function that did not exist because the name was misspelled.

This function was called from the "updateProduct" or similar hook of the module.

The exception occurred when I save a product, this process is done through ajax. The server returned error 500 and a blank page (regardless of the status of the debug option)

It took me a long time to find the problem because I didn't saw anything in the php error log about calling a function that didn't exist. Only the trace shown at the beginning of the issue/pr.

Being totally inexperienced, I think the exception handler produced an exception that was the only one it showed.

After applying this fix, the exception no longer was throw.

Finally, this would be another issue in my opinion, I never understood why this error appeared ... var/www/html/admin/themes/new-theme/public/index.php' not found or unable to stat. . Are you trying to open index.php somewhere in prestashop? I solved it by creating index.php.

@marionf

This comment has been minimized.

Copy link
Contributor

marionf commented Oct 17, 2019

@PierreRambaud @davidglezz
Do you see any non-regressions tests to be done by the QA ?
What could it break ?
Otherwise if there is nothing functional to test, we can go without QA

@PierreRambaud

This comment has been minimized.

Copy link
Contributor

PierreRambaud commented Oct 17, 2019

I don't see any scenario to test this PR.
ping @matks If you have an idea, please! Otherwise, let's merge it as technical PR

@matks

This comment has been minimized.

Copy link
Contributor

matks commented Oct 17, 2019

ping @matks If you have an idea, please! Otherwise, let's merge it as technical PR

Let's do that

@matks
matks approved these changes Oct 17, 2019
@matks matks added this to the 1.7.7.0 milestone Oct 17, 2019
@matks matks removed the waiting for dev label Oct 17, 2019
@matks

This comment has been minimized.

Copy link
Contributor

matks commented Oct 17, 2019

Thank you @davidglezz

@matks matks merged commit 7b85bff into PrestaShop:develop Oct 17, 2019
2 checks passed
2 checks passed
PrettyCI Code formatting
Details
Travis CI - Pull Request Build Passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.