• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

wp-graphql / wp-graphql-woocommerce / 23228201207

18 Mar 2026 03:49AM UTC coverage: 83.184% (-0.4%) from 83.59%
23228201207

push

github

web-flow
fix: inverted logic in pop_transaction_id() causes cart session corruption (#971)

* fix: resolve REQUEST_URI fatal error and JWT key length issues in CI

QLSessionHandlerTest::tearDown() was calling unset($_SERVER) which
destroyed the entire superglobal. WordPress cron.php then fataled on
shutdown when accessing $_SERVER['REQUEST_URI']. Changed to only unset
the specific HTTP_WOOCOMMERCE_SESSION key.

Also updated JWT secret keys to meet firebase/php-jwt v7's minimum
32-byte requirement for HS256 in both test config and Docker entrypoint.

* fix: the rest of the files added

* devops: php7.4 removed from matrix

* chore: Linter compliances met

* devops: More broken test updated

* devops: Tests updated for CI

* fix: QLSessionHandlerCest fixed

* fix: QLSessionHandlerCest fixed

* devops: CI fixed

3 of 59 new or added lines in 2 files covered. (5.08%)

526 existing lines in 17 files now uncovered.

12594 of 15140 relevant lines covered (83.18%)

75.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.6
/includes/type/object/class-meta-data-type.php
1
<?php
2
/**
3
 * WPObject Type - Order_Item_Type
4
 *
5
 * Registers MetaData type and queries
6
 *
7
 * @package WPGraphQL\WooCommerce\Type\WPObject
8
 * @since   0.0.2
9
 */
10

11
namespace WPGraphQL\WooCommerce\Type\WPObject;
12

13
/**
14
 * Class Meta_Data_Type
15
 */
16
class Meta_Data_Type {
17
        /**
18
         * Register Order type and queries to the WPGraphQL schema
19
         *
20
         * @return void
21
         */
22
        public static function register() {
23
                register_graphql_object_type(
153✔
24
                        'MetaData',
153✔
25
                        [
153✔
26
                                'description' => __( 'Extra data defined on the WC object', 'wp-graphql-woocommerce' ),
153✔
27
                                'fields'      => [
153✔
28
                                        'id'    => [
153✔
29
                                                'type'        => 'ID',
153✔
30
                                                'description' => __( 'Meta ID.', 'wp-graphql-woocommerce' ),
153✔
31
                                                'resolve'     => static function ( $source ) {
153✔
32
                                                        return ! empty( $source->id ) ? $source->id : null;
1✔
33
                                                },
153✔
34
                                        ],
153✔
35
                                        'key'   => [
153✔
36
                                                'type'        => [ 'non_null' => 'String' ],
153✔
37
                                                'description' => __( 'Meta key.', 'wp-graphql-woocommerce' ),
153✔
38
                                                'resolve'     => static function ( $source ) {
153✔
39
                                                        return ! empty( $source->key ) ? (string) $source->key : null;
13✔
40
                                                },
153✔
41
                                        ],
153✔
42
                                        'value' => [
153✔
43
                                                'type'        => 'String',
153✔
44
                                                'description' => __( 'Meta value.', 'wp-graphql-woocommerce' ),
153✔
45
                                                'resolve'     => static function ( $source ) {
153✔
46
                                                        if ( empty( $source->value ) ) {
13✔
UNCOV
47
                                                                return null;
×
48
                                                        }
49

50
                                                        if ( is_array( $source->value ) || is_object( $source->value ) ) {
13✔
UNCOV
51
                                                                return wp_json_encode( $source->value );
×
52
                                                        }
53

54
                                                        return (string) $source->value;
13✔
55
                                                },
153✔
56
                                        ],
153✔
57
                                ],
153✔
58
                        ]
153✔
59
                );
153✔
60
        }
61

62
        /**
63
         * Definition/Resolution of the metaData field used across the schema.
64
         *
65
         * @return array
66
         */
67
        public static function get_metadata_field_definition() {
68
                return [
153✔
69
                        'type'        => [ 'list_of' => 'MetaData' ],
153✔
70
                        'description' => __( 'Object meta data', 'wp-graphql-woocommerce' ),
153✔
71
                        'args'        => [
153✔
72
                                'key'      => [
153✔
73
                                        'type'        => 'String',
153✔
74
                                        'description' => __( 'Retrieve meta by key', 'wp-graphql-woocommerce' ),
153✔
75
                                ],
153✔
76
                                'keysIn'   => [
153✔
77
                                        'type'        => [ 'list_of' => 'String' ],
153✔
78
                                        'description' => __( 'Retrieve multiple metas by key', 'wp-graphql-woocommerce' ),
153✔
79
                                ],
153✔
80
                                'multiple' => [
153✔
81
                                        'type'        => 'Boolean',
153✔
82
                                        'description' => __( 'Retrieve meta with matching keys', 'wp-graphql-woocommerce' ),
153✔
83
                                ],
153✔
84
                        ],
153✔
85
                        'resolve'     => static function ( $source, array $args ) {
153✔
86
                                // Set unique flag.
87
                                $single = empty( $args['multiple'] );
11✔
88

89
                                // Check "key" argument and format meta_data objects.
90
                                if ( ! empty( $args['key'] ) && $source->meta_exists( $args['key'] ) ) {
11✔
91
                                        $key  = $args['key'];
1✔
92
                                        $data = $source->get_meta( $key, false );
1✔
93
                                        if ( empty( $data ) ) {
1✔
94
                                                $data = [];
×
95
                                        } elseif ( $single ) {
1✔
96
                                                $data = array_slice( $data, 0, 1 );
1✔
97
                                        }
98

99
                                        $data = array_map(
1✔
100
                                                static function ( $value ) {
1✔
101
                                                        return (object) $value;
1✔
102
                                                },
1✔
103
                                                $data
1✔
104
                                        );
1✔
105
                                } elseif ( ! empty( $args['keysIn'] ) ) {
11✔
106
                                        // Check "keysIn" argument and format meta_data objects.
107
                                        $keys_in = $args['keysIn'];
1✔
108

109
                                        $found = [];
1✔
110
                                        $data  = array_filter(
1✔
111
                                                $source->get_meta_data(),
1✔
112
                                                static function ( $meta ) use ( $keys_in, $single, &$found ) {
1✔
113
                                                        if ( in_array( $meta->key, $keys_in, true ) ) {
1✔
114
                                                                if ( $single && in_array( $meta->key, $found, true ) ) {
1✔
115
                                                                        return false;
×
116
                                                                }
117
                                                                $found[] = $meta->key;
1✔
118
                                                                return true;
1✔
119
                                                        }
120
                                                }
1✔
121
                                        );
1✔
122
                                } else {
123
                                        // If no arguments set return all meta (in accordance with unique flag).
124
                                        $found = [];
11✔
125
                                        $data  = array_filter(
11✔
126
                                                $source->get_meta_data(),
11✔
127
                                                static function ( $meta ) use ( $single, &$found ) {
11✔
128
                                                        if ( $single && in_array( $meta->key, $found, true ) ) {
11✔
129
                                                                return false;
1✔
130
                                                        }
131

132
                                                        $found[] = $meta->key;
11✔
133
                                                        return true;
11✔
134
                                                }
11✔
135
                                        );
11✔
136
                                }//end if
137

138
                                return ! empty( $data ) ? $data : null;
11✔
139
                        },
153✔
140
                ];
153✔
141
        }
142
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc