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

Fixed access to Front Office container from modules #8922

Merged
merged 1 commit into from Apr 6, 2018

Conversation

@mickaelandrieu
Copy link
Member

commented Apr 5, 2018

Questions Answers
Branch? 1.7.3.x
Description? We can't rely on ADMIN_LEGACY_CONTEXT constant to ensure we are in Front Office.
Type? bug fix
Category? CO
BC breaks? no
Deprecations? no
How to test? Use this module after a re-installation in 1.7.3.x branch and on this one, accessing the Front Office.

This change is Reviewable

@eternoendless eternoendless added this to the 1.7.3.1 milestone Apr 5, 2018

@mickaelandrieu mickaelandrieu force-pushed the mickaelandrieu:fix-module-get branch from 509b34d to 0ba9581 Apr 5, 2018

@eternoendless

This comment has been minimized.

Copy link
Member

commented Apr 5, 2018

Tested and ok

@mickaelandrieu mickaelandrieu force-pushed the mickaelandrieu:fix-module-get branch from 0ba9581 to f043f84 Apr 5, 2018

@eternoendless

This comment has been minimized.

Copy link
Member

commented Apr 5, 2018

Can you provide a module to verify the PR now? 😁

@mickaelandrieu mickaelandrieu force-pushed the mickaelandrieu:fix-module-get branch from f043f84 to afb5e44 Apr 5, 2018

@mickaelandrieu

This comment has been minimized.

Copy link
Member Author

commented Apr 5, 2018

@eternoendless done but I need an approval (branch rebased) ;)

@marionf marionf added QA ✔️ and removed waiting for QA labels Apr 6, 2018

@eternoendless

This comment has been minimized.

Copy link
Member

commented Apr 6, 2018

Thank you @mickaelandrieu

@eternoendless eternoendless merged commit ef35c59 into PrestaShop:1.7.3.x Apr 6, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@123monsite-regis

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

hi,
we have an issue with this change,
we use on our module on hooks who belong to the BO product page (on prestashop 1.7.3.3)

 public function hookActionProductUpdate($params)
{
  [...]
  $request = $this->get('request');
  [...]
}

the container is not build, so wo got
PHP Fatal error: Call to a member function get() on null in classes/controller/Controller.php line 718

does you have the same comportement ?

@mickaelandrieu mickaelandrieu deleted the mickaelandrieu:fix-module-get branch Jun 26, 2018

@mickaelandrieu

This comment has been minimized.

Copy link
Member Author

commented Jun 26, 2018

@123monsite-regis weird :/ can you provide a quick fix?

This is really difficult to find in which context the hook is executed, we can't wait to have only Symfony BO and FO :/ The container is always built in Migrated pages but the condition in isSymfonyContext doesnt match: one more tricky use case to manage ...

Potential Workaround: to retrieve the request, you can do Request::createFromGlobals();

Second workaround (for your module):

// in your hook
$container = SymfonyContainer::getInstance();

if ($container !== null) {
    $request = $container->get('request');
}
@123monsite-regis

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2018

i have, the awfull
!defined('ADMIN_LEGACY_CONTEXT') && defined('_PS_ADMIN_DIR_')

i try to find where is build the "pseudo old" context controller maybe, we can launch a "buildContainer" on it

@mickaelandrieu

This comment has been minimized.

Copy link
Member Author

commented Jun 26, 2018

feel free to make a patch, I'll try to make it available in 1.7.4 👍

Thanks for you report!

@123monsite-regis

This comment has been minimized.

Copy link
Contributor

commented Jun 27, 2018

thanks for the help and Workarounds ,

$request = $this->get('request'); was just a sample, quite all services may be usefull espacially 'form.factory' to handle data in this case

i create a pull whith the patch, but sorry use case are so various that i does not know how to test alls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.