Font provider submodules set their own weight to 1 in hook_enable()
to ensure [provider]_preprocess_html()
is called after fontyourface_preprocess_html()
, in a manner like:
function font_provider_enable() {
// Weight must be above @font-your-face weight so preprocess comes after
db_query("UPDATE {system} SET weight = 1 WHERE name = 'font_provider'");
This code comes from 6.x and is not quite the proper way to do the task in D7. Documentation for db_query() explicitly tells us not to use it for UPDATE queries (while it still works for most users, it may fail on exotic databases). Hence, these lines need to be rewritten like:
function font_provider_enable() {
db_update('system')
->fields(array('weight' => 1))
->condition('name', 'font_provider')
->execute();
...and the comment could be a bit more verbose, too.
Here's how this was done for Edge Fonts module (which is not yet part of @font-your-face).
Comment | File | Size | Author |
---|---|---|---|
#2 | fontyourface-convert-update-queries-1837202-2.patch | 4.71 KB | Anonymous (not verified) |
Comments
Comment #1
Drave Robber CreditAttribution: Drave Robber commentedTagging.
Comment #2
Anonymous (not verified) CreditAttribution: Anonymous commentedI've had a go at this. Let me know if it's OK (not just the code but also the patch/git process).
Thanks!
Comment #3
sreynen CreditAttribution: sreynen commentedLooks good, thanks. Committed.
Looks like this is your first committed patch on Drupal.org, sjhuda. Congrats!
Comment #4
Anonymous (not verified) CreditAttribution: Anonymous commentedThank you!