Skip to content

Commit 17dab6a

Browse files
authored
Merge pull request #8160 from kenjis/docs-add-warning-to-getVar
docs: add warning to `getVar()`
2 parents 46ab4c6 + 1149f27 commit 17dab6a

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

user_guide_src/source/incoming/incomingrequest.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ Getting Data
101101

102102
The ``getVar()`` method will pull from ``$_REQUEST``, so will return any data from ``$_GET``, ``$POST``, or ``$_COOKIE`` (depending on php.ini `request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_).
103103

104+
.. warning:: If you want to validate POST data only, don't use ``getVar()``.
105+
Newer values override older values. POST values may be overridden by the
106+
cookies if they have the same name, and you set "C" after "P" in
107+
`request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_.
108+
104109
.. note:: If the incoming request has a ``Content-Type`` header set to ``application/json``,
105110
the ``getVar()`` method returns the JSON data instead of ``$_REQUEST`` data.
106111

user_guide_src/source/libraries/validation.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ For example, data returned by multi select dropdown:
343343
withRequest()
344344
=============
345345

346+
.. warning:: If you want to validate POST data only, don't use ``withRequest()``.
347+
This method uses :ref:`$request->getVar() <incomingrequest-getting-data>`
348+
which returns ``$_GET``, ``$_POST`` or ``$_COOKIE`` data in that order
349+
(depending on php.ini `request-order <https://www.php.net/manual/en/ini.core.php#ini.request-order>`_).
350+
Newer values override older values. POST values may be overridden by the
351+
cookies if they have the same name.
352+
346353
One of the most common times you will use the validation library is when validating
347354
data that was input from an HTTP Request. If desired, you can pass an instance of the
348355
current Request object and it will take all of the input data and set it as the

0 commit comments

Comments
 (0)