Uncaught TypeError: Cannot read property 'setStyle' of undefined
Expected Behavior
I visit a page, say 'banlist'. I click on an entry to expand it. I expect the entry to expand and show me the relevant information.
Current Behavior
I visit a page, say 'banlist'. I click on an entry to expand it. Sometimes, the entry expands as expected. Other times, it does not expand and the following Javascript error is printed to console:
Uncaught TypeError: Cannot read property 'setStyle' of undefined
at klass.onBackground (https://www.invexgaming.com.au/bans/scripts/sourcebans.js:191:11)
at returns (https://www.invexgaming.com.au/bans/scripts/mootools.js:447:15)
at https://www.invexgaming.com.au/bans/scripts/mootools.js:452:11
at klass.<anonymous> (https://www.invexgaming.com.au/bans/scripts/mootools.js:199:65)
at Array.forEach (native)
at klass.fireEvent (https://www.invexgaming.com.au/bans/scripts/mootools.js:198:23)
at klass.<anonymous> (https://www.invexgaming.com.au/bans/scripts/mootools.js:3314:9)
at Array.forEach (native)
at klass.display (https://www.invexgaming.com.au/bans/scripts/mootools.js:3311:17)
Then I cannot expand any entries until I refresh the page.
Possible Solution
An undefined check somewhere before calling .setStyle()? I'm not too sure, I don't know how many others are experiencing this issue.
Steps to Reproduce (for bugs)
I cannot reproduce this 100%. It happens randomly. I am always logged into SourceBans when this happens but it could also potentially happen when logged out. It is frequent however, occurs multiple times per day.
- Visit banlist page
- Click on entry to expand
- Does not expand, Javascript spits out error
Your Environment
- Version used:
- PHP and MySQL version: PHP version: 5.6.30, MySQL 5.5.53
- Operating System and version: Windows 10 / Version 1607 / Build 14393.1066
- Link to your project: https://www.invexgaming.com.au/bans/
- Link to gist with phpinfo() output: N/A
Also I am using 'SourceBans++ 1.5.4.7' but I've had this issue for some time. However, I will update soonish to latest release and report if its fixed but I have a feeling it won't be.
Same issue after updating to 1.6.1:
Uncaught TypeError: Cannot read property 'setStyle' of undefined
at klass.onBackground (https://www.invexgaming.com.au/bans/scripts/sourcebans.js:191:11)
at returns (https://www.invexgaming.com.au/bans/scripts/mootools.js:447:15)
at https://www.invexgaming.com.au/bans/scripts/mootools.js:452:11
at klass.<anonymous> (https://www.invexgaming.com.au/bans/scripts/mootools.js:199:65)
at Array.forEach (native)
at klass.fireEvent (https://www.invexgaming.com.au/bans/scripts/mootools.js:198:23)
at klass.<anonymous> (https://www.invexgaming.com.au/bans/scripts/mootools.js:3314:9)
at Array.forEach (native)
at klass.display (https://www.invexgaming.com.au/bans/scripts/mootools.js:3311:17)
After further review I found a PHP error log entry: [Sun May 14 04:19:30.256664 2017] [:error] [pid 10844] [client REMOVED] PHP Warning: mysqli_real_connect(): (HY000/1040): Too many connections in /var/www/REMOVED/public_html/bans/includes/adodb/drivers/adodb-mysqli.inc.php on line 124, referer: https://www.invexgaming.com.au/bans/index.php/index.php?p=banlist&page=2&advSearch=REMOVED&advType=ip [Sun May 14 04:19:30.261620 2017] [:error] [pid 10844] [client REMOVED] PHP Fatal error: mysqli error: [1040: Too many connections] in CONNECT(REMOVED, '', '', sourcebans)\n in /var/www/REMOVED/public_html/bans/includes/adodb/adodb-errorhandler.inc.php on line 79, referer: https://www.invexgaming.com.au/bans/index.php/index.php?p=banlist&page=2&advSearch=REMOVED&advType=ip
So I believe the error was caused by my database reaching max connections. I found another plugin (which also uses SourceBans db) was making a lot of connections but was not closing the connection which probably caused the above error. I will monitor the ban page now for the same bug over the next week, if it doesn't appear from this point onwards, this issue can be closed.