Conversation
dgw
left a comment
There was a problem hiding this comment.
I admit I'm still not sold on this whole idea, especially since when to use other- seems entirely too ambiguous. Still, I've done my best to flag places that objectively don't make sense, such as use of read- context in a function that later performs a write operation.
|
All good points here @dgw , thanks a lot. Suggestion for the |
Co-authored-by: dgw <dgw@technobabbl.es>
Co-authored-by: dgw <dgw@technobabbl.es>
Co-authored-by: dgw <dgw@technobabbl.es>
Co-authored-by: dgw <dgw@technobabbl.es>
|
I guess that "slave DB" means If the primary originator of |
- Replace 'other-' with 'read-' in contexts - Validate context or raise debug message - Add tests for context - Add tests for all functions-debug.php
For consistency with previously existing DBSetTest file
dgw
left a comment
There was a problem hiding this comment.
I renamed the new test file (DBTestGet -> DBGetTest) for consistency, but otherwise 🚀
Realistically, I should block out time to make the new release (#4034) at the weekend, which gives @LeoColomb a few days to weigh in too :)
|
Morning thought : maybe instead of message in the footer, we could raise a notice, like we do when someone uses a deprecated function. Notices show only if YOURLS_DEBUG is true so this change would not affect YOURLS instances in prod |
|
100% go with the approach that has the best chance of making PHPUnit complain, imo I believe |
|
Missing or malformed contexts now trigger a notice. No message in the footer for consistency with other deprecation messages in YOURLS |
|
Principle sounds all good to me. |
yourls_get_db()
|
If the context is omitted, a notice is thrown, but nothing else happens. As I see it, someone making a plugin for a master/slave setup should make it so that, by default, unspecified queries are sent to the Maybe I should stress this out in my sample plugin |
LeoColomb
left a comment
There was a problem hiding this comment.
Understood. I think I would have preferred an internal fallback, but all good for me both ways.

PR related to #3846
All
yourls_get_db()calls in core are now passing an optional$contextparameter, with the following naming convention:One practical use of such contextualized
yourls_get_db()calls is to be able to use different DB connections in a Master/Slave setup. The following plugin should be a helping start : https://gist.github.com/ozh/553c2519878984271584939355e91b8e@daynesuke Could you test this branch and the plugin for your use case ? Input would be much appreciated