typo3typo3-9.xtypo3-8.xpibase

TYPO3 8.7/9.5 pibase $_POST not available?


I am reworking some old typo3 project extensions. The problem is we have to stay on that pibase structure as it is supported by core anyway. So that extension does some simple CRUD operations, in my case an insert based on submitted values via $_POST. So the old extension just used $_POST directly which is not supported anymore, I guess since the PSR-7 Request/Response implementation.

But now how can I access the submitted values since $_POST is not available anymore and I do not have $this->request either because the extension extends AbstractPlugin.

edit: also, we are not inside main() the codeblock is within sendMail()

I also have no idea where sendMail gets called from as there is no available documentation for pibase.

Help is much appreciated.


Solution

  • You can access the GET and POST parameters with \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('name')

    But for security reasons that might be filtered away.

    We have the concept of cHashes which secure the site against injected parameters. All parameters must be known and are secured by a hash. TYPO3 remembers the parameter by the cHash. If a cHash is given, the parameters are fetched from the database and parameters given to the server are ignored.

    For forms (like ext:form or ext:powermail) there are no cHashes generated and the fields of the form can be processed.

    If you have 'naked' forms and plain php-files to process, you should change to a form extension where you can use the existing finishers and can add additional finishers (and validators), for these finishers the form data is secured against injection and you do not need to access $_GET or $_POST.

    EDIT:
    Here is a question/answer on how to disable cHash calculation for single form values: TYPO3 - Deactivating cHash in own extension - 8LTS