This patch updates Browscap to Drupal 5 and addresses most of the issues current in the queue for this module. Here's the changes:
- New .info file - required by Drupal 5
- Removed hook_help() - no longer needed
- Changed import method for Browscap data from garykeith.com. Import now comes from the .ini file provided for PHP. This will keep the module from breaking if/when the data order/type changes (as happened recently with the csv). It's a slightly larger download, but it's a quicker parse and doesn't require two writes to the database anymore to fill in the "parent" data.
- The browscap_get_browser() now always outputs an array. This array more closely adheres to the browscap data file keys than to PHPs get_browser() function, but most stuff lines up pretty closely. Again, this sort of future-proofs the module. If Gary adds more properties, they will immediately be available as part of the browscap_get_browser() output.
- Browscap now maintains its own cache table as recommended by Drupal 5.
- The format of the 'browscap' table has changed to allow for future changes to Gary's data. All of the returned data is serialized and stored in a 'data' field very similar to the cache table format. This makes moving the data from the 'browscap' table into the (new) 'cache_browscap' table quicker.
- The Browscap menus have been changed to accommodate the new admin screens in Drupal 5. The different types of log views ('all', 'browsers', 'crawlers') are now represented as tabs.
Incidentally, I've written a module (tentatively) called Browser Theme Switcher that uses browscap_get_browser() to allow swapping out a different theme for a given browser. My goal being to allow for Drupal to provide a different page layout to mobile devices. It's all working quite well!
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | browscap.install_0.txt | 2.3 KB | bwynants |
| #2 | browscap.install.txt | 1.55 KB | jjeff |
| #1 | browscap.info_.txt | 177 bytes | jjeff |
| browscap-5.patch | 17.83 KB | jjeff |
Comments
Comment #1
jjeff commentedPatch didn't include new .info file... Here it is...
Comment #2
jjeff commentedAlso new .install file that now includes hook_uninstall()
Comment #3
jjeff commentedOoop. With this big database change there will probably need to be an hook_update_2() to truncate the browcap table and convert it to the new format.
Comment #4
bwynants commentedinstall files misses
in browscap_install function
Comment #5
jjeff commentedYes. Discovered that. I'm doing a little more cleanup and then I'll commit this to CVS.
Comment #6
jo1ene commentedFYI: I tried this out for the sake of testing (adding the missing line in #4) and got this error filling up my logs:
Comment #7
bwynants commentedBetter install file. rename (remove .txt) Drop it in. uninstall -> reinstall
Comment #8
luti commentedAs first, thanks for a patch and files provided here.
A bad news is that in my test environment browscap is causing cron timeout to be reached. I've tried to dig a bit into the cron process and it seems to me a problem is somewhere in "recursive magic". The fact is if I comment out the section between the "//some recursive magic!" line (line 102) and until the "foreach" closing bracket (after the "db_query..." sentence in a line 111), cron is finished in a few seconds. If I move a start of the commented out section after a "while" loop (to the beginning of a line 109), cron doesn't finish in time.
What is interesting is that after the initial run of the cron, database ("browscap" table) was filled with 2980 lines, so it seems the issue starts somewhere in the middle (or, at the end) of parsed file (downloaded data).
So, after my database was populated with those 2980 lines, I've commented out the "problematic" part as above, so there should not be a problem with cron now (this could be some kind of a temporary solution). In the future, I can manually run the cron with "original" module version to update browscap table (probably it will have to be a bit modified not to check the last "update" time...). So much as my advice to the others, until someone will fix this issue.
Comment #9
bwynants commentedsame problems here... was also looking at the same pieces of code yesterday but haven't looked into deep detail what exactly goes wrong.....
Comment #10
fholldorffIf there any news about an update?
Comment #11
jaskegreen commentedSo where does this update stand? Is it ready for D5? Can someone provide a module download that would include all of the files necessary for D5?
Thanks,
Jason
Comment #12
mikeryanThere's a Drupal 5 dev release available now, and I'm reviewing it now in anticipation of an official release. If you find any problems in the dev release, please open new issues for them.
Thanks.