@@ -165,53 +165,25 @@ public function encryptionKeyRegenerated(\Maho\Event\Observer $observer): void
165165 $ output = $ observer ->getEvent ()->getOutput ();
166166 $ encryptCallback = $ observer ->getEvent ()->getEncryptCallback ();
167167 $ decryptCallback = $ observer ->getEvent ()->getDecryptCallback ();
168- $ readConnection = Mage::getSingleton ('core/resource ' )->getConnection ('core_read ' );
169- $ writeConnection = Mage::getSingleton ('core/resource ' )->getConnection ('core_write ' );
170168
171169 $ output ->write ('Re-encrypting data on sales_flat_quote_payment table... ' );
172- $ table = Mage::getSingleton ('core/resource ' )->getTableName ('sales_flat_quote_payment ' );
173-
174- $ select = $ readConnection ->select ()
175- ->from ($ table )
176- ->where ('cc_number_enc IS NOT NULL ' );
177- $ encryptedData = $ readConnection ->fetchAll ($ select );
178- foreach ($ encryptedData as $ encryptedDataRow ) {
179- $ writeConnection ->update (
180- $ table ,
181- ['cc_number_enc ' => $ encryptCallback ($ decryptCallback ($ encryptedDataRow ['cc_number_enc ' ]))],
182- ['payment_id = ? ' => $ encryptedDataRow ['payment_id ' ]],
183- );
184- }
185-
186- $ select = $ readConnection ->select ()
187- ->from ($ table )
188- ->where ('cc_cid_enc IS NOT NULL ' );
189- $ encryptedData = $ readConnection ->fetchAll ($ select );
190- foreach ($ encryptedData as $ encryptedDataRow ) {
191- $ writeConnection ->update (
192- $ table ,
193- ['cc_cid_enc ' => $ encryptCallback ($ decryptCallback ($ encryptedDataRow ['cc_cid_enc ' ]))],
194- ['payment_id = ? ' => $ encryptedDataRow ['payment_id ' ]],
195- );
196- }
197-
170+ Mage::helper ('core ' )->recryptTable (
171+ Mage::getSingleton ('core/resource ' )->getTableName ('sales_flat_quote_payment ' ),
172+ 'payment_id ' ,
173+ ['cc_number_enc ' , 'cc_cid_enc ' ],
174+ $ encryptCallback ,
175+ $ decryptCallback ,
176+ );
198177 $ output ->writeln ('OK ' );
199178
200179 $ output ->write ('Re-encrypting data on sales_flat_order_payment table... ' );
201- $ table = Mage::getSingleton ('core/resource ' )->getTableName ('sales_flat_order_payment ' );
202-
203- $ select = $ readConnection ->select ()
204- ->from ($ table )
205- ->where ('cc_number_enc IS NOT NULL ' );
206- $ encryptedData = $ readConnection ->fetchAll ($ select );
207- foreach ($ encryptedData as $ encryptedDataRow ) {
208- $ writeConnection ->update (
209- $ table ,
210- ['cc_number_enc ' => $ encryptCallback ($ decryptCallback ($ encryptedDataRow ['cc_number_enc ' ]))],
211- ['entity_id = ? ' => $ encryptedDataRow ['entity_id ' ]],
212- );
213- }
214-
180+ Mage::helper ('core ' )->recryptTable (
181+ Mage::getSingleton ('core/resource ' )->getTableName ('sales_flat_order_payment ' ),
182+ 'entity_id ' ,
183+ ['cc_number_enc ' , 'cc_cid_enc ' ],
184+ $ encryptCallback ,
185+ $ decryptCallback ,
186+ );
215187 $ output ->writeln ('OK ' );
216188 }
217189}
0 commit comments