-
Notifications
You must be signed in to change notification settings - Fork 189
[survey_accounts] Fixed base URL not being set properly #7807
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
[survey_accounts] Fixed base URL not being set properly #7807
Conversation
src/Router/BaseRouter.php
Outdated
| $request = $request->withAttribute("baseurl", $baseurl->__toString()); | ||
|
|
||
| // Reset factory object so that the base URL can be reset | ||
| $factory->reset(); |
There was a problem hiding this comment.
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 ??
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/Router/BaseRouter.php
Outdated
| $request = $request->withAttribute("baseurl", $baseurl->__toString()); | ||
|
|
||
| // Reset factory object so that the base URL can be reset | ||
| $factory->reset(); |
There was a problem hiding this comment.
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
ridz1208
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks good
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 usingsetBaseURL. 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
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