Skip to content

Commit

Permalink
Merge pull request #101 from magento-south/MAGETWO-32690
Browse files Browse the repository at this point in the history
[South] MAGETWO-32690: Upgrade the ZF1 controller libraries to a new up to date library
  • Loading branch information
slavvka committed Feb 19, 2015
2 parents e85f2eb + 55fa3a3 commit a9e59f8
Show file tree
Hide file tree
Showing 218 changed files with 2,606 additions and 1,428 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class AjaxMarkAsRead extends \Magento\AdminNotification\Controller\Adminhtml\Not
*/
public function execute()
{
if (!$this->getRequest()->getPost()) {
if (!$this->getRequest()->getPostValue()) {
return;
}
$notificationId = (int)$this->getRequest()->getPost('id');
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Backend/App/AbstractAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,7 @@ public function dispatch(\Magento\Framework\App\RequestInterface $request)
}

if ($request->isDispatched() && $request->getActionName() !== 'denied' && !$this->_isAllowed()) {
$this->_response->setHeader('HTTP/1.1', '403 Forbidden');
$this->_response->setHttpResponseCode(403);
$this->_response->setStatusHeader(403, '1.1', 'Forbidden');
if (!$this->_auth->isLoggedIn()) {
return $this->_redirect('*/auth/login');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function _performLogin(\Magento\Framework\App\RequestInterface $reques
$postLogin = $request->getPost('login');
$username = isset($postLogin['username']) ? $postLogin['username'] : '';
$password = isset($postLogin['password']) ? $postLogin['password'] : '';
$request->setPost('login', null);
$request->setPostValue('login', null);

try {
$this->_auth->login($username, $password);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function aroundDispatch(
if ($key) {
$postData = $request->getPost($key);
$value = is_array($postData) ? $postData : explode(',', $postData);
$request->setPost($key, $value ? $value : null);
$request->setPostValue($key, $value ? $value : null);
}
return $proceed($request);
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Backend/Controller/Adminhtml/Denied.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public function execute()
if (!$this->_auth->isLoggedIn()) {
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setHeader('HTTP/1.1', '403 Forbidden');
$resultRedirect->setStatusHeader(403, '1.1', 'Forbidden');
return $resultRedirect->setPath('*/auth/login');
}
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setHeader('HTTP/1.1', '403 Forbidden');
$resultPage->setStatusHeader(403, '1.1', 'Forbidden');
$resultPage->addHandle('adminhtml_denied');
return $resultPage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
$resultPage->setHeader('HTTP/1.1', '404 Not Found');
$resultPage->setStatusHeader(404, '1.1', 'Forbidden');
$resultPage->setHeader('Status', '404 File not found');
$resultPage->addHandle('adminhtml_noroute');
return $resultPage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function _filterPostData($data)
*/
public function execute()
{
$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function execute()
{
/** @var \Magento\Backend\Model\View\Result\Redirect $redirectResult */
$redirectResult = $this->resultRedirectFactory->create();
if ($this->getRequest()->isPost() && ($postData = $this->getRequest()->getPost())) {
if ($this->getRequest()->isPost() && ($postData = $this->getRequest()->getPostValue())) {
if (empty($postData['store_type']) || empty($postData['store_action'])) {
$redirectResult->setPath('adminhtml/*/');
return $redirectResult;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Captcha/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ public function checkUserCreate($observer)
if (!$captchaModel->isCorrect($this->_getCaptchaString($controller->getRequest(), $formId))) {
$this->messageManager->addError(__('Incorrect CAPTCHA'));
$this->_actionFlag->set('', \Magento\Framework\App\Action\Action::FLAG_NO_DISPATCH, true);
$this->_session->setCustomerFormData($controller->getRequest()->getPost());
$this->_session->setCustomerFormData($controller->getRequest()->getPostValue());
$url = $this->_urlManager->getUrl('*/*/create', ['_nosecret' => true]);
$controller->getResponse()->setRedirect($this->redirect->error($url));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function execute()

$storeId = $this->getRequest()->getParam('store');
$refreshTree = false;
$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
if ($data) {
$category->addData($this->_filterCategoryPostData($data['general']));
if (!$category->getId()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function __construct(
*/
public function execute()
{
$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
$resultRedirect = $this->resultRedirectFactory->create();
if ($data) {
$setId = $this->getRequest()->getParam('set');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function execute()
$productId = $this->getRequest()->getParam('id');
$resultRedirect = $this->resultRedirectFactory->create();

$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
if ($data) {
try {
$product = $this->initializationHelper->initialize($this->productBuilder->build($this->getRequest()));
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/Controller/Product/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ public function execute()
{
$result = null;
if (!$this->_initProduct()) {
if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
$store = $this->getRequest()->getQuery('store');
if (isset($store) && !$this->getResponse()->isRedirect()) {
$result = $this->resultRedirectFactory->create();
$result->setPath('');
} elseif (!$this->getResponse()->isRedirect()) {
Expand Down
3 changes: 2 additions & 1 deletion app/code/Magento/Catalog/Controller/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ public function __construct(
*/
protected function noProductRedirect()
{
if (isset($_GET['store']) && !$this->getResponse()->isRedirect()) {
$store = $this->getRequest()->getQuery('store');
if (isset($store) && !$this->getResponse()->isRedirect()) {
$resultRedirect = $this->resultRedirectFactory->create();
return $resultRedirect->setPath('');
} elseif (!$this->getResponse()->isRedirect()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ class Save extends \Magento\CatalogRule\Controller\Adminhtml\Promo\Catalog
*/
public function execute()
{
if ($this->getRequest()->getPost()) {
if ($this->getRequest()->getPostValue()) {
try {
$model = $this->_objectManager->create('Magento\CatalogRule\Model\Rule');
$this->_eventManager->dispatch(
'adminhtml_controller_catalogrule_prepare_save',
['request' => $this->getRequest()]
);
$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
$inputFilter = new \Zend_Filter_Input(
['from_date' => $this->_dateFilter, 'to_date' => $this->_dateFilter],
[],
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/CatalogSearch/Block/Advanced/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function getProductListHtml()
public function getFormUrl()
{
return $this->_urlFactory->create()->addQueryParams(
$this->getRequest()->getQuery()
$this->getRequest()->getQueryValue()
)->getUrl(
'*/*/',
['_escape' => true]
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/CatalogSearch/Controller/Advanced/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public function execute()
{
try {
$this->layerResolver->create('advanced');
$this->_catalogSearchAdvanced->addFilters($this->getRequest()->getQuery());
$this->_catalogSearchAdvanced->addFilters($this->getRequest()->getQueryValue());
$this->_view->loadLayout();
$this->_view->renderLayout();
} catch (\Magento\Framework\Model\Exception $e) {
$this->messageManager->addError($e->getMessage());
$defaultUrl = $this->_urlFactory->create()
->addQueryParams($this->getRequest()->getQuery())
->addQueryParams($this->getRequest()->getQueryValue())
->getUrl('*/*/');
$this->getResponse()->setRedirect($this->_redirect->error($defaultUrl));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function invoke(Observer $observer)
{
/** @var Category $category */
$category = $observer->getEvent()->getCategory();
$data = $observer->getEvent()->getRequest()->getPost();
$data = $observer->getEvent()->getRequest()->getPostValue();

/**
* Create Permanent Redirect for old URL key
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Checkout/Controller/Onepage.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public function dispatch(RequestInterface $request)
protected function _ajaxRedirectResponse()
{
$resultRaw = $this->resultRawFactory->create();
$resultRaw->setHeader('HTTP/1.1', '403 Session Expired')
$resultRaw->setStatusHeader(403, '1.1', 'Session Expired')
->setHeader('Login-Required', 'true');
return $resultRaw;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Save extends \Magento\CheckoutAgreements\Controller\Adminhtml\Agreement
*/
public function execute()
{
$postData = $this->getRequest()->getPost();
$postData = $this->getRequest()->getPostValue();
if ($postData) {
$model = $this->_objectManager->get('Magento\CheckoutAgreements\Model\Agreement');
$model->setData($postData);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/Controller/Adminhtml/Block/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function execute()
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
// check if data sent
$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
if ($data) {
$id = $this->getRequest()->getParam('block_id');
$model = $this->_objectManager->create('Magento\Cms\Model\Block')->load($id);
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ protected function _isAllowed()
*/
public function execute()
{
$data = $this->getRequest()->getPost();
$data = $this->getRequest()->getPostValue();
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
if ($data) {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/Controller/Index/DefaultNoRoute.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct(
public function execute()
{
$resultLayout = $this->resultPageFactory->create();
$resultLayout->setHeader('HTTP/1.1', '404 Not Found');
$resultLayout->setStatusHeader(404, '1.1', 'Not Found');
$resultLayout->setHeader('Status', '404 File not found');
return $resultLayout;
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/Controller/Noroute/Index.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function execute()
$pageHelper = $this->_objectManager->get('Magento\Cms\Helper\Page');
$resultPage = $pageHelper->prepareResultPage($this, $pageId);
if ($resultPage) {
$resultPage->setHeader('HTTP/1.1', '404 Not Found');
$resultPage->setStatusHeader(404, '1.1', 'Not Found');
$resultPage->setHeader('Status', '404 File not found');
return $resultPage;
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Contact/Controller/Index/Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Post extends \Magento\Contact\Controller\Index
*/
public function execute()
{
$post = $this->getRequest()->getPost();
$post = $this->getRequest()->getPostValue();
if (!$post) {
$this->_redirect('*/*/');
return;
Expand Down
3 changes: 1 addition & 2 deletions app/code/Magento/Core/Controller/Index/NotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ class NotFound extends \Magento\Framework\App\Action\Action
*/
public function execute()
{
$this->getResponse()->setHeader('HTTP/1.1', '404 Not Found');
$this->getResponse()->setHttpResponseCode(404);
$this->getResponse()->setStatusHeader(404, '1.1', 'Not Found');
$this->getResponse()->setBody(__('Requested resource not found'));
}
}
8 changes: 5 additions & 3 deletions app/code/Magento/Core/Model/File/Storage/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*/
namespace Magento\Core\Model\File\Storage;

use Magento\Framework\HTTP\PhpEnvironment\Request as HttpRequest;

class Request
{
/**
Expand All @@ -23,11 +25,11 @@ class Request

/**
* @param string $workingDir
* @param \Zend_Controller_Request_Http $request
* @param HttpRequest $request
*/
public function __construct($workingDir, \Zend_Controller_Request_Http $request = null)
public function __construct($workingDir, HttpRequest $request = null)
{
$request = $request ?: new \Zend_Controller_Request_Http();
$request = $request ?: new HttpRequest();
$this->_pathInfo = str_replace('..', '', ltrim($request->getPathInfo(), '/'));
$this->_filePath = $workingDir . '/' . $this->_pathInfo;
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Core/Model/File/Storage/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ class Response extends Http implements \Magento\Framework\App\Response\FileInter
/**
* Constructor
*
* @param \Magento\Framework\Stdlib\CookieManagerInterface $cookieManager
* @param \Magento\Framework\Stdlib\Cookie\CookieMetadataFactory $cookieMetadataFactory
* @param CookieManagerInterface $cookieManager
* @param CookieMetadataFactory $cookieMetadataFactory
* @param \Magento\Framework\App\Http\Context $context
* @param \Magento\Framework\File\Transfer\Adapter\Http $transferAdapter
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public function execute()
$this->messageManager->addException($e, __('Cannot save the customer.'));
}

$this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
$this->_getSession()->setCustomerFormData($this->getRequest()->getPostValue());
$defaultUrl = $this->urlModel->getUrl('*/*/create', ['_secure' => true]);
$resultRedirect->setUrl($this->_redirect->error($defaultUrl));
return $resultRedirect;
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Controller/Account/EditPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function execute()
}

if ($this->messageManager->getMessages()->getCount() > 0) {
$this->_getSession()->setCustomerFormData($this->getRequest()->getPost());
$this->_getSession()->setCustomerFormData($this->getRequest()->getPostValue());
$resultRedirect->setPath('*/*/edit');
return $resultRedirect;
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/Controller/Address/FormPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function execute()
}

if (!$this->getRequest()->isPost()) {
$this->_getSession()->setAddressFormData($this->getRequest()->getPost());
$this->_getSession()->setAddressFormData($this->getRequest()->getPostValue());
return $this->resultRedirectFactory->create()->setUrl(
$this->_redirect->error($this->_buildUrl('*/*/edit'))
);
Expand All @@ -96,7 +96,7 @@ public function execute()
$this->messageManager->addException($e, __('Cannot save address.'));
}

$this->_getSession()->setAddressFormData($this->getRequest()->getPost());
$this->_getSession()->setAddressFormData($this->getRequest()->getPostValue());
$url = $this->_buildUrl('*/*/edit', ['id' => $this->getRequest()->getParam('id')]);
return $this->resultRedirectFactory->create()->setUrl($this->_redirect->error($url));
}
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected function _extractData(
}
$filteredData = $metadataForm->extractData($request, $scope);

$object = $this->_objectFactory->create(['data' => $request->getPost()]);
$object = $this->_objectFactory->create(['data' => $request->getPostValue()]);
$requestData = $object->getData($scope);
foreach ($additionalAttributes as $attributeCode) {
$filteredData[$attributeCode] = isset($requestData[$attributeCode]) ? $requestData[$attributeCode] : false;
Expand Down Expand Up @@ -178,7 +178,7 @@ public function execute()
{
$returnToEdit = false;
$customerId = (int)$this->getRequest()->getParam('id');
$originalRequestData = $this->getRequest()->getPost();
$originalRequestData = $this->getRequest()->getPostValue();
if ($originalRequestData) {
try {
// optional fields might be set in request for future processing by observers in other modules
Expand Down
4 changes: 2 additions & 2 deletions app/code/Magento/Customer/Controller/Ajax/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* Login controller
*
* @method \Zend_Controller_Request_Http getRequest()
* @method \Magento\Framework\App\RequestInterface getRequest()
* @method \Magento\Framework\App\Response\Http getResponse()
*/
class Login extends \Magento\Framework\App\Action\Action
Expand Down Expand Up @@ -85,7 +85,7 @@ public function execute()
/** @var \Magento\Framework\Controller\Result\Raw $resultRaw */
$resultRaw = $this->resultRawFactory->create();
try {
$credentials = $this->helper->jsonDecode($this->getRequest()->getRawBody());
$credentials = $this->helper->jsonDecode($this->getRequest()->getContent());
} catch (\Exception $e) {
return $resultRaw->setHttpResponseCode($httpBadRequestCode);
}
Expand Down
2 changes: 1 addition & 1 deletion app/code/Magento/Customer/Controller/Ajax/Logout.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/**
* Logout controller
*
* @method \Zend_Controller_Request_Http getRequest()
* @method \Magento\Framework\App\RequestInterface getRequest()
* @method \Magento\Framework\App\Response\Http getResponse()
*/
class Logout extends \Magento\Framework\App\Action\Action
Expand Down
2 changes: 0 additions & 2 deletions app/code/Magento/Customer/Model/Metadata/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,10 +311,8 @@ protected function _getAttributeDataModel($attribute)
public function prepareRequest(array $data)
{
$request = clone $this->_httpRequest;
$request->setParamSources();
$request->clearParams();
$request->setParams($data);

return $request;
}

Expand Down
2 changes: 0 additions & 2 deletions app/code/Magento/Eav/Model/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,10 +415,8 @@ protected function _getAttributeDataModel(\Magento\Eav\Model\Entity\Attribute $a
public function prepareRequest(array $data)
{
$request = clone $this->_httpRequest;
$request->setParamSources();
$request->clearParams();
$request->setParams($data);

return $request;
}

Expand Down
Loading

0 comments on commit a9e59f8

Please sign in to comment.