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

dev/core#4907 Form-layer consolidation on getting the number of spaces for the event #28984

Merged
merged 1 commit into from Jan 12, 2024

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

dev/core#4907 Form-layer consolidation on getting the number of spaces for the event

Before

CRM_Event_BAO_Participant::eventFull() is called 12 times with a mixture of parameters & a mixture of results. One of the anomalies is that sometimes it returns text rather than a number. This fixes one of those places (the event info screen) to NOT expect text to be returned (which seems like an antipattern)

After

Unchanged UI

image

Technical Details

In the medium term we want the form layer to use apiv4 to get the available_spaces. The parity is not there at the moment - partly as fixed in #28983 but there is also some other stuff going on that does give me confidence they are like for like. However, we can update the forms to call getEventValue('available_spaces') & it will use the old method for now but once we are confident we can just remove this extra temporary wrangling from this one place

I also added the getPriceSetID() function for consistency with similar forms

Comments

Copy link

civibot bot commented Jan 12, 2024

🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷

Introduction for new contributors...
  • If this is your first PR, an admin will greenlight automated testing with the command ok to test or add to whitelist.
  • A series of tests will automatically run. You can see the results at the bottom of this page (if there are any problems, it will include a link to see what went wrong).
  • A demo site will be built where anyone can try out a version of CiviCRM that includes your changes.
  • If this process needs to be repeated, an admin will issue the command test this please to rerun tests and build a new demo site.
  • Before this PR can be merged, it needs to be reviewed. Please keep in mind that reviewers are volunteers, and their response time can vary from a few hours to a few weeks depending on their availability and their knowledge of this particular part of CiviCRM.
  • A great way to speed up this process is to "trade reviews" with someone - find an open PR that you feel able to review, and leave a comment like "I'm reviewing this now, could you please review mine?" (include a link to yours). You don't have to wait for a response to get started (and you don't have to stop at one!) the more you review, the faster this process goes for everyone 😄
  • To ensure that you are credited properly in the final release notes, please add yourself to contributor-key.yml
  • For more information about contributing, see CONTRIBUTING.md.
Quick links for reviewers...

➡️ Online demo of this PR 🔗

@civibot civibot bot added the master label Jan 12, 2024
Copy link

civibot bot commented Jan 12, 2024

The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/core/-/issues/4907

@colemanw colemanw merged commit a1fd4e3 into civicrm:master Jan 12, 2024
3 checks passed
@eileenmcnaughton eileenmcnaughton deleted the event_full_info branch January 12, 2024 21:05
TRUE,
$this->getEventValue('has_waitlist')
);
return is_numeric($availableSpaces) ? (int) $availableSpaces : 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding https://lab.civicrm.org/dev/core/-/issues/4918, I think the problem is this function is trying to convert something that is inherently a mixed value into a single integer. It doesn't take into account that the available spaces could be infinite (which is not an integer, and is what NULL means here - i.e. not the same as 0).

It's true that it feels weird to have a function that sometimes returns a display string and sometimes a number, but the underlying thing is that it is truly a mixed value, of some kind.

One option is that if it's NULL, return INT_MAX. But that feels kludgy, and what if you're hosting a video party for the World Cup Final...

Copy link
Contributor

Choose a reason for hiding this comment

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

If it is available spaces (i.e. those available after previous participants have registered). you could still host your World Cup party, couldn't you? You aren't worried about the maximum number of participants, only how much space is left? Or have I misunderstood things badly?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right but this function is ALWAYS returning 0 available spaces left when you leave the maximum number of participants field blank, because CRM_Event_BAO_Participant::eventFull() returns null in that case, and then this function converts null to 0 instead of converting it to "infinity".

The World Cup reference was partly a joke, that if instead of returning infinity, because that's not an integer, you return php's highest integer, but for such an event that might not be big enough.

When I tried that though I then started seeing some problems with the confirmation page and haven't looked closer yet.

Choose a reason for hiding this comment

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

Every event has a limit to the number of participants, but in some cases you may not want to cap the number of people who register for an event.

An example is where you're using an event to track volunteer applications. You may only need 20 volunteers, but you want to select the 20 volunteers that have the best skillsets for the roles. So you would allow everyone to register their interest to volunteer for the event, and then manually identify the people who you will ask to volunteer.

Looking at the eventFull method, it returns NULL if there is no participant limit. (link) which seems like a fair result rather than 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just noting that the regression under discussion is now partially fixed and the remaining part is in https://lab.civicrm.org/dev/core/-/issues/4942

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