Skip to content

Commit 5524b79

Browse files
authored
Merge pull request #1046 from vishal-singh-webkul/gli-2046
Fixed: Getting errors in the back office if the id in the URL is updated manually to an invalid one.
2 parents b3dbfd7 + ed1251a commit 5524b79

11 files changed

+35
-30
lines changed

classes/order/Order.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1805,7 +1805,7 @@ public function getOrderPaymentDetail()
18051805
SELECT opd.`amount` as `real_paid_amount`, opd.*, op.*
18061806
FROM `'._DB_PREFIX_.'order_payment_detail` opd
18071807
INNER JOIN `'._DB_PREFIX_.'order_payment` op ON (opd.`id_order_payment` = op.`id_order_payment`)
1808-
WHERE `id_order` = '.$this->id
1808+
WHERE `id_order` = '.(int) $this->id
18091809
);
18101810
}
18111811

controllers/admin/AdminCmsContentController.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ public function viewAccess($disable = false)
8585

8686
public function initContent()
8787
{
88+
$this->loadObject(true);
8889
$this->initTabModuleList();
8990
$this->renderPageHeaderToolbar();
9091

@@ -151,8 +152,9 @@ public function renderPageHeaderToolbar()
151152

152153
if (Tools::getValue('addcms') !== false) {
153154
$this->toolbar_title[] = $this->l('Add new');
154-
} elseif ($id_cms_page) {
155-
$cms_page = new CMS($id_cms_page);
155+
} elseif ($id_cms_page
156+
&& Validate::isLoadedObject($cms_page = new CMS($id_cms_page))
157+
) {
156158
$this->toolbar_title[] = sprintf($this->l('Edit: %s'), $cms_page->meta_title[$this->context->employee->id_lang]);
157159
}
158160
} else {

controllers/admin/AdminFeaturesController.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -452,10 +452,9 @@ public function initContent()
452452
$this->initToolbar();
453453
$this->initPageHeaderToolbar();
454454
if ($this->display == 'edit' || $this->display == 'add') {
455-
if (!$this->loadObject(true)) {
456-
return;
455+
if ($this->loadObject(true)) {
456+
$this->content .= $this->renderForm();
457457
}
458-
$this->content .= $this->renderForm();
459458
} elseif ($this->display == 'view') {
460459
// Some controllers use the view action without an object
461460
if ($this->className) {

controllers/admin/AdminNormalProductsController.php

+5-4
Original file line numberDiff line numberDiff line change
@@ -1392,7 +1392,10 @@ public function postProcess()
13921392
parent::postProcess();
13931393
}
13941394

1395-
if ($this->display == 'edit' || $this->display == 'add') {
1395+
if (in_array($this->display, array('add', 'edit'))
1396+
&& $this->tabAccess[$this->display] == '1'
1397+
&& $this->loadObject(true)
1398+
) {
13961399
$this->addJqueryUI(array(
13971400
'ui.core',
13981401
'ui.widget'
@@ -2814,9 +2817,7 @@ public function renderForm()
28142817
}
28152818

28162819
// let's calculate this once for all
2817-
if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) {
2818-
$this->errors[] = 'Unable to load object';
2819-
} else {
2820+
if ($this->loadObject(true)) {
28202821
$this->_displayDraftWarning($this->object->active);
28212822

28222823
// if there was an error while saving, we don't want to lose posted data

controllers/admin/AdminOrdersController.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,9 @@ public function setMedia()
980980
$this->addJS(_PS_JS_DIR_.'vendor/d3.v3.min.js');
981981

982982
if ($this->tabAccess['edit'] == 1 && $this->display == 'view') {
983-
$this->addJS(_PS_JS_DIR_.'admin/orders.js');
983+
if ($this->loadObject()) {
984+
$this->addJS(_PS_JS_DIR_.'admin/orders.js');
985+
}
984986
// add js for reallocation process
985987
$this->addJS(_PS_JS_DIR_.'admin/reallocation.js');
986988
// $this->addJS(_PS_JS_DIR_.'admin/orders-product-event.js');
@@ -6912,4 +6914,4 @@ public function ajaxProcessChangeRoomTypeToReallocate()
69126914

69136915
$this->ajaxDie(json_encode($result));
69146916
}
6915-
}
6917+
}

controllers/admin/AdminProductsController.php

+2-3
Original file line numberDiff line numberDiff line change
@@ -1486,6 +1486,7 @@ public function postProcess()
14861486

14871487
if (in_array($this->display, array('add', 'edit'))
14881488
&& $this->tabAccess[$this->display] == '1'
1489+
&& $this->loadObject(true)
14891490
) {
14901491
$this->addJqueryUI(array(
14911492
'ui.core',
@@ -2862,9 +2863,7 @@ public function renderForm()
28622863
}
28632864

28642865
// let's calculate this once for all
2865-
if (!Validate::isLoadedObject($this->object) && Tools::getValue('id_product')) {
2866-
$this->errors[] = 'Unable to load object';
2867-
} else {
2866+
if ($this->loadObject(true)) {
28682867
$this->_displayDraftWarning($this->object->active);
28692868

28702869
// if there was an error while saving, we don't want to lose posted data

controllers/admin/AdminRequestSqlController.php

+2-4
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,9 @@ public function initContent()
283283
$this->initToolbar();
284284
$this->initPageHeaderToolbar();
285285
if ($this->display == 'edit' || $this->display == 'add') {
286-
if (!$this->loadObject(true)) {
287-
return;
286+
if ($this->loadObject(true)) {
287+
$this->content .= $this->renderForm();
288288
}
289-
290-
$this->content .= $this->renderForm();
291289
} elseif ($this->display == 'view') {
292290
// Some controllers use the view action without an object
293291
if ($this->className) {

modules/hotelreservationsystem/controllers/admin/AdminAddHotelController.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ public function renderList()
104104

105105
public function renderForm()
106106
{
107+
if (!$this->loadObject(true)) {
108+
return;
109+
}
107110
$smartyVars = array();
108111
//tinymce setup
109112
$smartyVars['path_css'] = _THEME_CSS_DIR_;
@@ -125,7 +128,7 @@ public function renderForm()
125128
$smartyVars['defaultCountry'] = $country->name[Configuration::get('PS_LANG_DEFAULT')];
126129

127130
$idCountry = null;
128-
if ($this->display == 'edit') {
131+
if ($this->object->id) {
129132
$idHotel = Tools::getValue('id');
130133
$hotelBranchInfo = new HotelBranchInformation($idHotel);
131134
$objCategory = new Category($hotelBranchInfo->id_category);
@@ -168,13 +171,11 @@ public function renderForm()
168171
}
169172
}
170173
$smartyVars['order_restrict_date_info'] = $restrictDateInfo;
171-
}
172-
173-
// manage state option
174-
if ($this->display == 'add') {
174+
} else {
175175
$idCountry = Tools::getValue('hotel_country');
176176
}
177177

178+
// manage state option
178179
$stateOptions = null;
179180
if ($idCountry) {
180181
$stateOptions = State::getStatesByIdCountry($idCountry);

modules/hotelreservationsystem/controllers/admin/AdminHotelfeaturesController.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public function renderView()
5858

5959
public function renderForm()
6060
{
61+
if (!$this->loadObject(true)) {
62+
return;
63+
}
64+
6165
$smartyVars = array();
6266
//lang vars
6367
$languages = Language::getLanguages(false);
@@ -66,7 +70,7 @@ public function renderForm()
6670
$smartyVars['languages'] = $languages;
6771
$smartyVars['currentLang'] = $currentLang;
6872
$smartyVars['ps_img_dir'] = _PS_IMG_.'l/';
69-
if ($id = Tools::getValue('id')) {
73+
if ($id = $this->object->id) {
7074
$smartyVars['edit'] = 1;
7175
if (Validate::isLoadedObject($objFeatures = new HotelFeatures($id))) {
7276
$featureInfo = (array) $objFeatures;

modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRequestsController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ public function displayViewLink($token, $idOrderReturn, $name = null)
195195

196196
public function renderView()
197197
{
198-
if (!($objOrderReturn = $this->loadObject(true))) {
198+
if (!($objOrderReturn = $this->loadObject())) {
199199
return;
200200
}
201201
$refundStatuses = OrderReturnStateCore::getOrderReturnStates($this->context->language->id);

modules/hotelreservationsystem/controllers/admin/AdminOrderRefundRulesController.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,13 @@ public function renderForm()
141141
$smartyVars = array();
142142
$objCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
143143
$smartyVars['objCurrency'] = $objCurrency;
144-
145-
if ($this->display == 'edit'
146-
&& $refundRuleInfo = $this->loadObject(true)
144+
if (($refundRuleInfo = $this->loadObject(true))
145+
&& $this->object->id
147146
) {
148147
$smartyVars['edit'] = 1;
149148
$idRefundRule = Tools::getValue('id_refund_rule');
150149
$objRefundRule = new HotelOrderRefundRules();
151-
$smartyVars['refund_rules_info'] = (array)$refundRuleInfo;
150+
$smartyVars['refund_rules_info'] = (array) $refundRuleInfo;
152151
}
153152

154153
//lang vars

0 commit comments

Comments
 (0)