Skip to content

Conversation

@ajolo2ky
Copy link
Contributor

Changes proposed in this Pull Request

This PR adds a function to create a new supporter based on a CF7 submission, gets all the fields from the form and adds a new post in Pending Review mode.

Testing instructions

Go to https://open-source-initiative-development.mystagingwebsite.com/ai/endorsements, fill in the form, a new Supporter should be created

@xpurichan xpurichan mentioned this pull request Jan 14, 2025
@gin0115
Copy link
Collaborator

gin0115 commented Jan 14, 2025

Hey

this issue seems to be related to the code, its failing based on styling and type hints (or lack of)

FILE: themes/osi/functions.php
----------------------------------------------------------------------
FOUND 22 ERRORS AND 2 WARNINGS AFFECTING 22 LINES
----------------------------------------------------------------------
 439 | ERROR   | [ ] Missing @return tag in function comment
     |         |     (Squiz.Commenting.FunctionComment.MissingReturn)
 440 | WARNING | [ ] The method parameter $contact_form is never
     |         |     used
     |         |     (Generic.CodeAnalysis.UnusedFunctionParameter.Found)
 440 | ERROR   | [ ] Type hint "WPCF7_ContactForm" missing for
     |         |     $contact_form
     |         |     (Squiz.Commenting.FunctionComment.TypeHintMissing)
 441 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 443 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 444 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 446 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 447 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 448 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 449 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 450 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 451 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 452 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 454 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 455 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 456 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 457 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 458 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 459 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 460 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 460 | WARNING | [ ] error_log() found. Debug code should not
     |         |     normally be used in production.
     |         |     (WordPress.PHP.DevelopmentFunctions.error_log_error_log)
 461 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 462 | ERROR   | [x] Tabs must be used to indent lines; spaces are
     |         |     not allowed
     |         |     (Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)
 463 | ERROR   | [x] Expected 1 newline at end of file; 0 found
     |         |     (PSR2.Files.EndFileNewline.NoneFound)
----------------------------------------------------------------------
PHPCBF CAN FIX THE [20](https://github.com/OpenSourceOrg/dotOrg/actions/runs/12720502890/job/35462242778?pr=162#step:9:21) MARKED SNIFF VIOLATIONS AUTOMATICALLY
----------------------------------------------------------------------

I can fix this tomorrow if needs be, but most of the fixes above can be fixed running composer install then composer format:php

Things like error_log() found. Debug code should not | normally be used in production. will need a comment to suppress the error, as error_log() is discouraged. Also the types are required in the

 * Save form data to a custom post type.
 *
 * @param WPCF7_ContactForm $contact_form The Contact Form 7 instance.
 *
 * @return void
 */
function save_form_data_to_cpt( $contact_form ) {

The function should also be prefixed with the osi_ (osi_save_form_data_to_cpt())

@ajolo2ky
Copy link
Contributor Author

Yes, please give it the right format when you can, I don't have composer installed on my machine. Also feel free to remove that error_log, I was just debugging, and agree it shouldn't be in production.

@gin0115
Copy link
Collaborator

gin0115 commented Jan 17, 2025

Sorry ended up AFK yesterday and now trying to fight through a growing list of small tasks, this has been done. Ive updated the format so its compliant with phpcs.

ive not deployed this YET, but will push it up on monday (ive only got 1hr left today and dont want to risk it).

@ajolo2ky
Copy link
Contributor Author

Sounds reasonable, happy ROF! :)

@gin0115 gin0115 merged commit 03bcfa8 into main Jan 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants