Skip to content

Commit

Permalink
Merge pull request #10289 from SidRoberts/fix-10283
Browse files Browse the repository at this point in the history
[2.0.x] Readded Http\Request::hasPut() (#10283)
  • Loading branch information
andresgutierrez committed May 12, 2015
2 parents b0b1cff + 8fc371f commit d6997e2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Fixed segfault when a docblock does not have annotations #10301
- Fixed wrong number of parameters passed when triggering an event in Mvc\Collection
- Now Mvc\Model checks if an attribute has a default value associated in the database and ignores it from the insert/update generated SQL
- Readded Http\Request::hasPut() (#10283)

2.0.1
- Added missing Phalcon\Debug::listenLowSeverity
Expand Down
24 changes: 22 additions & 2 deletions phalcon/http/request.zep
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ class Request implements RequestInterface, InjectionAwareInterface

protected _filter;

protected _putCache;

/**
* Sets the dependency injector
*/
Expand Down Expand Up @@ -118,8 +120,14 @@ class Request implements RequestInterface, InjectionAwareInterface
{
var put;

let put = [];
parse_str(file_get_contents("php://input"), put);
let put = this->_putCache;

if typeof put != "array" {
let put = [];
parse_str(file_get_contents("php://input"), put);

let this->_putCache = put;
}

return this->getHelper(put, name, filters, defaultValue, notAllowEmpty, noRecursive);
}
Expand Down Expand Up @@ -210,6 +218,18 @@ class Request implements RequestInterface, InjectionAwareInterface
return isset _POST[name];
}

/**
* Checks whether the PUT data has certain index
*/
public function hasPut(string! name) -> boolean
{
var put;

let put = this->getPut();

return isset put[name];
}

/**
* Checks whether $_GET superglobal has certain index
*/
Expand Down
5 changes: 5 additions & 0 deletions phalcon/http/requestinterface.zep
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ interface RequestInterface
*/
public function hasPost(string! name) -> boolean;

/**
* Checks whether the PUT data has certain index
*/
public function hasPut(string! name) -> boolean;

/**
* Checks whether $_GET superglobal has certain index
*/
Expand Down

0 comments on commit d6997e2

Please sign in to comment.