Skip to content

Commit 32642e5

Browse files
committed
Revert Register Akismet Anti-Spam as a connector.
This reverts [62193]. The connector for Akismet shouldn't show up when akismet is not installed. The plugin itself can register the connecter when it is activated. Follow-up to [62193]. See #65012. Props peterwilsoncc, jorgefilipecosta, johnbillion, eclev91, desrosj, davidbaumwald, jorbin. git-svn-id: https://develop.svn.wordpress.org/trunk@62210 602fd350-edb4-49c9-b593-d223f7449a82
1 parent fd34506 commit 32642e5

File tree

5 files changed

+15
-48
lines changed

5 files changed

+15
-48
lines changed

src/wp-includes/class-wp-connector-registry.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ final class WP_Connector_Registry {
7171
* For connectors with `api_key` authentication, a `setting_name` can be provided
7272
* explicitly. If omitted, one is automatically generated using the pattern
7373
* `connectors_{$type}_{$id}_api_key`, with hyphens in the type and ID normalized
74-
* to underscores (e.g., connector type `spam_filtering` with ID `akismet` produces
75-
* `connectors_spam_filtering_akismet_api_key`). This setting name is used for the
74+
* to underscores (e.g., connector type `spam_filtering` with ID `my_plugin` produces
75+
* `connectors_spam_filtering_my_plugin_api_key`). This setting name is used for the
7676
* Settings API registration and REST API exposure.
7777
*
7878
* Registering a connector with an ID that is already registered will trigger a
@@ -110,7 +110,7 @@ final class WP_Connector_Registry {
110110
* Optional. Plugin data for install/activate UI.
111111
*
112112
* @type string $file The plugin's main file path relative to the plugins
113-
* directory (e.g. 'akismet/akismet.php' or 'hello.php').
113+
* directory (e.g. 'my-plugin/my-plugin.php' or 'hello.php').
114114
* }
115115
* }
116116
* @return array|null The registered connector data on success, null on failure.

src/wp-includes/connectors.php

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function wp_is_connector_registered( string $id ): bool {
5959
* Optional. Plugin data for install/activate UI.
6060
*
6161
* @type string $file The plugin's main file path relative to the plugins
62-
* directory (e.g. 'akismet/akismet.php' or 'hello.php').
62+
* directory (e.g. 'my-plugin/my-plugin.php' or 'hello.php').
6363
* }
6464
* }
6565
* @phpstan-return ?array{
@@ -120,7 +120,7 @@ function wp_get_connector( string $id ): ?array {
120120
* Optional. Plugin data for install/activate UI.
121121
*
122122
* @type string $file The plugin's main file path relative to the plugins
123-
* directory (e.g. 'akismet/akismet.php' or 'hello.php').
123+
* directory (e.g. 'my-plugin/my-plugin.php' or 'hello.php').
124124
* }
125125
* }
126126
* }
@@ -210,25 +210,6 @@ function _wp_connectors_init(): void {
210210
_wp_connectors_register_default_ai_providers( $registry );
211211
}
212212

213-
// Non-AI default connectors.
214-
$registry->register(
215-
'akismet',
216-
array(
217-
'name' => __( 'Akismet Anti-spam' ),
218-
'description' => __( 'Protect your site from spam.' ),
219-
'type' => 'spam_filtering',
220-
'plugin' => array(
221-
'file' => 'akismet/akismet.php',
222-
),
223-
'authentication' => array(
224-
'method' => 'api_key',
225-
'credentials_url' => 'https://akismet.com/get/',
226-
'setting_name' => 'wordpress_api_key',
227-
'constant_name' => 'WPCOM_API_KEY',
228-
),
229-
)
230-
);
231-
232213
/**
233214
* Fires when the connector registry is ready for plugins to register connectors.
234215
*
@@ -417,9 +398,9 @@ function _wp_connectors_mask_api_key( string $key ): string {
417398
* @since 7.0.0
418399
* @access private
419400
*
420-
* @param string $setting_name The option name for the API key (e.g., 'connectors_spam_filtering_akismet_api_key').
421-
* @param string $env_var_name Optional. Environment variable name to check (e.g., 'AKISMET_API_KEY').
422-
* @param string $constant_name Optional. PHP constant name to check (e.g., 'AKISMET_API_KEY').
401+
* @param string $setting_name The option name for the API key (e.g., 'connectors_spam_filtering_my_plugin_api_key').
402+
* @param string $env_var_name Optional. Environment variable name to check (e.g., 'MY_PLUGIN_API_KEY').
403+
* @param string $constant_name Optional. PHP constant name to check (e.g., 'MY_PLUGIN_API_KEY').
423404
* @return string The key source: 'env', 'constant', 'database', or 'none'.
424405
*/
425406
function _wp_connectors_get_api_key_source( string $setting_name, string $env_var_name = '', string $constant_name = '' ): string {

tests/phpunit/tests/connectors/wpConnectorsGetConnectorSettings.php

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ public function test_returns_expected_connector_keys(): void {
3737
$this->assertArrayHasKey( 'google', $connectors );
3838
$this->assertArrayHasKey( 'openai', $connectors );
3939
$this->assertArrayHasKey( 'anthropic', $connectors );
40-
$this->assertArrayHasKey( 'akismet', $connectors );
4140
$this->assertArrayHasKey( 'mock-connectors-test', $connectors );
42-
$this->assertCount( 5, $connectors );
41+
$this->assertCount( 4, $connectors );
4342
}
4443

4544
/**
@@ -57,7 +56,7 @@ public function test_each_connector_has_required_fields(): void {
5756
$this->assertArrayHasKey( 'description', $connector_data, "Connector '{$connector_id}' is missing 'description'." );
5857
$this->assertIsString( $connector_data['description'], "Connector '{$connector_id}' description should be a string." );
5958
$this->assertArrayHasKey( 'type', $connector_data, "Connector '{$connector_id}' is missing 'type'." );
60-
$this->assertContains( $connector_data['type'], array( 'ai_provider', 'spam_filtering' ), "Connector '{$connector_id}' has unexpected type '{$connector_data['type']}'." );
59+
$this->assertContains( $connector_data['type'], array( 'ai_provider' ), "Connector '{$connector_id}' has unexpected type '{$connector_data['type']}'." );
6160
$this->assertArrayHasKey( 'authentication', $connector_data, "Connector '{$connector_id}' is missing 'authentication'." );
6261
$this->assertIsArray( $connector_data['authentication'], "Connector '{$connector_id}' authentication should be an array." );
6362
$this->assertArrayHasKey( 'method', $connector_data['authentication'], "Connector '{$connector_id}' authentication is missing 'method'." );
@@ -80,16 +79,11 @@ public function test_api_key_connectors_have_setting_name_and_credentials_url():
8079
++$api_key_count;
8180

8281
$this->assertArrayHasKey( 'setting_name', $connector_data['authentication'], "Connector '{$connector_id}' authentication is missing 'setting_name'." );
83-
84-
// AI providers use the connectors_ai_{id}_api_key convention.
85-
// Non-AI connectors may use custom setting names.
86-
if ( 'ai_provider' === $connector_data['type'] ) {
87-
$this->assertSame(
88-
'connectors_ai_' . str_replace( '-', '_', $connector_id ) . '_api_key',
89-
$connector_data['authentication']['setting_name'] ?? null,
90-
"Connector '{$connector_id}' setting_name does not match expected format."
91-
);
92-
}
82+
$this->assertSame(
83+
'connectors_ai_' . str_replace( '-', '_', $connector_id ) . '_api_key',
84+
$connector_data['authentication']['setting_name'] ?? null,
85+
"Connector '{$connector_id}' setting_name does not match expected format."
86+
);
9387
}
9488

9589
$this->assertGreaterThan( 0, $api_key_count, 'At least one connector should use api_key authentication.' );

tests/phpunit/tests/rest-api/rest-settings-controller.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ public function test_get_items() {
119119
'default_ping_status',
120120
'default_comment_status',
121121
'site_icon', // Registered in wp-includes/blocks/site-logo.php
122-
'wordpress_api_key', // Registered by Akismet connector.
123122
'wp_collaboration_enabled',
124123
);
125124

tests/qunit/fixtures/wp-api-generated.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11011,12 +11011,6 @@ mockedApiResponse.Schema = {
1101111011
"PATCH"
1101211012
],
1101311013
"args": {
11014-
"wordpress_api_key": {
11015-
"title": "Akismet Anti-spam API Key",
11016-
"description": "API key for the Akismet Anti-spam connector.",
11017-
"type": "string",
11018-
"required": false
11019-
},
1102011014
"title": {
1102111015
"title": "Title",
1102211016
"description": "Site title.",
@@ -14550,7 +14544,6 @@ mockedApiResponse.CommentModel = {
1455014544
};
1455114545

1455214546
mockedApiResponse.settings = {
14553-
"wordpress_api_key": "",
1455414547
"title": "Test Blog",
1455514548
"description": "",
1455614549
"url": "http://example.org",

0 commit comments

Comments
 (0)