To help sort user agents and expose data about the user agent to Drupal it would be useful to separate the data into database columns. This allows data to be queried in groups, sort data based on any value and filter results more quickly.
It would also be required to implement a feature in Mobile Tools where by we expose user agent data through CTools contextual data.
Context is CTools way of saying, my plugin (read, block) shouldn't be dumb. If it requires a node or a user to extract data from, then it should let others know about it.
I'll attempt a patch to Browscap with the adjustment in-place. The change shouldn't change any of the existing functionality, the existing columns would be retained.
Comment | File | Size | Author |
---|---|---|---|
#45 | browser-database-schema-1713570-45-D7.patch | 9.04 KB | sidharthap |
#1 | 1713570-schema-change.patch | 10.58 KB | minorOffense |
Comments
Comment #1
minorOffense CreditAttribution: minorOffense commentedHere's my first attempt at a patch to add this feature. We may need to add some indexes and ensure all the data is being imported properly.
Comment #2
webadpro CreditAttribution: webadpro commentedHas this been pushed yet?
Comment #3
minorOffense CreditAttribution: minorOffense commentedNot that I know of.
Comment #4
dgreenyc CreditAttribution: dgreenyc commentedI've tried applying this patch but am running into problems - new to patching, so any instructions that you may be able to provide would be appreciated.
Comment #5
taonac CreditAttribution: taonac commentedHi,
I tried patching but im getting Hunk #1 FAILED at 20.
Comment #6
hebbar10 CreditAttribution: hebbar10 commentedPatch #1 worked for me. Thanks.
Comment #7
drupalok CreditAttribution: drupalok commentedplease add this to a release! all those folks out there (like me) that are not too much into patching can't use mobile tools with browscap at all if this is only usable by patchin...
thanks a lot!
Comment #8
miahon CreditAttribution: miahon commentedShould this #1 patch working with Browscap 7.x-2.0 (dated 2012-Nov-22 ) ?
Comment #9
imoreno CreditAttribution: imoreno commentedHi,
Based on my knowledge end experiments. this patch didn't make it to the nov-22 version. i had to apply it in order to make mobile tools 7.3.x to work.
Please correct me if i'm wrong
BR
Itzhak
Comment #10
dominikb1888 CreditAttribution: dominikb1888 commentedUsing drush to enable browscap I received the following error. Apparently false instead of 0 is submitted to alpha, which is a tinyint column. Apart from this the patch seems to work as expected. The table is generated nonetheless.
Comment #11
jlea9378 CreditAttribution: jlea9378 commentedI also received this error in my log after enabling Browscap (after patching):
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: 'false' for column 'alpha' at row 1...).
Comment #12
jlea9378 CreditAttribution: jlea9378 commentedClicking "Refresh browscap data" on the Browscap admin UI causes the error to throw again:
Comment #13
dark_kz CreditAttribution: dark_kz commentedhave the same problem
Comment #14
Iztok CreditAttribution: Iztok commentedSame problem when I want to update. The default mobile group is also missing parent browser agents list.
Comment #15
drupalok CreditAttribution: drupalok commentedi ended up using some javascript for browser detection.
don't get me wrong. i really appreciate the hard work every developer does for drupal, but longterm issues like this, which make the use of some standard-functionality (come on, mobile sites have to work out of the box in drupal now!) make me think about where drupal is going...
is it really just us 14 followers that use drupal with browscap and mobile tools and want this to work without patching and painful try-and-error?
or are we just to stupid to get this done?
Comment #16
mondrakeFor comments #10 to #14, issue #1868808: False/true not converted to 0/1 during browscap.ini import seems to be related.
Comment #17
jlea9378 CreditAttribution: jlea9378 commentedThanks mondrake, that second patch you pointed me to worked. No more errors!
Comment #18
benchesters CreditAttribution: benchesters commentedI have now spent 2 hours trying to patch this file with no luck. Can someone please send me the finished file? Seems strange how no one ever posts the actual patched file yet talks about it endlessly!! Please help a novice out. Cheers!
Comment #19
benchesters CreditAttribution: benchesters commentedI am definitely too stupid - I have wasted 3 hours just trying to patch this file. I beg anyone to send me the completed file!
Comment #20
mondrake@benchesters,
welcome to patching :)
in fact you should apply the patch to a local copy of the latest code, available in the development branch of the project - then, copy the resulting patched files to the folder where browscap is installed, clear caches, and you should be done.
If you are totally new to git, Drupal's version control system, where the code is stored, I would suggest you take a look at Git documentation. If you can't wait :), more direct instructions are available at Applying patches with Git.
Comment #21
benchesters CreditAttribution: benchesters commentedHello there. I have tried and tried to do this but cannot. I even posted the job on a freelancer site. I am happy to pay someone to so this for me as it's infuriating! Appreciate your feedback mondrake but this one is out of my depth and seriously slowing me down.
Comment #22
DaveHS CreditAttribution: DaveHS commentedThe attached patch applies the same changes as minorOffense made in comment #1 to the 7.x-2.x code.
The zip file is the full plugin - use at your own discretion, and be careful about applying any future updates...
This version has been used successfully with:
to handle mobile devices.
Comment #23
benchesters CreditAttribution: benchesters commentedThank you very much for your help, I really appreciate it.
Comment #24
steven.wichers CreditAttribution: steven.wichers commentedNot sure what's with the attached patch in #22. Here's a patch from the zip he included.
Comment #25
benchesters CreditAttribution: benchesters commentedThe error seems to have stopped now that I used the version in #22. Next problem is the URL which has a word added to it when a mobile visits. The URL Modifier? Anyone know how to get rid of this, I want the same URL to be served for all devices.
Comment #26
alibama CreditAttribution: alibama commentedDitto - in fact I can now add the word mobile to my url eg test.com/mobile and get the same functionality regardless of whether the user agent has changed. This is not working as I had expected when I added the browscapped user agents to the mobile group.... this may be a question for mobile tools instead of browscap though... any help appreciated
Comment #27
xturgorex CreditAttribution: xturgorex commentedAfter trying a few different patches without any luck, I finally upgraded my server from PHP 5.2 to 5.3 and used patch #24. That worked for me. I could not get this module working with 5.2. Not that my project requires 5.2, I just didn't realize this would be the issue.
Comment #28
dsnopekPatch in #24 works for me! I think the issues in #25 and #26 are with mobile_tools, not browscap. Unfortunately, I don't have a PHP 5.2 environment to verify #27.
Comment #29
decibel.places CreditAttribution: decibel.places commentedI came here via directions in mobile_tools_browscap/README.txt
but the patch in #24 fails:
also it appears that the second optional patch for the Chosen module is already in the latest version
And when I try to add a Mobile Tools device group, I get this error:
[EDIT]
BUT...
When I replace the Browscap module with the browscap-7.x-2.x-patch.zip from #22, run db updates, and restore the official version of Browscap the error does not appear, but neither do the parent browser agents... tried the patched version form #22, still no parents...
OK, maybe because in local dev I have PHP 5.4.9-4ubuntu2.3 ?
Well on CentOS server with PHP 5.3.3 still no dice...
Comment #30
gregglesThe patch no longer applies, so "needs work" status for that.
It would be great if someone could benchmark the code with and without this change.
Comment #31
jlea9378 CreditAttribution: jlea9378 commentedI tried using this module (latest version) with the patch in #24 (I applied it manually) with the most recent 7.x-3.x dev release of Mobile Tools but got this error: #2117253: PDOException Data too long for column 'detection_settings'
I figured I would mention it here in case anyone else tries using this module with the patch with Mobile Tools.
Comment #32
danharper CreditAttribution: danharper commentedI can't get browscap to work with latest version of mobile_tools, when I try to edit a device group I get a PDO error.
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'b.parent' in 'field list': SELECT b.parent AS parent FROM {browscap} b GROUP BY parent ORDER BY parent ASC; Array ( ) in mobile_tools_browscap_get_browscap_parents() (line 139 of /srv/drupal/sites/all/modules/mobile_tools/mobile_tools_browscap/mobile_tools_browscap.module).
When I turn off browscap I can edit the device groups again.
The patches in the thread don't seem to work against the latest dev version.
I'm using the latest mobile tools dev version.
Cheers Dan
Comment #33
Damien Laguerre CreditAttribution: Damien Laguerre commentedHi,
This is the patch for Browscap 7.x-2.2.
Comment #34
Damien Laguerre CreditAttribution: Damien Laguerre commentedNew one,
Some fields have changed in the latest version.
Comment #35
gregglesOriginal was right. This is hook_schema.
Did anyone benchmark this change? It will make imports even slower but should improve some lookups. So...what's the tradeoff :)
This change looks unrelated. Can you clarify why it's needed or add it back?
This seems like an unrelated change. Can you clarify why it was necessary?
This change is likely to conflict with the work in #2305223: Optimize database access in _browscap_import() which seems to be closer to ready to go.
Comment #36
Damien Laguerre CreditAttribution: Damien Laguerre commented1. From #24
2. Idem
3. I have this error with gzdecode :
Warning : gzdecode(): data error
4. Previous regex doesn't work :
Part of ini file :
5. From #24
Comment #37
gregglesOK. If there are problems with the patch in #24 they should be removed, not referenced ;)
Items 3 and 4 should be split into unique issues so the merits can be discussed more directly with an issue title that focuses on that problem.
Comment #38
Damien Laguerre CreditAttribution: Damien Laguerre commentedI've just port the #24 on Browscap 7.x-2.2
This patch is requested by mobile_tools(README in mobile_tools_browscap).
I do not know why they want to blow up the table into several fields.
Comment #39
danharper CreditAttribution: danharper commentedHi Thanks for the updated patch, it adds the new schema correctly but it breaks the import.
When I click refresh data the page just refreshes, it doesn't display any error nor does it report to the log file.
Also as you mention a lot of work has been done to optimise the database access on the other thread but this patch which is now in dev doesn't cope with new schema required for mobilt_tools either.
I can't seem to get this to work with any combination either 7.x-2.2 or 7.x-dev patched.
It would be great to get a patch against the latest dev that would solve all the issues with slow db writes and having the correct schema.
Cheers Dan
Comment #40
danharper CreditAttribution: danharper commentedI've created a patch which does work against the current dev version in terms of writing the correct records to the db but one caveat is that I could only get the import to work through drush as when it tries to write the records to the database it timesout.
Also although I can see the records in the db the actual mobile tools UI seems to be broken which I will log as a separate issue on that issue queue.
Dan
Comment #41
AohRveTPV CreditAttribution: AohRveTPV commenteddanharper, looks like you may have uploaded the wrong patch?
Comment #42
danharper CreditAttribution: danharper commentedUpdated patch and this seems to work but mobile tools still needs patching as the mobile tools UI seems to fail querying the parent, Patch #40 needs removing but not sure how to do it.After reinstalling the module it doesn't bring all the fields in.
Cheers Dan
Comment #43
AohRveTPV CreditAttribution: AohRveTPV commentedMight it be better to not hardcode the specific fields? The properties in the Browscap data may change over time. If Browscap data version x adds a property, this may break for a user whose site automatically updates from version x-1? I am wondering if it is possible and would be better to create the database columns dynamically upon import.
Comment #44
vishalgala CreditAttribution: vishalgala as a volunteer commentedI received the same below issue and tried to applied attached patch which worked also resolved the issue mentioned in #12 in the above mail thread..
PDOException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'b.parent' in 'field list': SELECT b.parent AS parent FROM {browscap} b GROUP BY parent ORDER BY parent ASC; Array ( ) in mobile_tools_browscap_get_browscap_parents() (line 139 of /Users/alfredonevarez/Sites/tresplace/sites/all/modules/contrib/mobile_tools/mobile_tools_browscap/mobile_tools_browscap.module).
This is the patch for Browscap 7.x-2.2.
Comment #45
sidharthapThank you for the patch @vishalgala
I applied the patch and it shows trailing whitespace at line 191, 389,391
warning: 3 lines add whitespace errors.
Here is the new patch with correcting the whitespace errors.