Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
On the first page load after clearing caches on a site using office_hours (1.3 or 1.x-dev) there's a BOM (byte-order mark) present on the page.
This is present in office_hours.feeds.inc.
Attached simple patch to remove the BOM.
Comment | File | Size | Author |
---|---|---|---|
office_hours-remove-bom-from-feeds-inc.patch | 199 bytes | paulgrand | |
Comments
Comment #1
paulgrand CreditAttribution: paulgrand commentedJust a quick note, while it looks like this patch removes and then adds an identical <?php open tag, the BOM is in there (first character in the office_hours.feeds.inc file).
Comment #2
johnvNot sure what you mean, but I have committed the patch. Can you post a screenshot of the problem you had? Why is this major?
On a side note: can you succesfully load data? People seem to have problems: #1160440: Feeds mapper for Office hours
Comment #3
paulgrand CreditAttribution: paulgrand commentedIt's not the easiest to spot because in most editors it just doesn't appear.
In an editor such as netbeans, you can see the byte-order mark right before the PHP tag (either in my patch file or office_hours.feeds.inc) as below example:
Netbeans BOM showing
While inspecting the response headers one can also see the offending char:
Inspecting headers
(note the red dot before doctype in the inspector)
The result is (usually) whitespace right before any page content gets loaded after a cache clear (and some interesting w3c validator results), such as:
Result
Steps to replicate would be:
- Give a site a coloured header, or something that would be noticeable if it were moved down a line.
- Use drush to clear caches (the whitespace is well hidden by admin menu, so hard to detect when using admin backend to clear caches)
- Load a page.
It's usually not a huge issue, however, if this first pageload is done by an anonymous user on a site sitting behind a caching server, the BOM causing the whitespace will also be cached. Thus present until caches are cleared, and the first page-load done by an auth'd user.
I'm not entirely sure why it only happens on the very first page load, but applying the patch and then clearing caches will address the issue.
An easy way to spot files with this pesky char in future is running (at the root of your code dir):
grep -rl $'\xEF\xBB\xBF' .
Hope this explains what I'm getting at, as I notice that opening the patch file in a web browser looks like I'm replacing an identical line haha!
Let me know if anything's unclear!
Thanks,
Paul
Comment #4
johnvHi Paul, thanks for your extensive explanation. It's strange, though, since you apparently aren't using Feeds, at least not on an ordinary page, so it shouldn't be loaded...
But anyway, It's fixed now, and I'll roll a new version when I have checked the Feeds problems of the other guys.
Comment #6
johnv