Developer Notes
Handling Invalid music-list.php Requests
During development of music-list.php, the page originally
defaulted to displaying the archive by title whenever it received an
unrecognised or incomplete URL request.
For example, if a programming error generated an incorrect URL, the page would still display a perfectly valid list of tracks ordered by title. Although this avoided a PHP error, it also hid the underlying problem.
The decision was therefore made to change this behaviour.
Design Principle
When something unexpected happens, fail visibly rather than quietly doing something else.
Returning an apparently correct page when an invalid request has been made can make programming errors much harder to detect and may confuse users who receive results different from those they expected.
Planned Behaviour
-
If the requested
viewparameter is recognised (for example title, genre, instrument, or status), the appropriate list will be displayed. - If the request is not recognised, a friendly message will be shown rather than silently displaying a list ordered by title.
The page should explain that the requested list could not be generated and, where appropriate, encourage the visitor to report the problem if they followed a link from elsewhere on the website.
For diagnostic purposes the page may also display the values that were received, for example:
view=xyz value=abc
Future Development
Rather than immediately creating an error_logs table, a more flexible approach would be to introduce a general site_log table capable of recording a variety of events throughout the website.
Possible categories could include:
- Information – General operational events, such as searches returning no results.
- Warning – Unexpected but non-critical events, such as an unknown
music-listfilter. - Error – Genuine faults, for example missing artwork files or database inconsistencies.
- Security – Invalid administrator logins, suspicious requests, or other security-related events.
This broader approach would provide a reusable logging system for the entire
website rather than one designed solely for music-list.php.
Implementation Strategy
- Remove the current default behaviour of listing tracks by title.
- Display a clear, user-friendly message whenever an invalid request is received.
- Implement a reusable logging system later, once several areas of the website can benefit from it.
This follows the general philosophy adopted throughout the project: first make the behaviour correct and understandable, then introduce reusable infrastructure when there is a genuine need for it.