Skip to content

Conversation

@CGastrell
Copy link
Contributor

@CGastrell CGastrell commented Dec 10, 2025

This is a rebase of #44538 but decided to open a new PR so to not mess with the original changes.

Proposed changes:

  • Deprecates the Admin::init() method in the Forms package as part of migrating away from the classic admin interface
  • Removes the call to Admin::init() from Util::init() to stop initializing the deprecated classic admin functionality
  • Migrates Google Drive export functionality from the deprecated Admin class to Contact_Form_Plugin class where it belongs
  • Adds comprehensive test coverage for:
    • Verifying Admin::init() is no longer called during initialization
    • Testing deprecation warnings are properly implemented
    • Validating export functionality delegation works correctly
    • Ensuring security validation in export methods
  • Updates Phan baseline to reflect code changes

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Does this pull request change what data or activity we track or use?

No

Testing instructions:

Test that Forms functionality still works:

  1. In your Docker environment, go to Jetpack > Forms
  2. Verify that you can still view form responses
  3. Verify that CSV export still works by clicking the "Export" button and choosing "CSV"
  4. If you have Google Drive connected, verify that Google Drive export still works

Test that deprecated code triggers warnings (optional):

  1. In your test environment with WP_DEBUG enabled, add this code to call the deprecated method:
    add_action('init', function() {
        \Automattic\Jetpack\Forms\ContactForm\Admin::init();
    });
  2. Check debug.log for deprecation warnings
  3. Remove the test code when done

Test that classic admin is no longer initialized:

  1. Run the new unit tests: jetpack test projects/packages/forms -- --filter=Util_Test
  2. Verify all tests pass, especially the new tests that check Admin::init() is not called

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. [Type] Task [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Package] Forms Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR labels Dec 10, 2025
@CGastrell CGastrell self-assigned this Dec 10, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WoA dev site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin (Jetpack), and enable the remove/forms-old-admin-2 branch.
  • To test on Simple, run the following command on your sandbox:
bin/jetpack-downloader test jetpack remove/forms-old-admin-2

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@github-actions
Copy link
Contributor

github-actions bot commented Dec 10, 2025

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ✅ Add a "[Status]" label (In Progress, Needs Review, ...).
  • ✅ Add a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Make sure to test your changes on all platforms that it applies to. You're responsible for the quality of the code you ship.
  3. You can use GitHub's Reviewers functionality to request a review.
  4. When it's reviewed and merged, you will be pinged in Slack to deploy the changes to WordPress.com simple once the build is done.

If you have questions about anything, reach out in #jetpack-developers for guidance!


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen as soon as you deploy your changes after merging this PR (PCYsg-Jjm-p2).
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly:
    • Scheduled release: January 6, 2026

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions github-actions bot added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Dec 10, 2025
@jp-launch-control
Copy link

jp-launch-control bot commented Dec 10, 2025

Code Coverage Summary

Coverage changed in 4 files.

File Coverage Δ% Δ Uncovered
projects/packages/forms/src/contact-form/class-contact-form-plugin.php 471/1438 (32.75%) -1.11% 47 💔
projects/packages/forms/src/contact-form/class-editor-view.php 0/156 (0.00%) 0.00% -1 💚
projects/packages/forms/src/contact-form/class-util.php 46/175 (26.29%) 7.64% -15 💚
projects/packages/forms/src/contact-form/class-admin.php 0/747 (0.00%) 0.00% -54 💚

Full summary · PHP report · JS report

Coverage check overridden by Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR .

@CGastrell CGastrell added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Dec 10, 2025
* @var string The nonce field name for GDrive export.
*/
private $export_nonce_field_gdrive = 'feedback_export_nonce_gdrive';

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it makes any sense to move all the Google drive logic to the Google_Drive class that was created in August? That's in forms/src/services/.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it would? But I'm also on the side of sticking to what we have tested and worked well. We can always follow up or find optimizations, specially in terms of code readability and organization. I just wanted to stay as simple as possible, after all, this is janitorial and not meant to take so much of us.

That said, feel free to push changes and add tests or test instructions. Or create a PR branching out of this one if that helps as a "follow up reminder".

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR deprecates the classic Admin initialization in the Forms package by removing the Admin::init() call from Util::init() and migrating the Google Drive export functionality to the Contact_Form_Plugin class. The changes improve code organization by centralizing export functionality and fix a bug in Google Drive export where array indices weren't checked before access.

Key changes:

  • Removed Admin::init() call from Util::init() to stop initializing deprecated classic admin functionality
  • Migrated export_to_gdrive() method from Admin class to Contact_Form_Plugin with improved array handling
  • Added comprehensive test coverage validating the deprecation and migration

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
projects/packages/forms/src/contact-form/class-util.php Removes the conditional call to Admin::init() to stop initializing classic admin functionality
projects/packages/forms/src/contact-form/class-admin.php Marks init() and export_to_gdrive() as deprecated with delegation to new implementation; removes AJAX handler registrations for export functions
projects/packages/forms/src/contact-form/class-contact-form-plugin.php Adds export_to_gdrive() method with improved array index checking and registers AJAX handler for Google Drive export
projects/packages/forms/src/contact-form/class-editor-view.php Removes unnecessary removal of Admin media button action since Admin is no longer initialized
projects/packages/forms/tests/php/contact-form/Util_Test.php Adds comprehensive tests for Admin deprecation, hook registration validation, export delegation, and security checks
projects/packages/forms/.phan/baseline.php Updates Phan baseline to reflect deprecated function usage in tests and removed type mismatch suppression
projects/packages/forms/changelog/remove-forms-old-admin Adds changelog entry for Forms package marking change as major/removed
projects/plugins/jetpack/changelog/remove-forms-old-admin Adds changelog entry for Jetpack plugin marking change as major/bugfix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 86 to 89

add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
add_action( 'admin_footer-edit.php', array( $this, 'print_export_modal' ) );

add_action( 'wp_ajax_grunion_export_to_gdrive', array( $this, 'export_to_gdrive' ) );
add_action( 'wp_ajax_grunion_gdrive_connection', array( $this, 'test_gdrive_connection' ) );
}
Copy link

Copilot AI Dec 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the wp_ajax_grunion_gdrive_connection action registration breaks the Google Drive connection polling functionality. The JavaScript code in grunion-admin.js (line 219) still calls this AJAX action via startPollingConnection(), but the endpoint is no longer registered.

This action handler should be migrated to Contact_Form_Plugin class (similar to how export_to_gdrive was migrated), and the test_gdrive_connection method should either be migrated or deprecated with delegation.

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@CGastrell - I'm curious about this too. Do/will we still need the logic and hook for test_gdrive_connection?

@CGastrell CGastrell force-pushed the remove/forms-old-admin-2 branch 2 times, most recently from a602e8e to 88d3d32 Compare December 10, 2025 19:04
),
200,
JSON_UNESCAPED_SLASHES
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test results:

  • Sanity check that menu items and dashboard work as expected
  • Confirm CSV exports work
  • Confirm Google Drive exports work
  • Confirm that if I add code to call Admin::init() directly, I do get deprecation notices in debug.log
  • Confirm tests pass

Notes:

  • The PR description says "Fixes issue with CSV column array building to handle empty values properly by checking if array index exists before accessing", but I don't think the PR actually makes any changes for this?
  • The testing instructions say go to Dashboard → Feedback → Select a form... but we don't load a Feedback menu item or page anymore. If I try to load that page directly, I'm just redirected to our new forms dashboard. Also, when on our forms dashboard, you can't select a form when on the Jetpack > Forms page. So I wasn't quite sure what this was asking?

@CGastrell CGastrell merged commit 56181cc into trunk Dec 11, 2025
69 of 70 checks passed
@CGastrell CGastrell deleted the remove/forms-old-admin-2 branch December 11, 2025 12:37
@github-actions github-actions bot added this to the jetpack/15.4 milestone Dec 11, 2025
@github-actions github-actions bot removed the [Status] Needs Review This PR is ready for review. label Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Coverage tests to be added later Use to ignore the Code coverage requirement check when tests will be added in a follow-up PR [Feature] Contact Form [Package] Forms [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Tests] Includes Tests [Type] Janitorial [Type] Task

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants