Skip to content

Commit eeaf8da

Browse files
authored
chore!: remove old deprecations (#428)
1 parent 5ca942c commit eeaf8da

File tree

9 files changed

+4
-153
lines changed

9 files changed

+4
-153
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
- feat: Add `FieldError.connectedFormField` connection to `FieldError` type.
1414
- dev: Remove `vendor` directory from the GitHub repository.
1515
- dev: Use `FormFieldsDataLoader` to resolve fields instead of instantiating a new `Model`.
16+
- chore!: Remove deprecated fields from the schema: `FormsConnectionOrderbyInput.field`, `GfFieldWithDisableQuantitySetting.isQuantityDisabled`. `GfSubmittedEntry.entryId`. `GfForm.button`, `gfForm.entryId`, `gfForm.lastPageButton`.
17+
- chore!: Remove deprecated hooks: `graphql_gf_form_modeled_data_experimental`, `graphql_gf_form_field_setting_properties`, `graphql_gf_form_field_value_properties`.
18+
- chore!: Remove deprecated helper method: `GFUtils::handle_file_upload()`.
1619
- chore: Add iterable type hints.
1720
- chore!: Bump minimum WPGraphQL version to v1.26.0.
1821
- chore!: Bump minimum WordPress version to v6.0.0.

src/Data/Connection/FormsConnectionResolver.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ private function prepare_sort( array $args ): array {
212212
];
213213

214214
if ( ! empty( $args['where']['orderby'] ) && is_array( $args['where']['orderby'] ) ) {
215-
// @todo remove support for deprecated `field` input.
216-
if ( empty( $args['where']['orderby']['column'] ) && ! empty( $args['where']['orderby']['field'] ) ) {
217-
$args['where']['orderby']['column'] = $args['where']['orderby']['field'];
218-
}
219-
220215
$sort = [
221216
'key' => $args['where']['orderby']['column'] ?? '',
222217
'direction' => $args['where']['orderby']['order'] ?? 'ASC',

src/Model/Form.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,6 @@ static function ( $confirmation ) {
255255
'hasValidationSummary' => fn (): bool => ! empty( $this->data['validationSummary'] ),
256256
'version' => fn (): ?string => ! empty( $this->data['version'] ) ? $this->data['version'] : null,
257257
];
258-
259-
/**
260-
* Internal Filter for modifying the model.
261-
*
262-
* To be replaced by https://github.com/wp-graphql/wp-graphql/issues/2198
263-
*
264-
* @deprecated 0.11.0 use "graphql_model_prepare_fields"
265-
*/
266-
$this->fields = apply_filters_deprecated( 'graphql_gf_form_modeled_data_experimental', [ $this->fields, $this->data ], '0.11.0', 'graphql_model_prepare_fields' );
267258
}
268259
}
269260
}

src/Registry/FormFieldRegistry.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -351,22 +351,6 @@ public static function get_description( string $field_name ): string {
351351
public static function get_fields( GF_Field $field, array $settings, $interfaces ): array {
352352
$fields = [];
353353

354-
if ( has_filter( 'graphql_gf_form_field_setting_properties' ) ) {
355-
foreach ( $settings as $setting_key ) {
356-
/**
357-
* Filter to modify the Form Field GraphQL fields based on GF_Field::form_editor_field_settings().
358-
*
359-
* @deprecated 0.12.0 Use `graphql_gf_form_field_setting_fields` instead.
360-
*
361-
* @param array<string,array<string,mixed>> $fields An array of GraphQL field configs. See https://www.wpgraphql.com/functions/register_graphql_fields/
362-
* @param string $setting_key The `form_editor_field_settings()` key.
363-
* @param \GF_Field $field The Gravity Forms Field object.
364-
* @param string[] $interfaces The list of interfaces for the GraphQL type.
365-
*/
366-
$fields = apply_filters_deprecated( 'graphql_gf_form_field_setting_properties', [ $fields, $setting_key, $field ], '0.12.0', 'graphql_gf_form_field_setting_fields' );
367-
}
368-
}
369-
370354
/**
371355
* Filter to modify the Form Field GraphQL fields.
372356
*
@@ -408,11 +392,6 @@ public static function get_field_value_fields( GF_Field $field ): array {
408392
$fields += FieldValues::consent_value();
409393
break;
410394
case 'fileupload':
411-
// Deprecate values field.
412-
$values = FieldValues::values();
413-
$values['values']['deprecationReason'] = __( 'Use `fileUploadValues` instead.', 'wp-graphql-gravity-forms' );
414-
$fields += $values;
415-
416395
$fields += FieldValues::file_upload_values();
417396
break;
418397
case 'list':
@@ -441,16 +420,6 @@ public static function get_field_value_fields( GF_Field $field ): array {
441420
break;
442421
}
443422

444-
/**
445-
* Filter to modify the Form Field value GraphQL fields.
446-
*
447-
* @deprecated 0.12.0 Use `graphql_gf_form_field_value_fields` instead.
448-
*
449-
* @param array<string,array<string,mixed>> $fields An array of GraphQL field configs. See https://www.wpgraphql.com/functions/register_graphql_fields/
450-
* @param \GF_Field $field The Gravity Forms Field object.
451-
*/
452-
$fields = apply_filters_deprecated( 'graphql_gf_form_field_value_properties', [ $fields, $field ], '0.12.0', 'graphql_gf_form_field_value_fields' );
453-
454423
/**
455424
* Filter to modify the Form Field Value GraphQL fields.
456425
*

src/Type/Input/FormsConnectionOrderbyInput.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ public static function get_description(): string {
3636
*/
3737
public static function get_fields(): array {
3838
return [
39-
'field' => [
40-
'type' => 'String',
41-
'description' => __( 'The field name used to sort the results.', 'wp-graphql-gravity-forms' ),
42-
'deprecationReason' => __( 'Use the `orderBy` field instead.', 'wp-graphql-gravity-forms' ),
43-
],
4439
'column' => [
4540
'type' => FormsConnectionOrderByEnum::$type,
4641
'description' => __( 'The form column name used to sort the results.', 'wp-graphql-gravity-forms' ),

src/Type/WPInterface/FieldSetting/FieldWithDisableQuantity.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,11 @@ class FieldWithDisableQuantity extends AbstractFieldSetting {
3333
*/
3434
public static function get_fields(): array {
3535
return [
36-
'hasQuantity' => [
36+
'hasQuantity' => [
3737
'type' => 'Boolean',
3838
'description' => __( 'Whether the field has the quantity property enabled.', 'wp-graphql-gravity-forms' ),
3939
'resolve' => static fn ( $source ) => empty( $source->disableQuantity ),
4040
],
41-
'isQuantityDisabled' => [
42-
'type' => 'Boolean',
43-
'description' => __( 'Whether the quantity property should be disabled for this field.', 'wp-graphql-gravity-forms' ),
44-
'deprecationReason' => __( 'Use `hasQuantity` instead', 'wp-graphql-gravity-forms' ),
45-
'resolve' => static fn ( $source ) => ! empty( $source->disableQuantity ),
46-
],
4741
];
4842
}
4943
}

src/Type/WPObject/Entry/SubmittedEntry.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,6 @@ public static function get_description(): string {
7272
*/
7373
public static function get_fields(): array {
7474
return [
75-
'entryId' => [
76-
'type' => 'Int',
77-
'description' => __( 'The entry ID. Returns null for draft entries.', 'wp-graphql-gravity-forms' ),
78-
'deprecationReason' => __( 'Deprecated in favor of the databaseId field.', 'wp-graphql-gravity-forms' ),
79-
'resolve' => static fn ( $source ) => $source->databaseId ?? null,
80-
],
8175
'isStarred' => [
8276
'type' => 'Boolean',
8377
'description' => __( 'Indicates if the entry has been starred (i.e marked with a star).', 'wp-graphql-gravity-forms' ),

src/Type/WPObject/Form/Form.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
use WPGraphQL\GF\Type\WPInterface\Entry;
2626
use WPGraphQL\GF\Type\WPInterface\FormField;
2727
use WPGraphQL\GF\Type\WPObject\AbstractObject;
28-
use WPGraphQL\GF\Type\WPObject\Button;
2928
use WPGraphQL\GF\Utils\Utils;
3029

3130
/**
@@ -137,12 +136,6 @@ public static function get_description(): string {
137136
*/
138137
public static function get_fields(): array {
139138
return [
140-
'button' => [
141-
'type' => FormSubmitButton::$type,
142-
'description' => __( 'Contains the form button settings such as the button text or image button source.', 'wp-graphql-gravity-forms' ),
143-
'deprecationReason' => __( 'Use `submitButton` field instead', 'wp-graphql-gravity-forms' ),
144-
'resolve' => static fn ( $source ) => $source->submitButton,
145-
],
146139
'confirmations' => [
147140
'type' => [ 'list_of' => FormConfirmation::$type ],
148141
'description' => __( 'Contains the form confirmation settings such as confirmation text or redirect URL.', 'wp-graphql-gravity-forms' ),
@@ -187,12 +180,6 @@ public static function get_fields(): array {
187180
'type' => 'String',
188181
'description' => __( 'CSS class for the first page.', 'wp-graphql-gravity-forms' ),
189182
],
190-
'formId' => [
191-
'type' => 'Int',
192-
'description' => __( 'Form ID.', 'wp-graphql-gravity-forms' ),
193-
'deprecationReason' => __( 'Deprecated in favor of the databaseId field.', 'wp-graphql-gravity-forms' ),
194-
'resolve' => static fn ( $source ) => $source->databaseId,
195-
],
196183
'hasValidationSummary' => [
197184
'type' => 'Boolean',
198185
'description' => __( 'If enabled, will show a summary that lists form validation errors at the top of the form when a user attempts a failed submission.', 'wp-graphql-gravity-forms' ),
@@ -209,12 +196,6 @@ public static function get_fields(): array {
209196
'type' => Enum\FormLabelPlacementEnum::$type,
210197
'description' => __( 'Determines where the field labels should be placed in relation to the field.', 'wp-graphql-gravity-forms' ),
211198
],
212-
'lastPageButton' => [
213-
'type' => Button\FormLastPageButton::$type,
214-
'description' => __( 'Last page button data.', 'wp-graphql-gravity-forms' ),
215-
'deprecationReason' => __( 'Use `pagination.lastPageButton` instead', 'wp-graphql-gravity-forms' ),
216-
'resolve' => static fn ( $source ) => ! empty( $source->pagination ) ? $source->pagination['lastPageButton'] : null,
217-
],
218199
'login' => [
219200
'type' => FormLogin::$type,
220201
'description' => __( 'Login requirements data.', 'wp-graphql-gravity-forms' ),

src/Utils/GFUtils.php

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -437,75 +437,4 @@ public static function get_gravity_forms_upload_dir( int $form_id ): array {
437437
'baseurl' => untrailingslashit( GFFormsModel::get_upload_url_root() ),
438438
];
439439
}
440-
441-
/**
442-
* Handle custom file upload.
443-
*
444-
* This mimics WP Core upload functionality but allows for uploading file to a custom directory rather than the standard WP uploads dir.
445-
* Slightly modified from source.
446-
*
447-
* @see https://developer.wordpress.org/reference/functions/_wp_handle_upload/
448-
*
449-
* @author WebDevStudios
450-
* @source https://github.com/WebDevStudios/wds-headless-wordpress/blob/5a8e84a2dbb7a0bb537422223ab409ecd2568b00/themes/wds_headless/inc/wp-graphql.php#L452
451-
* @param array<string,mixed> $file File data to upload.
452-
* @param array<string,mixed> $target Target upload directory; WP uploads dir will be used if none provided.
453-
*
454-
* @return array{file:string,url:string,type:mixed}
455-
*
456-
* @deprecated 0.11.0
457-
*
458-
* @throws \GraphQL\Error\UserError .
459-
*/
460-
public static function handle_file_upload( $file, $target ) {
461-
_doing_it_wrong( __FUNCTION__, esc_html__( 'GFUtils::handle_file_upload() is deprecated. Please use native WP/GF methods instead.', 'wp-graphql-gravity-forms' ), '0.11.0' );
462-
463-
$target = $target ?: wp_upload_dir();
464-
465-
$wp_filetype = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'] );
466-
$ext = empty( $wp_filetype['ext'] ) ? '' : $wp_filetype['ext'];
467-
$type = empty( $wp_filetype['type'] ) ? '' : $wp_filetype['type'];
468-
$proper_filename = empty( $wp_filetype['proper_filename'] ) ? '' : $wp_filetype['proper_filename'];
469-
470-
// Check to see if wp_check_filetype_and_ext() determined the filename was incorrect.
471-
if ( ! empty( $proper_filename ) ) {
472-
$file['name'] = $proper_filename;
473-
}
474-
475-
// Return error if file type not allowed.
476-
if ( ( ! $type || ! $ext ) && ! current_user_can( 'unfiltered_upload' ) ) {
477-
throw new UserError( esc_html__( 'This file type is not permitted for security reasons.', 'wp-graphql-gravity-forms' ) );
478-
}
479-
480-
$type = empty( $type ) ? $file['type'] : $type;
481-
482-
$filename = wp_unique_filename( $target['path'], $file['name'] );
483-
484-
// Move the file to the GF uploads dir.
485-
$new_file = $target['path'] . sprintf( '/%s', $filename );
486-
487-
// Use copy and unlink because rename breaks streams.
488-
$move_new_file = @copy( $file['tmp_name'], $new_file ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged,Generic.PHP.NoSilencedErrors.Forbidden
489-
unlink( $file['tmp_name'] ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_unlink
490-
491-
if ( ! $move_new_file ) {
492-
throw new UserError( esc_html__( 'Failed to copy the file to the server.', 'wp-graphql-gravity-forms' ) );
493-
}
494-
495-
// Set correct file permissions.
496-
$stat = stat( dirname( $new_file ) );
497-
if ( is_array( $stat ) ) {
498-
$perms = $stat['mode'] & 0000666;
499-
chmod( $new_file, $perms ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.chmod_chmod
500-
}
501-
502-
// Compute the URL.
503-
$url = $target['url'] . sprintf( '/%s', $filename );
504-
505-
return [
506-
'file' => $new_file,
507-
'url' => $url,
508-
'type' => $type,
509-
];
510-
}
511440
}

0 commit comments

Comments
 (0)