Why isn't opendb.asp included in inc_theme_common? |
Post Reply |
Author | |
Brett
Groupie Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
Post Options
Thanks(0)
Posted: 11-June-2017 at 7:44pm |
I've been trying to use the JSON parser and pcf_OpenUTF8 within my theme, but I couldn't get it to work. Eventually I found out that the issue was related to ErrorHandler.asp not being included.
I ended up having to include opendb.asp to the list of includes in include_theme_common.asp, and include ErrorHandler.asp in that same list of includes. Now it appears to be working, and pcf_OpenUTF8 is opening the file and I am able to parse it with JSON. Is there any reason opendb.asp wasn't included in include_theme_common.asp and that instead a different copy of the openDB function was hardcoded at the bottom of inc_theme_common.asp? Ideally I'd like to leave these changes as is, with opendb.asp and errorhandler.asp being included with inc_theme_common.asp, but if this is some kind of security risk or other issue then I suppose I'll need to find a workaround. |
|
Matt
Moderator Group Joined: 20-July-2006 Location: United States Status: Offline Points: 73 |
Post Options
Thanks(0)
|
Including "opendb.asp" worked because it automatically opens a database connection, but that's the reason it's not included. You want to be able to control when a database connection is open, and in most cases you don't want to open one within the header or footer. Think about the data you need and try to save it as a static asset, or at the least cache it. Try not to include anything dynamic in your head and footer that is going to use resources unnecessarily. However, if you have a good reason to connect to the database, contact a remote service, and parse JSON on each page load. You should remove opendb.asp and just call the open function.
e.g. ' Open db call openDB() ' do something... ' Close db call closeDB() If you are including "opendb.asp" and not closing the connection, then you have a leak. |
|
Brett
Groupie Joined: 22-April-2008 Location: Phoenix, AZ Status: Offline Points: 89 |
Post Options
Thanks(0)
|
Thanks for the explanation Matt. I'm trying to use webpack to setup an asset pipeline, and typically I'd read the assets from an assets.json file. I took your advice and reverted the changes to inc_theme_common.asp. I'll have to figure out some other way to parse the assets file.
I definitely don't want to continuously connect to the DB and stuff. It already seems like this is happening too much between the regular execution, and then theme.asp, header.asp, and footer.asp (which all seem to include inc_theme_common.asp since they all run in their own context due to being included via server.execute. I'll let you know what I end up going with. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |