Completed
Push — master ( eb51fb...9d1029 )
by David
01:50
created
Controllers/Backend/WbmQueryManager.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             )
59 59
             ->from('WbmQueryManager\Models\Query', 'query');
60 60
         
61
-        if(!empty($id)){
61
+        if (!empty($id)) {
62 62
             $qb->where('query.id = :id')
63 63
                 ->setParameter(':id', $id);
64 64
         } else {
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         $params = $this->Request()->getPost();
78 78
         
79
-        if($params['hasCronjob'] && empty($params['nextRun'])){
79
+        if ($params['hasCronjob'] && empty($params['nextRun'])) {
80 80
             $params['nextRun'] = new \DateTime();
81 81
         }
82 82
         
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $params = $this->Request()->getPost();
100 100
         $id = (int)$this->Request()->get('id');
101 101
         
102
-        if($params['hasCronjob'] && empty($params['nextRun'])){
102
+        if ($params['hasCronjob'] && empty($params['nextRun'])) {
103 103
             $params['nextRun'] = new \DateTime();
104 104
         }
105 105
 
@@ -164,18 +164,18 @@  discard block
 block discarded – undo
164 164
             do {
165 165
                 $data[$i]['rowsetKey'] = $i;
166 166
 
167
-                if($this->container->get('wbm_query_manager.db')->getColumnCount($query)){
167
+                if ($this->container->get('wbm_query_manager.db')->getColumnCount($query)) {
168 168
                     $records = $this->container->get('wbm_query_manager.db')->fetchAll($query);
169 169
                     $data[$i]['rowCount'] = $this->container->get('wbm_query_manager.db')->getRowCount($query);
170 170
 
171
-                    if($download && $rowsetKey != $i){
171
+                    if ($download && $rowsetKey != $i) {
172 172
                         $i++;
173 173
                         continue;
174 174
                     }
175 175
 
176 176
                     $recordFields = array_keys($records[0]);
177 177
                     $columns = array();
178
-                    foreach($recordFields as $recordField){
178
+                    foreach ($recordFields as $recordField) {
179 179
                         $columns[] = array(
180 180
                             'header' => $recordField,
181 181
                             'dataIndex' => $recordField,
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                         'columns' => $columns
190 190
                     );
191 191
 
192
-                    if($download){
192
+                    if ($download) {
193 193
                         $this->container->get('plugins')->Controller()->ViewRenderer()->setNoRender();
194 194
                         $now = new \DateTime();
195 195
                         $file = "query_" . $now->format('Y_m_d_h_i_s') . ".csv";
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
                         header("Content-Disposition: attachment; filename=\"$file\"");
198 198
 
199 199
                         $outputBuffer = fopen("php://output", 'w');
200
-                        foreach(array_merge(array(0 => $recordFields),$records) as $val) {
200
+                        foreach (array_merge(array(0 => $recordFields), $records) as $val) {
201 201
                             fputcsv($outputBuffer, $val, $this->container->get('config')->getByNamespace('WbmQueryManager', 'csv_field_separator'));
202 202
                         }
203 203
                         fclose($outputBuffer);
Please login to merge, or discard this patch.
WbmQueryManager.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
      */
61 61
     public function update(UpdateContext $context)
62 62
     {
63
-        if(version_compare($context->getCurrentVersion(), '2.0.0', '<')) {
63
+        if (version_compare($context->getCurrentVersion(), '2.0.0', '<')) {
64 64
             $sql = "ALTER TABLE `wbm_query_manager` CHANGE `interval` `interval_int` INT(11) NULL DEFAULT '0';
65 65
                     ALTER TABLE `wbm_query_manager` CHANGE `sql` `sql_string` LONGTEXT NOT NULL;";
66 66
 
Please login to merge, or discard this patch.
Services/QueryManagerDb.php 1 patch
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
      */
52 52
     private function getConnection($query)
53 53
     {
54
-        if(function_exists('mysqli_connect') && class_exists('Zend_Db_Adapter_Mysqli')) {
54
+        if (function_exists('mysqli_connect') && class_exists('Zend_Db_Adapter_Mysqli')) {
55 55
             $config = $this->container->getParameter('shopware.db');
56 56
             $mysqli = new \Zend_Db_Adapter_Mysqli($config);
57 57
             $connection = $mysqli->getConnection();
58
-            if($connection->multi_query($query)){
58
+            if ($connection->multi_query($query)) {
59 59
                 return $connection;
60 60
             }
61 61
         }
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public function query($query)
70 70
     {
71 71
         $connection = $this->getConnection($query);
72
-        if(get_class($connection) == 'mysqli'){
72
+        if (get_class($connection) == 'mysqli') {
73 73
             return $connection;
74 74
         }
75 75
         return $connection->query($query);
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
      */
82 82
     public function getRowCount($query)
83 83
     {
84
-        if(get_class($query) == 'mysqli'){
84
+        if (get_class($query) == 'mysqli') {
85 85
             return $query->affected_rows;
86 86
         }
87 87
         return $query->rowCount();
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public function getColumnCount($query)
95 95
     {
96
-        if(get_class($query) == 'mysqli'){
96
+        if (get_class($query) == 'mysqli') {
97 97
             return $query->field_count;
98 98
         }
99 99
         return $query->columnCount();
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
      */
106 106
     public function fetchAll($query)
107 107
     {
108
-        if(get_class($query) == 'mysqli'){
108
+        if (get_class($query) == 'mysqli') {
109 109
             $results = array();
110
-            if($result = $query->store_result()){
111
-                while($row = $result->fetch_assoc()){
110
+            if ($result = $query->store_result()) {
111
+                while ($row = $result->fetch_assoc()) {
112 112
                     $results[] = $row;
113 113
                 }
114 114
             }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
      */
124 124
     public function nextResult($query)
125 125
     {
126
-        if(get_class($query) == 'mysqli'){
126
+        if (get_class($query) == 'mysqli') {
127 127
             return $query->next_result();
128 128
         }
129 129
         return false;
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
      */
136 136
     public function close($query)
137 137
     {
138
-        if(get_class($query) == 'mysqli'){
138
+        if (get_class($query) == 'mysqli') {
139 139
             return $query->close();
140 140
         } else {
141 141
             $query->closeCursor();
Please login to merge, or discard this patch.
Subscriber/Backend/QueryManagerCron.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
         $data = array();
77 77
         $clearCacheAfter = false;
78 78
 
79
-        foreach($cronJobs as $cronJob){
79
+        foreach ($cronJobs as $cronJob) {
80 80
             $i = 0;
81 81
             $numRows = 0;
82 82
             try {
83 83
                 /** @var \mysqli|\Zend_Db_Statement_Pdo $query */
84 84
                 $query = $this->container->get('wbm_query_manager.db')->query($cronJob['sqlString']);
85
-                if($query instanceof \Zend_Db_Statement_Pdo) {
85
+                if ($query instanceof \Zend_Db_Statement_Pdo) {
86 86
                     $query->closeCursor();
87 87
                 }
88 88
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
                 $snippets = $this->container->get('snippets')->getNamespace("backend/plugins/wbm/querymanager");
91 91
 
92 92
                 do {
93
-                    if($this->container->get('wbm_query_manager.db')->getColumnCount($query)){
93
+                    if ($this->container->get('wbm_query_manager.db')->getColumnCount($query)) {
94 94
                         $records = $this->container->get('wbm_query_manager.db')->fetchAll($query);
95 95
                         $rowCount = $this->container->get('wbm_query_manager.db')->getRowCount($query);
96 96
                         $recordFields = array_keys($records[0]);
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
                         $csvPath = $this->container->get('application')->DocPath() . 'var/log/' . $file;
103 103
 
104 104
                         $outputBuffer = fopen($csvPath, 'w');
105
-                        foreach(array_merge(array(0 => $recordFields),$records) as $val) {
105
+                        foreach (array_merge(array(0 => $recordFields), $records) as $val) {
106 106
                             fputcsv($outputBuffer, $val, $this->container->get('config')->getByNamespace('WbmQueryManager', 'csv_field_separator'));
107 107
                         }
108 108
                         fclose($outputBuffer);
109 109
 
110 110
                         $mailRecipient = $this->container->get('config')->getByNamespace('WbmQueryManager', 'mail_address_receiver');
111
-                        if(!empty($mailRecipient)){
111
+                        if (!empty($mailRecipient)) {
112 112
                             $mail = clone $this->container->get('mail');
113 113
                             $mail->setFrom($this->container->get('config')->get('mail'));
114 114
                             $mail->addTo($mailRecipient);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
                             $mail->send();
125 125
                         }
126 126
 
127
-                        if(!$this->container->get('config')->getByNamespace('WbmQueryManager', 'log_csv')){
127
+                        if (!$this->container->get('config')->getByNamespace('WbmQueryManager', 'log_csv')) {
128 128
                             unlink($csvPath);
129 129
                         }
130 130
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             $query = $this->container->get('models')->getRepository('WbmQueryManager\Models\Query')->find($cronJob['id']);
145 145
             $query->setLastLog($result);
146 146
             /** @var \DateTime $lastRun */
147
-            $lastRun = $query->getLastRun() ? : new \DateTime();
147
+            $lastRun = $query->getLastRun() ?: new \DateTime();
148 148
             $query->setLastRun($now);
149 149
             $query->setNextRun($lastRun->add(\DateInterval::createFromDateString($query->getIntervalInt() . ' seconds')));
150 150
 
@@ -152,14 +152,14 @@  discard block
 block discarded – undo
152 152
             $this->container->get('models')->flush();
153 153
             $this->container->get('models')->clear();
154 154
 
155
-            if($cronJob['clear_cache']){
155
+            if ($cronJob['clear_cache']) {
156 156
                 $clearCacheAfter = true;
157 157
             }
158 158
 
159 159
             $data[$cronJob['name']] = $result;
160 160
         }
161 161
 
162
-        if($clearCacheAfter){
162
+        if ($clearCacheAfter) {
163 163
             $cacheManager = $this->container->get('shopware.cache_manager');
164 164
             $cacheManager->clearHttpCache();
165 165
             $cacheManager->clearTemplateCache();
Please login to merge, or discard this patch.
Library/Zend/Db/Statement/Mysqli.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
                 $row = array_merge($values, $assoc);
309 309
                 break;
310 310
             case Zend_Db::FETCH_OBJ:
311
-                $row = (object) array_combine($this->_keys, $values);
311
+                $row = (object)array_combine($this->_keys, $values);
312 312
                 break;
313 313
             case Zend_Db::FETCH_BOUND:
314 314
                 $assoc = array_combine($this->_keys, $values);
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
          * @see Zend_Db_Statement_Mysqli_Exception
341 341
          */
342 342
         require_once 'Zend/Db/Statement/Mysqli/Exception.php';
343
-        throw new Zend_Db_Statement_Mysqli_Exception(__FUNCTION__.'() is not implemented');
343
+        throw new Zend_Db_Statement_Mysqli_Exception(__FUNCTION__ . '() is not implemented');
344 344
     }
345 345
 
346 346
     /**
Please login to merge, or discard this patch.
Library/Zend/Db/Adapter/Mysqli.php 2 patches
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
                 'COLUMN_POSITION'  => $i,
258 258
                 'DATA_TYPE'        => $row['Type'],
259 259
                 'DEFAULT'          => $row['Default'],
260
-                'NULLABLE'         => (bool) ($row['Null'] == 'YES'),
260
+                'NULLABLE'         => (bool)($row['Null'] == 'YES'),
261 261
                 'LENGTH'           => $row['Length'],
262 262
                 'SCALE'            => $row['Scale'],
263 263
                 'PRECISION'        => $row['Precision'],
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
         }
293 293
 
294 294
         if (isset($this->_config['port'])) {
295
-            $port = (integer) $this->_config['port'];
295
+            $port = (integer)$this->_config['port'];
296 296
         } else {
297 297
             $port = null;
298 298
         }
@@ -305,13 +305,13 @@  discard block
 block discarded – undo
305 305
 
306 306
         $this->_connection = mysqli_init();
307 307
 
308
-        if(!empty($this->_config['driver_options'])) {
309
-            foreach($this->_config['driver_options'] as $option=>$value) {
310
-                if(is_string($option)) {
308
+        if (!empty($this->_config['driver_options'])) {
309
+            foreach ($this->_config['driver_options'] as $option=>$value) {
310
+                if (is_string($option)) {
311 311
                     // Suppress warnings here
312 312
                     // Ignore it if it's not a valid constant
313 313
                     $option = @constant(strtoupper($option));
314
-                    if($option === null)
314
+                    if ($option === null)
315 315
                         continue;
316 316
                 }
317 317
                 mysqli_options($this->_connection, $option, $value);
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
      */
353 353
     public function isConnected()
354 354
     {
355
-        return ((bool) ($this->_connection instanceof mysqli));
355
+        return ((bool)($this->_connection instanceof mysqli));
356 356
     }
357 357
 
358 358
     /**
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
     public function lastInsertId($tableName = null, $primaryKey = null)
415 415
     {
416 416
         $mysqli = $this->_connection;
417
-        return (string) $mysqli->insert_id;
417
+        return (string)$mysqli->insert_id;
418 418
     }
419 419
 
420 420
     /**
@@ -548,9 +548,9 @@  discard block
 block discarded – undo
548 548
     {
549 549
         $this->_connect();
550 550
         $version = $this->_connection->server_version;
551
-        $major = (int) ($version / 10000);
552
-        $minor = (int) ($version % 10000 / 100);
553
-        $revision = (int) ($version % 100);
551
+        $major = (int)($version / 10000);
552
+        $minor = (int)($version % 10000 / 100);
553
+        $revision = (int)($version % 100);
554 554
         return $major . '.' . $minor . '.' . $revision;
555 555
     }
556 556
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -311,8 +311,9 @@
 block discarded – undo
311 311
                     // Suppress warnings here
312 312
                     // Ignore it if it's not a valid constant
313 313
                     $option = @constant(strtoupper($option));
314
-                    if($option === null)
315
-                        continue;
314
+                    if($option === null) {
315
+                                            continue;
316
+                    }
316 317
                 }
317 318
                 mysqli_options($this->_connection, $option, $value);
318 319
             }
Please login to merge, or discard this patch.