Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

mysqli_functions_include.php - dbconnection() will never return a connection


Print Track
(Edit: I've referenced 8.00.22 because it's the newest code on Github, but as far as I can tell, the bug is present in both .21 and .22)

The error
The MySQLi and PDO database handlers both have a function like this:
mysqli_functions_include.php #L139 - #L145
i.imgur.com/WzXzwGk.png

dbconnection() is currently called only one place outside of the handlers themselves:
maincore.php #L1136
i.imgur.com/OsPTr9T.png

function_get_settings() is however very dependant on the dbconnection() static variable being initialized. In pdo_functions_include.php, it is. In mysqli_functions_include.php, it is not - and as such, it will never return a connection.

pdo_functions_include.php #L152
i.imgur.com/bEdigUb.png

mysqli_functions_include.php #L126
i.imgur.com/NIKzO2X.png

My solution
Wrapping the connection in dbconnection() as follows
i.imgur.com/r87XkqQ.png
solved the two bugs that made me go hunting in the first place. I have not tested every place function_get_settings() is in use - I'll let you decide if that is needed.

Impact
(image) A quick command line search for function_get_settings() in 8.00.22
A lot of these places doesn't matter because of luck, but some do. I've found two, but they're probably not alone.

administration/bbcodes.php, before:
i.imgur.com/JVyBLPd.png
and after:
i.imgur.com/UQWWMa3.png

maintenance.php: Without the fix, it redirects to itself forever

0 replies

author Mickelvlm
forumSuspected Bugs and Errors - 8
replies1 post
viewed43 times
activeLast updated on 12 days ago

Hot Questions

Druid
Latest Comment Panel
Druid - 7 posts
Basti
N
Incorrect Validation Code
Nomak - 25 posts
B
Index.php always broken
bobesama - 19 posts
starefossen
PHP 5.3/6 Comparability Problems
starefossen - 8 posts
R
You can view all discussion threads in this forum.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
Users who participated in discussion: Mickelvlm