pantheon-systems / pantheon-advanced-page-cache

Plugin to make the most of Pantheon's Global CDN with advanced page caching options.
https://wordpress.org/plugins/pantheon-advanced-page-cache/
GNU General Public License v2.0
36 stars 13 forks source link

Internal server error with graphql queries #202

Closed jwuclorox closed 1 year ago

jwuclorox commented 1 year ago

After upgrading to 1.1.1, an internal server error gets thrown with the following debug message when executing a graphql query:

ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given

Likely caused by the graphql_dataloader_get_model filter passing a mixed data type, in this case array(12), but the Pantheon_Advanced_Page_Cache\Emitter::filter_graphql_dataloader_get_model method not handling that before using it to construct a ReflectionClass.

Here's a partial stack trace:

array(3) {
  [“errors”]=>
  array(1) {
    [0]=>
    array(6) {
      [“debugMessage”]=>
      string(103) “ReflectionClass::__construct(): Argument #1 ($objectOrClass) must be of type object|string, array given”
      [“message”]=>
      string(21) “Internal server error”
      [“extensions”]=>
      array(1) {
        [“category”]=>
        string(8) “internal”
      }
      [“locations”]=>
      array(1) {
        [0]=>
        array(2) {
          [“line”]=>
          int(4)
          [“column”]=>
          int(9)
        }
      }
      [“path”]=>
      array(2) {
        [0]=>
        string(4) “cart”
        [1]=>
        string(8) “contents”
      }
      [“trace”]=>
      array(47) {
        [0]=>
        array(3) {
          [“file”]=>
          string(74) “/app/wp-content/plugins/pantheon-advanced-page-cache/inc/class-emitter.php”
          [“line”]=>
          int(388)
          [“call”]=>
          string(39) “ReflectionClass::__construct(array(12))”
        }
        [1]=>
        array(3) {
          [“file”]=>
          string(34) “/app/wp-includes/class-wp-hook.php”
          [“line”]=>
          int(310)
          [“call”]=>
          string(84) “Pantheon_Advanced_Page_Cache\Emitter::filter_graphql_dataloader_get_model(array(12))”
        }
        [2]=>
        array(3) {
          [“file”]=>
          string(27) “/app/wp-includes/plugin.php”
          [“line”]=>
          int(205)
          [“call”]=>
          string(43) “WP_Hook::apply_filters(array(12), array(4))”
        }
        [3]=>
        array(3) {
          [“file”]=>
          string(73) “/app/wp-content/plugins/wp-graphql/src/Data/Loader/AbstractDataLoader.php”
          [“line”]=>
          int(411)
          [“function”]=>
          string(163) “apply_filters(‘graphql_dataloader_get_model’, array(12), array(12), ‘f1298750ed09618717f9c10ea8d1d3b0’, instance of WPGraphQL\WooCommerce\Data\Loader\WC_Db_Loader)”
        }
        [4]=>
        array(3) {
          [“file”]=>
          string(73) “/app/wp-content/plugins/wp-graphql/src/Data/Loader/AbstractDataLoader.php”
          [“line”]=>
          int(135)
          [“call”]=>
          string(104) “WPGraphQL\Data\Loader\AbstractDataLoader::normalize_entry(array(12), ‘f1298750ed09618717f9c10ea8d1d3b0’)”
        }
        [5]=>
        array(3) {
          [“file”]=>
          string(85) “/app/wp-content/plugins/wp-graphql/src/Data/Connection/AbstractConnectionResolver.php”
          [“line”]=>
          int(417)
          [“call”]=>
          string(82) “WPGraphQL\Data\Loader\AbstractDataLoader::load(‘f1298750ed09618717f9c10ea8d1d3b0’)”
        }
        [6]=>
        array(3) {
          [“file”]=>
          string(85) “/app/wp-content/plugins/wp-graphql/src/Data/Connection/AbstractConnectionResolver.php”
          [“line”]=>
          int(768)
          [“call”]=>
          string(104) “WPGraphQL\Data\Connection\AbstractConnectionResolver::get_node_by_id(‘f1298750ed09618717f9c10ea8d1d3b0’)”
        }
        [7]=>
        array(3) {
          [“file”]=>
          string(85) “/app/wp-content/plugins/wp-graphql/src/Data/Connection/AbstractConnectionResolver.php”
          [“line”]=>
          int(1002)
          [“call”]=>
          string(65) “WPGraphQL\Data\Connection\AbstractConnectionResolver::get_nodes()”
        }
        [8]=>
        array(3) {
          [“file”]=>
          string(106) “/app/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php”
          [“line”]=>
          int(67)
          [“call”]=>
          string(91) “WPGraphQL\Data\Connection\AbstractConnectionResolver::WPGraphQL\Data\Connection\{closure}()”
        }
        [9]=>
        array(3) {
          [“file”]=>
          string(106) “/app/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromise.php”
          [“line”]=>
          int(53)
          [“call”]=>
          string(90) “GraphQL\Executor\Promise\Adapter\SyncPromise::GraphQL\Executor\Promise\Adapter\{closure}()”
        }
        [10]=>
        array(3) {
          [“file”]=>
          string(113) “/app/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/Executor/Promise/Adapter/SyncPromiseAdapter.php”
          [“line”]=>
          int(149)
          [“call”]=>
          string(56) “GraphQL\Executor\Promise\Adapter\SyncPromise::runQueue()”
        }
        [11]=>
        array(3) {
          [“file”]=>
          string(77) “/app/wp-content/plugins/wp-graphql/vendor/webonyx/graphql-php/src/GraphQL.php”
          [“line”]=>
          int(105)
          [“call”]=>
          string(103) “GraphQL\Executor\Promise\Adapter\SyncPromiseAdapter::wait(instance of GraphQL\Executor\Promise\Promise)”
        }
        [12]=>
        array(3) {
          [“file”]=>
          string(50) “/app/wp-content/plugins/wp-graphql/src/Request.php”
          [“line”]=>
          int(656)
          [“call”]=>
          string(217) “GraphQL\GraphQL::executeQuery(instance of WPGraphQL\WPSchema, ‘
    {
      cart {
        contents {
          itemCount
        }
      }
    }
‘, null, instance of WPGraphQL\AppContext, null, null, null, array(29))”
        }
        [13]=>
        array(3) {
          [“file”]=>
          string(55) “/app/wp-content/plugins/wp-graphql/access-functions.php”
          [“line”]=>
          int(75)
          [“call”]=>
          string(28) “WPGraphQL\Request::execute()”
        }
macbookandrew commented 1 year ago

I’m running into the same problem, though this error message in the wp-graphql response is really misleading:

{
  "errors": [
    {
      "debugMessage": "Class Array does not exist",
      "message": "Internal server error",
      "extensions": {
        "category": "internal"
      },
      "locations": [
        {
          "line": 10,
          "column": 7
        }
      ],
      "path": [
        "login",
        "customer",
        "downloadableItems"
      ]
    }
  ],
  // data, extensions, etc.
}
jspellman814 commented 1 year ago

Thanks for this report and the PR. We are tracking this internally as BUGS-5812. I don't have an ETA on that at the moment, though today I'll re-roll #208 so it can run against our test suite.

jspellman814 commented 1 year ago

Hodwy folks 👋 the fix from #212 has been included in the 1.2.1 release. Please upgrade and let us know if you are still experiencing issues. Thanks!

jspellman814 commented 1 year ago

We're going to close this issue, please re-open if it persists. Thank you!