php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #20914 Allow changing browscap.ini in runtime for get_browser() function
Submitted: 2002-12-09 19:28 UTC Modified: 2022-04-07 14:25 UTC
Votes:22
Avg. Score:4.2 ± 0.9
Reproduced:10 of 18 (55.6%)
Same Version:6 (60.0%)
Same OS:8 (80.0%)
From: nzdarktrojan at hotmail dot com Assigned: ilutov (profile)
Status: Closed Package: PHP options/info functions
PHP Version: * OS: *
Private report: No CVE-ID: None
 [2002-12-09 19:28 UTC] nzdarktrojan at hotmail dot com
The get_browser () function currently can only use a single browscap.ini, as specified in php.ini. Therefore (to my knowledge) if the browscap.ini is changed, the server (I'm using Apache) must be restarted before the changes filter through to PHP. In my situation (and probably many others), I don't own or have rights to the server, and the owners are unwilling to restart the server (I'm developing a customized browscap, and I make changes frequently).

What I suggest (I don't have enough knowledge of C, or I'd do it myself) is overloading the get browser function,
from: object get_browser ([string user_agent])
to: object get_browser ([string user_agent], [string browscap_file])

When the function is called, it loads the browscap_file to memory and uses that instead of the global file. This would also be useful where multiple sites are hosted on the same server, but the sites wish to use different browscap files.

Patches

kXvrbKwH (last revision 2021-07-19 11:17 UTC by sample at email dot tst)

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-12-29 17:46 UTC] jani@php.net
-Summary: Extending get_browser () function +Summary: Allow changing browscap.ini in runtime for get_browser() function -Package: Feature/Change Request +Package: PHP options/info functions -Operating System: All +Operating System: * -PHP Version: 4.2.3 +PHP Version: *
 [2017-08-23 00:31 UTC] kalle@php.net
-Status: Open +Status: Analyzed
 [2017-08-23 00:31 UTC] kalle@php.net
The reason why is that PHP will load the browscap file into memory at initialization so calls to get_browser() will be faster if called multiple times, tho I suppose it could make sense to allow specific browscap files to be loaded if so desired. But all in all, I think it could be re-worked to allow a browscap in php.ini to be PHP_INI_USER or PHP_INI_ALL but I'm not sure how much of a value that is today, 15 years after the report was created
 [2021-07-19 11:16 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693393
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693393
 [2021-07-19 11:17 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693423
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693423
 [2021-07-19 11:17 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693431
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693431
 [2021-07-19 11:17 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693441
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693441
 [2021-07-19 11:17 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693451
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693451
 [2021-07-19 11:17 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693460
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693460
 [2021-07-19 11:17 UTC] sample at email dot tst
The following patch has been added/updated:

Patch Name: kXvrbKwH
Revision:   1626693471
URL:        https://bugs.php.net/patch-display.php?bug=20914&patch=kXvrbKwH&revision=1626693471
 [2022-04-07 14:25 UTC] ilutov@php.net
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: ilutov
 [2022-04-07 14:25 UTC] ilutov@php.net
Shared hosting nowadays is less common and in 2002, so restarting the server might be less of a problem. If the need for this persists, please create a new issue on GitHub.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 21:01:28 2024 UTC