Completed
Push — master ( f88fd0...4d0eb1 )
by David
01:46
created
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,7 +102,7 @@  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);
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                         if ($cronJob['mailRecipient']) {
112 112
                             $mailRecipient = $cronJob['mailRecipient'];
113 113
                         }
114
-                        if(!empty($mailRecipient)){
114
+                        if (!empty($mailRecipient)) {
115 115
                             $mail = clone $this->container->get('mail');
116 116
                             $mail->setFrom($this->container->get('config')->get('mail'));
117 117
                             $mail->addTo($mailRecipient);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
                             $mail->send();
128 128
                         }
129 129
 
130
-                        if(!$this->container->get('config')->getByNamespace('WbmQueryManager', 'log_csv')){
130
+                        if (!$this->container->get('config')->getByNamespace('WbmQueryManager', 'log_csv')) {
131 131
                             unlink($csvPath);
132 132
                         }
133 133
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
             $query = $this->container->get('models')->getRepository('WbmQueryManager\Models\Query')->find($cronJob['id']);
148 148
             $query->setLastLog($result);
149 149
             /** @var \DateTime $lastRun */
150
-            $lastRun = $query->getLastRun() ? : new \DateTime();
150
+            $lastRun = $query->getLastRun() ?: new \DateTime();
151 151
             $query->setLastRun($now);
152 152
             $query->setNextRun($lastRun->add(\DateInterval::createFromDateString($query->getIntervalInt() . ' seconds')));
153 153
 
@@ -155,14 +155,14 @@  discard block
 block discarded – undo
155 155
             $this->container->get('models')->flush();
156 156
             $this->container->get('models')->clear();
157 157
 
158
-            if($cronJob['clear_cache']){
158
+            if ($cronJob['clear_cache']) {
159 159
                 $clearCacheAfter = true;
160 160
             }
161 161
 
162 162
             $data[$cronJob['name']] = $result;
163 163
         }
164 164
 
165
-        if($clearCacheAfter){
165
+        if ($clearCacheAfter) {
166 166
             $cacheManager = $this->container->get('shopware.cache_manager');
167 167
             $cacheManager->clearHttpCache();
168 168
             $cacheManager->clearTemplateCache();
Please login to merge, or discard this patch.
WbmQueryManager.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -60,14 +60,14 @@
 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
 
67 67
             $this->container->get('shopware.db')->query($sql);
68 68
         }
69 69
 
70
-        if(version_compare($context->getCurrentVersion(), '2.0.3', '<')) {
70
+        if (version_compare($context->getCurrentVersion(), '2.0.3', '<')) {
71 71
             $sql = "ALTER TABLE `wbm_query_manager` ADD `mail_recipient` VARCHAR (255) NULL DEFAULT NULL AFTER `last_run`;";
72 72
 
73 73
             $this->container->get('shopware.db')->query($sql);
Please login to merge, or discard this patch.