Skip to content

Commit

Permalink
revert: don't disable by default / update db
Browse files Browse the repository at this point in the history
  • Loading branch information
justlevine committed Jan 23, 2024
1 parent 8ab4aa4 commit 8ee0e4c
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 50 deletions.
34 changes: 0 additions & 34 deletions activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,6 @@ function graphql_activation_callback() {
return;
}

// Run any activation scripts before updating the version.
graphql_migrate_1_20_0();

// store the current version of WPGraphQL
update_option( 'wp_graphql_version', WPGRAPHQL_VERSION );
}


/**
* Handles compatibility when updating from pre-v1.20.0 versions of WPGraphQL.
*
* @todo Remove this function in v2.0.0, when the default value for `query_analyzer_enabled` is set to `true`.
*/
function graphql_migrate_1_20_0(): void {
// If the version is already set, we don't need to do anything.
$version = get_option( 'wp_graphql_version' );
if ( ! $version ) {
return;
}

// If the previous version is higher than 1.20.0, we don't need to do anything.
if ( version_compare( $version, '1.20.0', '>=' ) ) {
return;
}

/**
* Set `query_analyzer_enabled` to `true` for preexisting installs.
*
* This is to prevent breaking changes in caching solutions that rely on the Query Analyzer, but aren't insuring that the `graphql_should_analyze_queries` filter is set to true.
*/

$graphql_settings = get_option( 'graphql_general_settings', [] );

$graphql_settings['query_analyzer_enabled'] = 'on';

update_option( 'graphql_general_settings', $graphql_settings );
}
1 change: 0 additions & 1 deletion src/Admin/Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ public function register_settings() {
true === \WPGraphQL::debug() ? '<br /><strong>' . __( 'NOTE: This setting is force enabled because GraphQL Debug Mode is enabled. ', 'wp-graphql' ) . '</strong>' : ''
),
'type' => 'checkbox',
'default' => 'off',
'disabled' => true === \WPGraphQL::debug(),
'value' => true === \WPGraphQL\Utils\QueryAnalyzer::is_enabled() ? 'on' : get_graphql_setting( 'query_analyzer_enabled', 'off' ),
],
Expand Down
15 changes: 0 additions & 15 deletions tests/wpunit/QueryAnalyzerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

use WPGraphQL\Utils\QueryAnalyzer;

use function Codeception\Extension\codecept_log;

class QueryAnalyzerTest extends \Tests\WPGraphQL\TestCase\WPGraphQLTestCase {

public $post_id;
Expand Down Expand Up @@ -51,19 +49,6 @@ public function testEnableQueryAnalyzer(): void {

$query = '{ posts { nodes { id, title } } }';

/** Test default behavior */
$this->toggle_query_analyzer( null );
$actual = QueryAnalyzer::is_enabled();
$this->assertFalse( $actual, 'Query Analyzer should be disabled by default' );

$request = graphql( ['query' => $query ], true );
$actual_response = $request->execute();
$actual_analyzer = $request->get_query_analyzer();

$this->assertFalse( $actual_analyzer->is_enabled(), 'Query Analyzer should be disabled by default' );
$this->assertFalse( $actual_analyzer->is_enabled_for_query(), 'Query Analyzer should be disabled for query' );
$this->assertArrayNotHasKey( 'queryAnalyzer', $actual_response['extensions'], 'There should be no extension output if Query Analyzer is disabled ' );

/** Test with Query Analyzer toggled on */
$this->toggle_query_analyzer( true );
$actual = QueryAnalyzer::is_enabled();
Expand Down

0 comments on commit 8ee0e4c

Please sign in to comment.