Skip to content

Commit 03b5436

Browse files
authored
Merge pull request #182 from mollie/9.1.12
9.1.12 -- Bugfixes and cleanup
2 parents fb2aa89 + 872402a commit 03b5436

File tree

8 files changed

+55
-29
lines changed

8 files changed

+55
-29
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
# Changelog #
44

5+
#### Changes in release 9.1.12
6+
+ Bugfix in database table patching
7+
+ Bugfix model load
8+
+ Bugfix PatchTable
9+
+ Cleaned up code
10+
511
#### Changes in release 9.1.11
612
+ Bugfix in database table patching
713

catalog/controller/payment/mollie/base.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,11 @@ public function payment()
316316
//Check if coupon applied
317317
if(isset($this->session->data['coupon'])) {
318318
//Get coupon data
319-
$coupon = Util::load()->model('extension/total/coupon');
319+
if(Util::version()->isMaximal("2.0.3.1")) {
320+
$coupon = Util::load()->model('checkout/coupon');
321+
} else {
322+
$coupon = Util::load()->model('total/coupon');
323+
}
320324

321325
$coupon_info = $coupon->getCoupon($this->session->data['coupon']);
322326

catalog/controller/payment/mollie/helper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
class MollieHelper
77
{
8-
const PLUGIN_VERSION = "9.1.11";
8+
const PLUGIN_VERSION = "9.1.12";
99
const OUTH_URL = 'https://api.mollie.com/oauth2';
1010

1111
// All available modules. These should correspond to the Mollie_API_Object_Method constants.

system/comercia/load.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,10 @@ private function rewriteModel($model)
380380
[
381381
"" => "extension/event",
382382
"3.0" => "setting/event"
383+
],
384+
[
385+
"" => "total/coupon",
386+
"2.3" => "extension/total/coupon"
383387
]
384388
]
385389
);

system/comercia/patch.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ class Patch
66
var $db;
77
function __construct()
88
{
9-
$prefix=DB_PREFIX;
109
require_once(__DIR__."/patchTable.php");
1110
$this->db=Util::registry()->get("db");
1211

13-
$table = $this->table("comercia_patch");
14-
if (!$table->exists()) {
15-
$table->addField("path","varchar(255)");
16-
$table->addField("patch", "varchar(50)");
17-
$table->addField("success", "int");
18-
$table->addField("date", "int");
19-
$table->create();
20-
}
12+
$this->table("comercia_patch")
13+
->addField("comercia_patch_id", "INT NOT NULL AUTO_INCREMENT", "primary")
14+
->addField("path", "varchar(255)")
15+
->addField("patch", "varchar(50)")
16+
->addField("success", "int")
17+
->addField("date", "int")
18+
->create();
2119

20+
$this->table("comercia_patch")
21+
->addField("comercia_patch_id", "INT NOT NULL AUTO_INCREMENT", "primary")
22+
->update();
2223
}
2324

2425
function runPatchesFromFile($path){

system/comercia/patchTable.php

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ function update()
5555
$query .= ",";
5656
}
5757

58-
if ($action["default"]!==null && $action["default"]!==false){
58+
if ($action["default"]!==null && $action["default"]!==false && $action["default"]!=='primary'){
5959
$action["default"]="'".$action["default"]."'";
6060
}
6161

62-
$query .= "ADD `" . $action["name"] . "` " . $action["type"]. ($action["default"]!==false?" DEFAULT " . $action["default"]:"");
62+
$query .= "ADD `" . $action["name"] . "` " . $action["type"]. (($action["default"]!==false && $action["default"]!=='primary')?" DEFAULT " . $action["default"]:"");
63+
64+
if (strtolower($action['default']) == 'primary') {
65+
$query .= ", ADD PRIMARY KEY (" . $action["name"] . ")";
66+
}
6367

6468
$i++;
6569
}
@@ -73,12 +77,16 @@ function update()
7377
$query .= ",";
7478
}
7579

76-
if($action["default"]!==null && $action["default"]!==false){
80+
if($action["default"]!==null && $action["default"]!==false && $action["default"]!=='primary'){
7781
$action["default"]="'".$action["default"]."'";
7882
}
7983

80-
$query .= "MODIFY `" . $action["name"] . "` " . $action["type"]. ($action["default"]!==false?" DEFAULT ".$action["default"]:"");
81-
84+
$query .= "MODIFY `" . $action["name"] . "` " . $action["type"]. (($action["default"]!==false && $action["default"]!=='primary')?" DEFAULT ".$action["default"]:"");
85+
86+
if (strtolower($action['default']) == 'primary') {
87+
$query .= ", ADD PRIMARY KEY (" . $action["name"] . ")";
88+
}
89+
8290
$i++;
8391
}
8492
}
@@ -117,6 +125,7 @@ function create()
117125
{
118126
if (!$this->exists($this->name)) {
119127
$prefix = DB_PREFIX;
128+
$primary = false;
120129
$query = "create table `" . $prefix . $this->name . "` (";
121130

122131
$i = 0;
@@ -135,7 +144,13 @@ function create()
135144
$i++;
136145
}
137146
}
138-
$query .= ",PRIMARY KEY (".$primary."))";
147+
148+
if ($primary) {
149+
$query .= ",PRIMARY KEY (" . $primary . ")";
150+
}
151+
152+
$query .= ")";
153+
139154

140155
$this->db->query($query);
141156

system/comercia/stringHelper.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ function ccToUnderline($subject){
1212
}
1313

1414
function rewriteForVersion($string,$words){
15+
// Check if file exists
16+
if(file_exists(DIR_APPLICATION . 'model/' . $string . '.php')) {
17+
return $string;
18+
}
19+
1520
foreach($words as $word){
1621
$match=false;
1722
$versionMatch=@isset($word[0])?:array_values($word)[0];

vqmod/xml/mollie.xml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<modification>
22
<id>Quality Works - Mollie</id>
3-
<version>1.2.4</version>
3+
<version>1.2.5</version>
44
<vqmver>2.3.0</vqmver>
55
<author>Quality Works</author>
66

@@ -305,7 +305,7 @@
305305
$order_id = $this->request->get['order_id'];
306306
$order = $this->model_sale_order->getOrder($order_id);
307307
308-
$mollieOrderDetails = $this->model_sale_order->getMollieOrderDetails($order_id);
308+
$mollieOrderDetails = $this->model_sale_order->getMolliePayment($order_id);
309309
if(!$mollieOrderDetails) {
310310
$log->write("Mollie order(mollie_order_id) not found for order_id - $order_id");
311311
$json['error'] = $this->language->get('text_order_not_found');
@@ -354,16 +354,7 @@
354354
<file name="admin/model/sale/order.php">
355355
<operation error="log">
356356
<search position="before"><![CDATA[public function getOrder($order_id)]]></search>
357-
<add><![CDATA[public function getMollieOrderDetails($order_id) {
358-
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "mollie_payments` WHERE order_id = '" . (int)$order_id . "'");
359-
360-
if($query->num_rows) {
361-
return $query->row;
362-
}
363-
364-
return false;
365-
}
366-
357+
<add><![CDATA[
367358
public function updateMolliePayment($order_id, $refund_id, $payment_status) {
368359
$this->db->query("UPDATE `" . DB_PREFIX . "mollie_payments` SET refund_id = '" . $refund_id . "', bank_status = '" . $payment_status . "' WHERE order_id = '" . (int)$order_id . "'");
369360
}

0 commit comments

Comments
 (0)