Skip to content

Commit 57800b4

Browse files
feat: HPOS support added. (#748)
* feat: HPOS support added. * fix: Refund connections and connection permission fixed * chore: Linter compliance met. * devops: CI script updated. * devops: CI script updated. * fix: Syntax error fixed. * devops: CI script updated. * devops: CI script updated. * devops: CI script updated. * chore: PHPStan fixes started. * chore: linter compliance met. * chore: fix scanning and type-hinting for non-stubbed classes * dev: refactor Order model around WC_Abstract_Order * chore: update dev deps * devops: PHPStan and Linter compliance met. * devops: HPOS test temporarily suppressed. --------- Co-authored-by: David Levine <[email protected]>
1 parent 4ef46ac commit 57800b4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1696
-1563
lines changed

.github/workflows/continous-integration.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,21 @@ jobs:
2323
strategy:
2424
matrix:
2525
php: ['8.0', '7.4', '7.3']
26-
wordpress: ['6.0', '5.9', '5.6']
26+
wordpress: ['6.2', '6.1', '6.0']
2727
composer_version: ['v2']
2828
include:
2929
- php: '7.4'
30-
wordpress: '5.9'
30+
wordpress: '6.2'
3131
coverage: '--coverage --coverage-xml'
3232
xdebug: 1
3333
- php: '7.3'
34-
wordpress: '5.6'
34+
wordpress: '6.1'
3535
debug: '--debug'
36+
- wordpress: '6.2'
37+
hpos: 0
3638

3739
fail-fast: false
38-
name: WordPress ${{ matrix.wordpress }} on PHP ${{ matrix.php }}
40+
name: Running Automated Tests w/ WPBrowser in WordPress v${{ matrix.wordpress }} on PHP${{ matrix.php }} ${{ matrix.hpos == 1 && 'with HPOS activated ' || '' }}${{ matrix.coverage == '--coverage --coverage-xml' && 'with Codecoverage ' || '' }}${{ matrix.debug == '--debug' && 'in Debug Mode ' || '' }}
3941
steps:
4042
- name: Checkout
4143
uses: actions/checkout@v2
@@ -54,12 +56,12 @@ jobs:
5456
composer install
5557
WP_VERSION=${{ matrix.wordpress }} SKIP_DB_CREATE=true SKIP_WP_SETUP=true composer installTestEnv
5658
57-
- name: Run Tests w/ Docker.
59+
- name: Run Tests.
5860
env:
5961
USING_XDEBUG: ${{ matrix.xdebug }}
6062
WP_VERSION: ${{ matrix.wordpress }}
6163
PHP_VERSION: ${{ matrix.php }}
62-
run: FILTER="${{ matrix.coverage }} ${{ matrix.debug }}" composer dRunTestStandalone
64+
run: HPOS="${{ matrix.hpos }}" FILTER="${{ matrix.coverage }} ${{ matrix.debug }}" composer dRunTestStandalone
6365

6466
- name: Push Codecoverage to Coveralls.io
6567
if: ${{ matrix.coverage == '--coverage --coverage-xml' && env.STRIPE_API_PUBLISHABLE_KEY != null }}

.github/workflows/lint-code.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ on:
1515
jobs:
1616
Coding-Standards:
1717
runs-on: ubuntu-latest
18-
name: "Linting WooGraphQL code with PHPCS"
18+
name: "Linting WooGraphQL code w/ PHPCS"
1919
steps:
2020
- name: Checkout
2121
uses: actions/checkout@v1

bin/_lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ install_wordpress() {
3939
wpackagist-plugin/woocommerce-gateway-stripe \
4040
wpackagist-plugin/wp-graphql \
4141
wpackagist-theme/twentytwentyone \
42-
wp-cli/wp-cli-bundle
42+
wp-cli/wp-cli-bundle:*
4343
}
4444

4545
remove_wordpress() {

codeception.dist.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ coverage:
2020
exclude:
2121
- 'local/*'
2222
- 'vendor/*'
23-
- 'includes/utils/class-ql-session-handler.php'
24-
- 'class-woographql-inflect.php'
2523
- 'wp-graphql-woocommerce.php'
2624
show_only_summary: false
2725
extensions:

composer.lock

Lines changed: 17 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ services:
8989
WORDPRESS_DOMAIN: localhost
9090
WP_SITEURL: http://localhost
9191
WP_HOME: http://localhost
92+
HPOS: ${HPOS:-}
9293
command: ./setup-database.sh testing codecept run ${FILTER:-}
9394
networks:
9495
testing:

includes/admin/class-general.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ public static function get_other_nonce_values( $excluded ) {
3939
*/
4040
public static function get_fields() {
4141
$custom_endpoint = apply_filters( 'woographql_authorizing_url_endpoint', null );
42-
$enabled_authorizing_url_fields = array_keys( woographql_setting( 'enable_authorizing_url_fields', [] ) );
42+
$enabled_authorizing_url_fields = woographql_setting( 'enable_authorizing_url_fields', [] );
43+
$enabled_authorizing_url_fields = ! empty( $enabled_authorizing_url_fields ) ? array_keys( $enabled_authorizing_url_fields ) : [];
4344
$all_urls_checked = apply_filters(
4445
'woographql_enabled_authorizing_url_fields',
4546
[

includes/class-core-schema-filters.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,6 @@ public static function add_filters() {
8585
3
8686
);
8787

88-
add_filter(
89-
'graphql_post_object_connection_query_args',
90-
[ '\WPGraphQL\WooCommerce\Connection\Orders', 'post_object_connection_query_args' ],
91-
10,
92-
5
93-
);
94-
9588
add_filter(
9689
'graphql_map_input_fields_to_wp_query',
9790
[ '\WPGraphQL\WooCommerce\Connection\Coupons', 'map_input_fields_to_wp_query' ],
@@ -106,13 +99,6 @@ public static function add_filters() {
10699
7
107100
);
108101

109-
add_filter(
110-
'graphql_map_input_fields_to_wp_query',
111-
[ '\WPGraphQL\WooCommerce\Connection\Orders', 'map_input_fields_to_wp_query' ],
112-
10,
113-
7
114-
);
115-
116102
add_filter(
117103
'graphql_map_input_fields_to_wp_user_query',
118104
[ '\WPGraphQL\WooCommerce\Connection\Customers', 'map_input_fields_to_wp_query' ],

includes/class-wp-graphql-woocommerce.php

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ private function includes() {
164164
require $include_directory_path . 'model/class-product.php';
165165
require $include_directory_path . 'model/class-product-variation.php';
166166
require $include_directory_path . 'model/class-order.php';
167-
require $include_directory_path . 'model/class-refund.php';
168167
require $include_directory_path . 'model/class-order-item.php';
169168
require $include_directory_path . 'model/class-shipping-method.php';
170169
require $include_directory_path . 'model/class-tax-rate.php';
@@ -176,8 +175,10 @@ private function includes() {
176175

177176
// Include connection resolver trait/class files.
178177
require $include_directory_path . 'data/connection/trait-wc-db-loader-common.php';
178+
require $include_directory_path . 'data/connection/trait-wc-cpt-loader-common.php';
179179
require $include_directory_path . 'data/connection/class-cart-item-connection-resolver.php';
180180
require $include_directory_path . 'data/connection/class-downloadable-item-connection-resolver.php';
181+
require $include_directory_path . 'data/connection/class-order-connection-resolver.php';
181182
require $include_directory_path . 'data/connection/class-order-item-connection-resolver.php';
182183
require $include_directory_path . 'data/connection/class-payment-gateway-connection-resolver.php';
183184
require $include_directory_path . 'data/connection/class-product-attribute-connection-resolver.php';
@@ -186,11 +187,8 @@ private function includes() {
186187
require $include_directory_path . 'data/connection/class-variation-attribute-connection-resolver.php';
187188

188189
// Include deprecated resolver trait/class files.
189-
require $include_directory_path . 'data/connection/trait-wc-cpt-loader-common.php';
190190
require $include_directory_path . 'data/connection/class-coupon-connection-resolver.php';
191191
require $include_directory_path . 'data/connection/class-product-connection-resolver.php';
192-
require $include_directory_path . 'data/connection/class-refund-connection-resolver.php';
193-
require $include_directory_path . 'data/connection/class-order-connection-resolver.php';
194192
require $include_directory_path . 'data/connection/class-customer-connection-resolver.php';
195193

196194
// Include mutation processor class files.
@@ -203,6 +201,10 @@ private function includes() {
203201
// Include factory class file.
204202
require $include_directory_path . 'data/class-factory.php';
205203

204+
// Include DB hooks class files.
205+
require $include_directory_path . 'data/cursor/class-cot-cursor.php';
206+
require $include_directory_path . 'data/class-db-hooks.php';
207+
206208
// Include enum type class files.
207209
require $include_directory_path . 'type/enum/class-backorders.php';
208210
require $include_directory_path . 'type/enum/class-cart-error-type.php';
@@ -378,14 +380,23 @@ function () {
378380
}//end if
379381
}
380382

383+
/**
384+
* Returns true if any authorizing urls are enabled.
385+
*
386+
* @return array
387+
*/
388+
public static function get_enabled_auth_urls() {
389+
return woographql_setting( 'enable_authorizing_url_fields', [] );
390+
}
391+
381392
/**
382393
* Returns true if any authorizing urls are enabled.
383394
*
384395
* @return bool
385396
*/
386397
public static function auth_router_is_enabled() {
387398
return defined( 'WPGRAPHQL_WOOCOMMERCE_ENABLE_AUTH_URLS' )
388-
|| ! empty( array_keys( woographql_setting( 'enable_authorizing_url_fields', [] ) ) );
399+
|| ! empty( self::get_enabled_auth_urls() );
389400
}
390401

391402
/**
@@ -407,6 +418,9 @@ private function setup() {
407418
// Initialize WooGraphQL Settings.
408419
new Admin();
409420

421+
// Initialize WooGraphQL DB hooks.
422+
new Data\DB_Hooks();
423+
410424
// Setup minor integrations.
411425
Functions\setup_minor_integrations();
412426

0 commit comments

Comments
 (0)