Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@AlexandraLivadas
Copy link
Contributor

When \NDB_Factory::singleton()->settings()->getBaseURL() was called, an empty string was returned, so the emails sent to users when a survey is created were not displaying the correct URL. This bug fix should also solve similar errors from occurring in other modules that use the above line.

The issue occurs because the line $DB = $factory->database() is called in NDB_Cient before the baseURL for the factory object is set to the correct value in the BaseRouter using setBaseURL. The database() function constructs the factory's static Settings object with an empty baseURL, so the baseURL ends up being an empty string instead of the correct value. This bug is fixed by adding the line $factory->reset() before setting the URL, which resets the Settings object and its variables.

Testing instructions (if applicable)

For the survey account module

  1. Go to the Survey Accounts page and add a new survey
  2. Include an email address and select "Email Survey"
  3. Check that the email contains a clickable link that directs you to the correct survey

For the bug in general:
To see that the line \NDB_Factory::singleton()->settings()->getBaseURL() works correctly throughout the codebase, you can add an error_log message anywhere it is used and see that it returns the base URL for your Loris instance.

Link to related issue

@AlexandraLivadas AlexandraLivadas added Category: Bug PR or issue that aims to report or fix a bug 24.0.0-bugs Issues or bug fix PRs that were raised during the testing of release 24.0.0 labels Nov 8, 2021
@driusan driusan added the Critical to release PR or issue is key for the release to which it has been assigned label Nov 9, 2021
@ridz1208 ridz1208 self-assigned this Nov 9, 2021
$request = $request->withAttribute("baseurl", $baseurl->__toString());

// Reset factory object so that the base URL can be reset
$factory->reset();
Copy link
Collaborator

@ridz1208 ridz1208 Nov 10, 2021

Choose a reason for hiding this comment

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

@AlexandraLivadas What's the value of the baseURL before the reset ??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The value is an empty string

Copy link
Collaborator

Choose a reason for hiding this comment

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

@AlexandraLivadas reset() will clear important values along with the settings singleton that we need cleared at this point. this is too risky.

What I think would be better is to reset the settings variable directly in NDB_Factory::setBaseURL() function. so directly in that function, set the settings to null and next time it is instanciated it will have the correct value.

Please try that change and test it and if all is good I'll pass review

$request = $request->withAttribute("baseurl", $baseurl->__toString());

// Reset factory object so that the base URL can be reset
$factory->reset();
Copy link
Collaborator

Choose a reason for hiding this comment

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

@AlexandraLivadas reset() will clear important values along with the settings singleton that we need cleared at this point. this is too risky.

What I think would be better is to reset the settings variable directly in NDB_Factory::setBaseURL() function. so directly in that function, set the settings to null and next time it is instanciated it will have the correct value.

Please try that change and test it and if all is good I'll pass review

Copy link
Collaborator

@ridz1208 ridz1208 left a comment

Choose a reason for hiding this comment

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

Code looks good

@ridz1208 ridz1208 assigned suzanne-lee and unassigned ridz1208 Nov 11, 2021
@suzanne-lee suzanne-lee added the Passed manual tests PR has been successfully tested by at least one peer label Nov 11, 2021
@driusan driusan merged commit 33d76d1 into aces:main Nov 11, 2021
@ridz1208 ridz1208 added this to the 24.0.0 milestone Nov 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

24.0.0-bugs Issues or bug fix PRs that were raised during the testing of release 24.0.0 Category: Bug PR or issue that aims to report or fix a bug Critical to release PR or issue is key for the release to which it has been assigned Passed manual tests PR has been successfully tested by at least one peer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[survey_accounts] Survey Email does not contain clickable link

4 participants