Skip to content

Resolve "Only execute legal queries when being logged in"

Closes #762 (closed)

What does this MR do?

Legal query is only executed when being logged in and database access is optimized.

How confident are you it won't break things if deployed?

The only critical point is to move the routing in session out to the classes using refreshDatabase by throwing and catching an exception. The 4 classes using refreshDatabase are Session, Settings, Relogin and Legal. The current code should reproduce their error handling when getFoodsaverDetails returns [] instead of the requested information. That is:

Session - Login (http://localhost:18080): Red box saying: unknown error

Settings (http://localhost:18080/?page=settings&sub=general): Whoops \ Exception \ ErrorException (E_NOTICE) Undefined index: rolle

Relogin (http://localhost:18080/?page=relogin): Redirect to logout

Legal (http://localhost:18080/?page=legal): Redirect to logout

Links to related issues

Any relevant links (issues, documentation, slack discussions).

How to test

As this was a refactoring task, no new test was written.

Steps a reviewer can take to verify that this MR does what it says it does e.g.

  1. Go to index page
  2. Open debugbar Database tab
  3. When logged in there should be two requests of the type: SELECT last_mod FROM fs_content WHERE id = ... on the index page. When not logged in there shouldn't be any request of that type on the index page.

Screenshots (if applicable)

Any relevant screenshots if this is a design / frontend change

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined #foodsharing-beta channel at https://slackin.yunity.org
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
  • Once your MR has been merged, you are responsible to update the #foodsharing-beta Slack channel about what has been changed here. They will test your work in different browsers, roles or other settings
Edited by Caroline Fischer

Merge request reports