Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
8c7ae47e
Commit
8c7ae47e
authored
Jan 28, 2014
by
Alexander Makarov
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2181 from cebe/request-body-default-post-params
removed getPostParam() from Request, body is $_POST by default
parents
df52510f
bc80101b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
49 deletions
+5
-49
CHANGELOG.md
framework/CHANGELOG.md
+1
-2
Request.php
framework/web/Request.php
+4
-47
No files found.
framework/CHANGELOG.md
View file @
8c7ae47e
...
...
@@ -104,7 +104,6 @@ Yii Framework 2 Change Log
-
Enh:
`init`
of advanced application now allows to specify answer for overwriting files via
`init --overwrite=n`
(samdark)
-
Enh: Added
`TableSchema::fullName`
property (qiangxue)
-
Enh: yii
\c
odeception
\T
estCase now supports loading and using fixtures via Yii fixture framework (qiangxue)
-
Enh: Added support to parse json request data to Request::getRestParams() (cebe)
-
Enh: Added ability to get incoming headers (dizews)
-
Enh: Added
`beforeRun()`
and
`afterRun()`
to
`yii\base\Action`
(qiangxue)
-
Enh: Added support for using timeZone with
`yii\base\Formatter`
(dizews)
...
...
@@ -120,7 +119,7 @@ Yii Framework 2 Change Log
-
Chg #1958:
`beforeSubmit`
in
`yii.activeform`
is now executed after validation and before form submission (6pblcb)
-
Chg #2025: Removed ability to declare scopes in ActiveRecord (samdark)
-
Chg #2043: Renamed
`yii\web\Request::acceptedLanguages`
to
`acceptableLanguages`
(qiangxue)
-
Chg #2043: Removed
`yii\web\Request::getPut()`
,
`getDelete()`
,
`getPatch()`
in favor of
`getBodyParam()`
(cebe)
-
Chg #2043: Removed
`yii\web\Request::getP
ost()`
,
`getP
ut()`
,
`getDelete()`
,
`getPatch()`
in favor of
`getBodyParam()`
(cebe)
-
Chg #2043: Renamed
`yii\web\Request::get()`
to
`getQueryParams()`
and
`getRestParams()`
to
`getBodyParams()`
(cebe)
-
Chg #2057: AutoTimestamp attributes defaults changed from
`create_time`
and
`update_time`
to
`created_at`
and
`updated_at`
(creocoder)
-
Chg #2059: Implemented git-flavored file excluding/filtering for
`FileHelper`
(nineinchnick)
...
...
framework/web/Request.php
View file @
8c7ae47e
...
...
@@ -344,6 +344,9 @@ class Request extends \yii\base\Request
throw
new
InvalidConfigException
(
"The fallback request parser is invalid. It must implement the yii
\\
web
\\
RequestParserInterface."
);
}
$this
->
_bodyParams
=
$parser
->
parse
(
$this
->
getRawBody
(),
$contentType
);
}
elseif
(
$this
->
getMethod
()
===
'POST'
)
{
// PHP has already parsed the body so we have all params in $_POST
$this
->
_bodyParams
=
$_POST
;
}
else
{
$this
->
_bodyParams
=
[];
mb_parse_str
(
$this
->
getRawBody
(),
$this
->
_bodyParams
);
...
...
@@ -411,7 +414,6 @@ class Request extends \yii\base\Request
* @param string $name the GET parameter name. If not specified, whole $_GET is returned.
* @param mixed $defaultValue the default parameter value if the GET parameter does not exist.
* @return mixed the GET parameter value
* @see getPostParam()
* @see getBodyParam()
*/
public
function
getQueryParam
(
$name
,
$defaultValue
=
null
)
...
...
@@ -420,51 +422,6 @@ class Request extends \yii\base\Request
return
isset
(
$params
[
$name
])
?
$params
[
$name
]
:
$defaultValue
;
}
private
$_postParams
;
/**
* Returns the POST request parameters.
*
* This method will return the contents of `$_POST` if params where not explicitly set.
* @return array the request POST parameter values.
* @see setPostParams()
* @see getPostParam()
*/
public
function
getPostParams
()
{
if
(
$this
->
_postParams
===
null
)
{
return
$_POST
;
}
return
$this
->
_postParams
;
}
/**
* Sets the request POST parameters.
* @param array $values the request POST parameters (name-value pairs)
* @see getPostParam()
* @see getPostParams()
*/
public
function
setPostParams
(
$values
)
{
$this
->
_postParams
=
$values
;
}
/**
* Returns the named POST parameter value.
* If the POST parameter does not exist, the second parameter to this method will be returned.
* @param string $name the POST parameter name. If not specified, whole $_POST is returned.
* @param mixed $defaultValue the default parameter value if the POST parameter does not exist.
* @property array the POST request parameter values
* @return mixed the POST parameter value
* @see getQueryParam()
* @see getBodyParam() for request method independent body parameters.
*/
public
function
getPostParam
(
$name
,
$defaultValue
=
null
)
{
$params
=
$this
->
getPostParams
();
return
isset
(
$params
[
$name
])
?
$params
[
$name
]
:
$defaultValue
;
}
private
$_hostInfo
;
/**
...
...
@@ -1204,7 +1161,7 @@ class Request extends \yii\base\Request
return
true
;
}
$trueToken
=
$this
->
getCookies
()
->
getValue
(
$this
->
csrfVar
);
$token
=
$
method
===
'POST'
?
$this
->
getPostParam
(
$this
->
csrfVar
)
:
$
this
->
getBodyParam
(
$this
->
csrfVar
);
$token
=
$this
->
getBodyParam
(
$this
->
csrfVar
);
return
$this
->
validateCsrfTokenInternal
(
$token
,
$trueToken
)
||
$this
->
validateCsrfTokenInternal
(
$this
->
getCsrfTokenFromHeader
(),
$trueToken
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment