Bug #39005

Proxies for Http\Request not used

Added by Marco Falkenberg over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Should have
Category:
Http
Start date:
2012-07-16
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:

Description

The proxies for the Http\Request are generated but not used. So you are not able to use AOP for this class. For example try this:

    /**
     * @param \TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint The current joinpoint
     *
     * @FLOW3\Around("method(TYPO3\FLOW3\Http\Request->decodeBodyArguments())")
     * @return mixed Result of the advice chain
     */
    public function transformRequestBody(\TYPO3\FLOW3\Aop\JoinPointInterface $joinPoint) {
        /** code **/
    }

The advices are never called.

The bug is located in the Http\RequestHandler. There the Request is generated through a static constructor method.

Maybe the request should be instantiated by the object manager while resolving the dependencies like the other properties of the request handler.

Like this:

    protected function resolveDependencies() {
        ...
        $this->request = $objectManager->get('TYPO3\FLOW3\Http\Request');
    }

Then you could feed the constructor of the request with a kind of "RequestVariablesLocator" which encapsulates the superglobals. When it's a singleton it get's injected.

Like this:

    public function __construct(\TYPO3\FLOW3\Mvc\RequestVariablesLocator $requestVariableLocator) {
        $server = $requestVariableLocator->getServerVariables();

        $this->headers = Headers::createFromServer($server);
        $this->setMethod(isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET');
        $protocol = (isset($server['SSL_SESSION_ID']) || (isset($server['HTTPS']) && ($server['HTTPS'] === 'on' || strcmp($server['HTTPS'], '1') === 0))) ? 'https' : 'http';
        $this->uri = new Uri($protocol . '://' . (isset($server['HTTP_HOST']) ? $server['HTTP_HOST'] : 'localhost') . str_replace('/index.php', '', (isset($server['REQUEST_URI']) ? $server['REQUEST_URI'] : '/')));
        $this->server = $server;
        $this->arguments = $this->buildUnifiedArguments($requestVariableLocator->getGetVariables(), $requestVariableLocator->getPostVariables(), $requestVariableLocator->getPostVariables());
    }

Related issues

Related to TYPO3.Flow - Task #39121: Encapsulate PHP superglobals for Http\RequestsRejectedMarco Falkenberg2012-07-20

Actions
#1

Updated by Karsten Dambekalns over 9 years ago

  • Status changed from New to Needs Feedback
  • Assignee changed from Christian Müller to Robert Lemke

Robert - I think Http\Request could simply get a Proxy(false) annotation and we live with the fact that this makes AOP on this class impossible. IMHO acceptable.

#2

Updated by Robert Lemke over 9 years ago

Karsten Dambekalns wrote:

Robert - I think Http\Request could simply get a Proxy(false) annotation and we live with the fact that this makes AOP on this class impossible. IMHO acceptable.

yes, correct, just go ahead! I think the same goes for all other classes in the Http namespace.

#3

Updated by Karsten Dambekalns over 9 years ago

  • Status changed from Needs Feedback to Accepted
  • Assignee changed from Robert Lemke to Karsten Dambekalns
  • Target version set to 1.1
#4

Updated by Gerrit Code Review over 9 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/13344

#5

Updated by Karsten Dambekalns over 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
#6

Updated by Gerrit Code Review over 9 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch FLOW3-1.1 has been pushed to the review server.
It is available at http://review.typo3.org/13501

#7

Updated by Karsten Dambekalns over 9 years ago

  • Status changed from Under Review to Resolved

Also available in: Atom PDF