Skip to content

Commit 48e31e7

Browse files
committed
Merge branch 'release/4.50.2'
2 parents 1253896 + 1752aa4 commit 48e31e7

File tree

8 files changed

+37
-25
lines changed

8 files changed

+37
-25
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "ricardomartins/pagbank-woocommerce",
33
"description": "Integração PagBank (PagSeguro) WooCommerce com desconto nas taxas oficiais",
44
"type": "wordpress-plugin",
5-
"version": "4.50.1",
5+
"version": "4.50.2",
66
"license": "GPL-3.0",
77
"autoload": {
88
"psr-4": {

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Donate link: https://github.com/sponsors/r-martins
55
Requires at least: 4.0
66
Tested up to: 6.9
77
Requires PHP: 7.4
8-
Stable tag: 4.50.1
8+
Stable tag: 4.50.2
99
License: GPLv3
1010
License URI: https://www.gnu.org/licenses/gpl-3.0.html
1111
PagBank com PIX, Cartão de Crédito, Boleto, Recorrência + Envio Fácil e com Menos Taxas no PagSeguro.
@@ -239,6 +239,9 @@ A confirmação é exibida ainda na tela de sucesso, e pode opcionalmente dispar
239239
Sim! Você pode [configurar descontos percentuais ou fixos](https://ajuda.pbintegracoes.com/hc/pt-br/articles/19945430928909-Oferecer-Desconto-Pix-e-Boleto) para PIX e Boleto diretamente nas configurações do plugin.
240240

241241
== Changelog ==
242+
= 4.50.2 =
243+
* Correção: erro fatal poderia ocorrer em versões do Woo anteriores a 7.1 ao verificarmos se o HPOS estava ativo.
244+
242245
= 4.50.1 =
243246
* Removidas mensagens desnecessárias dos logs relacionados ao split de pagamentos e dokan que eram exibidas no log mesmo sem tais recursos estarem em uso/ativos
244247
* Correção: em alguns cenários de race conditions, pedidos vindos de assinaturas poderiam ser gerados em duplicidade, especialmente em lojas que não configuraram o cron corretamente.

rm-pagbank.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Plugin Name: PagBank Connect
1212
* Plugin URI: https://pbintegracoes.com
1313
* Description: Integra seu WooCommerce com as APIs PagSeguro v4 através da aplicação de Ricardo Martins (com descontos nas taxas oficiais), com suporte a PIX transparente e muito mais.
14-
* Version: 4.50.1
14+
* Version: 4.50.2
1515
* Requires at least: 5.2
1616
* Tested up to: 6.9
1717
* Requires PHP: 7.4
@@ -33,7 +33,7 @@
3333
defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
3434

3535
// Plugin constants.
36-
define( 'WC_PAGSEGURO_CONNECT_VERSION', '4.50.0' );
36+
define( 'WC_PAGSEGURO_CONNECT_VERSION', '4.50.2' );
3737
define( 'WC_PAGSEGURO_CONNECT_PLUGIN_FILE', __FILE__ );
3838
define( 'WC_PAGSEGURO_CONNECT_BASE_DIR', __DIR__ );
3939
define( 'WC_PAGSEGURO_CONNECT_TEMPLATES_DIR', WC_PAGSEGURO_CONNECT_BASE_DIR . '/src/templates/' );

src/Connect.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ public static function configInfo(): void
261261
],
262262
],
263263
'extra' => [
264-
'hpos_enabled' => wc_get_container()->get(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled() ? 'yes' : 'no',
264+
'hpos_enabled' => Functions::isHposEnabled() ? 'yes' : 'no',
265265
'litespeed_cache' => is_plugin_active('litespeed-cache/litespeed-cache.php') ? 'yes' : 'no',
266266
'wordfence_active' => is_plugin_active('wordfence/wordfence.php') ? 'yes' : 'no',
267267
'cron_ok' => defined('DISABLE_WP_CRON') && DISABLE_WP_CRON ? 'yes' : 'no',
@@ -671,7 +671,7 @@ public static function checkPixOrderKeys()
671671

672672
//get the pix key from the last pix order
673673
// Check if HPOS is enabled
674-
if (wc_get_container()->get(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled()) {
674+
if (Functions::isHposEnabled()) {
675675
// HPOS is enabled
676676
$lastPixOrder = wc_get_orders([
677677
'limit' => 1,

src/Connect/Recurring.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,7 @@ protected function getUserRecurringOrders(int $userId = null)
17351735
{
17361736
$userId = $userId ?? get_current_user_id();
17371737
// Check if HPOS is enabled
1738-
if (wc_get_container()->get(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled()) {
1738+
if (Functions::isHposEnabled()) {
17391739
return wc_get_orders([
17401740
'customer_id' => $userId,
17411741
'limit' => -1,
@@ -1980,7 +1980,7 @@ public static function removeSubscriptionSandbox($orders)
19801980
*/
19811981
public static function getSandboxInitialOrders()
19821982
{
1983-
if (wc_get_container()->get(\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class)->custom_orders_table_usage_is_enabled()) {
1983+
if (Functions::isHposEnabled()) {
19841984
return wc_get_orders([
19851985
'limit' => -1,
19861986
'relation' => 'AND',

src/Connect/Recurring/Admin/Reports/Block/RecurringsReport.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,7 @@ public static function output()
7070
", $date_filter));
7171

7272
// Detect HPOS
73-
$is_hpos = false;
74-
try {
75-
$is_hpos = wc_get_container()->get(
76-
\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class
77-
)->custom_orders_table_usage_is_enabled();
78-
} catch (\Exception $e) {
79-
// HPOS not available or error checking
80-
$is_hpos = false;
81-
}
73+
$is_hpos = \RM_PagBank\Helpers\Functions::isHposEnabled();
8274

8375
if ($is_hpos) {
8476
// HPOS: fetch data from wp_wc_orders and wp_wc_order_addresses

src/Connect/Recurring/Admin/Subscriptions/SubscriptionList.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ private function get_order_ids_by_email($email)
174174
global $wpdb;
175175

176176
// Check if HPOS is enabled
177-
if (class_exists('\Automattic\WooCommerce\Utilities\OrderUtil') &&
178-
\Automattic\WooCommerce\Utilities\OrderUtil::custom_orders_table_usage_is_enabled()) {
177+
if (\RM_PagBank\Helpers\Functions::isHposEnabled()) {
179178
// HPOS: Use wc_get_orders with billing_email parameter
180179
$orders = wc_get_orders([
181180
'billing_email' => $email,

src/Helpers/Functions.php

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,28 @@ public static function isCartflowCheckout() {
353353
return _is_wcf_checkout_type();
354354
}
355355

356+
/**
357+
* Verifica se o HPOS (High-Performance Order Storage) do WooCommerce está habilitado.
358+
* Retorna false se o container/serviço não estiver disponível (ex.: WooCommerce antigo ou não inicializado).
359+
*
360+
* @return bool
361+
*/
362+
public static function isHposEnabled(): bool
363+
{
364+
try {
365+
if (!function_exists('wc_get_container')) {
366+
return false;
367+
}
368+
$class = \Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class;
369+
if (!class_exists($class)) {
370+
return false;
371+
}
372+
return wc_get_container()->get($class)->custom_orders_table_usage_is_enabled();
373+
} catch (\Throwable $e) {
374+
return false;
375+
}
376+
}
377+
356378
/**
357379
* @return array
358380
*/
@@ -363,9 +385,7 @@ public static function getExpiredPixOrders(): array
363385
Functions::addMetaQueryFilter();
364386

365387
// Check if HPOS is enabled
366-
if (wc_get_container()->get(
367-
\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class
368-
)->custom_orders_table_usage_is_enabled()) {
388+
if (self::isHposEnabled()) {
369389
$expiredDate = strtotime(gmdate('Y-m-d H:i:s')) - $expiryMinutes * 60;
370390
return wc_get_orders([
371391
'limit' => -1,
@@ -448,9 +468,7 @@ public static function getPagBankPendingOrders(): array
448468
Functions::addMetaQueryFilter();
449469

450470
// Check if HPOS is enabled
451-
if (wc_get_container()->get(
452-
\Automattic\WooCommerce\Internal\DataStores\Orders\CustomOrdersTableController::class
453-
)->custom_orders_table_usage_is_enabled()) {
471+
if (self::isHposEnabled()) {
454472
$createdAtDate = strtotime(gmdate('Y-m-d H:i:s')) - 3600 * 24 * 7;
455473
return wc_get_orders([
456474
'limit' => -1,

0 commit comments

Comments
 (0)