Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate CiviGrant component to an extension #22064

Merged
merged 10 commits into from
Jan 11, 2022

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Nov 12, 2021

Overview

This a straight port of CiviGrant to be packaged as an Extension instead of a Component. All the functionality is the same aside from how it's enabled or disabled in the UI.

Before

Enable or disable CiviGrant through Administer -> System Settings -> Components. As a component it cannot be uninstalled.

After

Enable, disable or uninstall CiviGrant through Administer -> System Settings -> Extensions. As an extension it can be uninstalled, which completely removes grant data from the database.

For existing sites, the extension will be automatically installed as either "enabled" or "disabled" depending on the status of the component.

For new sites, the extension is not installed by default.

@civibot
Copy link

civibot bot commented Nov 12, 2021

(Standard links)

@civibot civibot bot added the master label Nov 12, 2021
@colemanw colemanw force-pushed the civigrant branch 2 times, most recently from 001cd4b to 0fd1ed2 Compare November 16, 2021 03:07
@seamuslee001
Copy link
Contributor

mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1146 (42S02) at line 3795: Table 'core220642fa2jcivi_z4j89.civicrm_grant' doesn't exist

@JoeMurray
Copy link
Contributor

@monishdeb could you do a review of this. Please include how this impacts extensions like Grant Application Pages, Grant Programs. I think there may be a profile edit one, and at least one financial regarding Sage Intacct. What is of interest and unlikely to be found is breakage of related extensions when CiviGrant is changed from Component to Extension. I'd focus on calls and installs. If related extensions need to check for enabled status of CiviGrant as an extension now that is fine.

@monishdeb
Copy link
Member

monishdeb commented Nov 25, 2021

@colemanw when I tried to install the civigrant extension on a clean setup I got this error:

Screenshot 2021-11-25 at 5 41 38 PM

Nov 25 12:06:33  [info] $ManagedEntities_failed = Array
(
    [entity] => OptionValue
    [action] => create
    [params] => Array
        (
            [version] => 4
            [values] => Array
                (
                    [option_group_id.name] => grant_status
                    [label] => Submitted
                    [value] => 1
                    [name] => Submitted
                    [grouping] => 
                    [filter] => 0
                    [is_default] => 1
                    [weight] => 1
                    [description] => 
                    [is_optgroup] => 
                    [is_reserved] => 
                    [is_active] => 1
                    [icon] => 
                    [color] => 
                    [component_id] => 
                    [domain_id] => 
                    [visibility_id] => 
                )

            [checkPermissions] => 
        )

    [result] => Array
        (
            [fields] => Array
                (
                    [0] => option_group_id
                )

            [error_code] => mandatory_missing
            [entity] => OptionValue
            [action] => create
            [is_error] => 1
            [error_message] => Mandatory values missing from Api4 OptionValue::create: option_group_id
        )

)

Have you encountered this strange error earlier?

@colemanw
Copy link
Member Author

@monishdeb I just tried it myself and was able to run it without error. I ran setup to generate a fresh database based on this branch to avoid conflicts:

git checkout civigrant
./bin/setup.sh
cv en civigrant

I also just made some additional fixes and force-pushed this branch. 3 things are still not working as they should:

  1. Advanced search / Find grants
  2. The contact summary tab (which is based on the same search code)
  3. Reports

@colemanw colemanw force-pushed the civigrant branch 5 times, most recently from 17b9c8e to d02b9b7 Compare November 29, 2021 19:04
'update' => 'unmodified',
'params' => [
'version' => 4,
'values' => [
Copy link
Member

@monishdeb monishdeb Dec 8, 2021

Choose a reason for hiding this comment

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

@colemanw shouldn't the parameters declared directly under params not under values ?

Copy link
Member Author

@colemanw colemanw Dec 8, 2021

Choose a reason for hiding this comment

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

@monishdeb - no because APIv4 structures it this way. civicrm_api4('OptionValue', 'create', ['values' => [...]])

@monishdeb
Copy link
Member

@colemanw I have rebased the PR. However I have one concern on the mgd file. Can you please take a look ?

@colemanw
Copy link
Member Author

colemanw commented Dec 8, 2021

@monishdeb we'll have to rebase this again and move the upgrade code to 5.46. That'll be easier after merging #22224

@monishdeb
Copy link
Member

I have reviewed and marked #22224 with MoP. Reviewed the current PR in my local setup, everything works fine. Tested by submitting new Grant from and didn't encounter any issue

@colemanw
Copy link
Member Author

colemanw commented Dec 8, 2021

@monishdeb did you test all of these?

  • Advanced Search
  • Grants tab on contact summary screen
  • Grant reports

@colemanw
Copy link
Member Author

colemanw commented Dec 9, 2021

@monishdeb I've got this rebased again to use the 5.46 upgrader. But I think search/reports still need testing per my above comment.

@monishdeb
Copy link
Member

@colemanw yep my bad ... I missed the advanced search, reports . Will update the PR shortly with search fixes.

@colemanw
Copy link
Member Author

colemanw commented Dec 9, 2021

Sounds good @monishdeb - FYI you'll have to reset your local branch because of the rebasing I just did.

'import' => TRUE,
'where' => 'civicrm_grant.application_received_date',
'export' => TRUE,
'table_name' => 'civicrm_grant',
'entity' => 'Grant',
'bao' => 'CRM_Grant_BAO_Grant',
'bao' => 'CRM_Grant_DAO_Grant',
Copy link
Contributor

Choose a reason for hiding this comment

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

@colemanw any reason why this is being changed from the BAO to DAO?

Copy link
Member Author

Choose a reason for hiding this comment

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

🤷 GenCode wanted to...

Insert and then delete CiviGrant to avoid messing up legacy code with expectations of component IDs.
…table in core

Removes CiviGrant from hardcoded lists when possible, or at least puts up
guards to check that it's available before attempting to use it.
This fixes up the `CRM_Contact_BAO_Query_Interface` class which had incorrectly
omitted `static` from some static functions.

Adds defaultReurnProperties to search hook interface.
Disable & delete component, install extension as either "enabled" or "disabled" depending on the status of the component.
Migrate option values to managed entities
Migrate navigation menu to extension managed entities
@colemanw colemanw force-pushed the civigrant branch 2 times, most recently from 9159fc0 to 29d2ce6 Compare January 10, 2022 19:55
@colemanw colemanw marked this pull request as ready for review January 10, 2022 19:55
@colemanw
Copy link
Member Author

retest this please

@eileenmcnaughton
Copy link
Contributor

I chatted with @colemanw and as

  1. we are early in the release cycle and
  2. this PR has gotten stale a lot and
  3. a lot of work has gone into it

I'm merging after a light 'click around' and we should continue to QA during the release cycle.

@colemanw told me there is still a report issue - although I didn't spot it when I ran the report just now (as demo user). However I did spot a couple of things

  1. permissin incongruities - as demo user I could enable the extension but obvoulsy have a permission deficit as I could not
  • click on the contact grants tab without error
  • see civigrant menu items such as add & search
    But I COULD
  • see the grants tab that I couldn't click on
  • search for grants in advanced search
  • access civi reports
  1. demo site set up - once the above is sorted we should ensure civigrant is enabled & demo user has access on demo sites

FYI @seamuslee001 @demeritcowboy

@eileenmcnaughton eileenmcnaughton merged commit e50b42b into civicrm:master Jan 11, 2022
@eileenmcnaughton eileenmcnaughton deleted the civigrant branch January 11, 2022 02:09
@MegaphoneJon
Copy link
Contributor

MegaphoneJon commented Mar 11, 2022

The changes to CRM_Contact_BAO_Query_Interface - adding defaultReturnProperties() and setting from(), select(), and where() as static - breaks any Civi install with an extension that implements hook_civicrm_queryObjects. I'm not sure there's anything to be done now except to submit PRs to extensions though.

@eileenmcnaughton
Copy link
Contributor

@MegaphoneJon I would be OK reverting - but I worry that extensions may have already adapted so that could break them....

Note it is implementing CRM_Contact_BAO_Query_Interface not the hook that is the issue (although probably both are done together). If I were maintaining an extension I'd probaly remove the extends though so it works on before & after

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants