$smcFunc['db_create_table'] "bug"

Started by Oranos, August 22, 2010, 05:34:18 AM

Previous topic - Next topic

Oranos

./Sources/DbPackages-mysql.php

I don't think I would call this so much as a bug, but if a table creation is successful

if(!$smcFunc['db_create_table']($table_stuff))

does not return false. The reason being smf_db_create_table() doesn't have a return unless the table already exist. The solution is rather simple.

find

// Create the table!
$smcFunc['db_query']('', $table_query,
'security_override'
);


which is actually the very last thing in the function, and replace it with

// Create the table!
return $smcFunc['db_query']('', $table_query,
'security_override'
);


This is for MySQL, I don't really have any other SQL software to test it with, but without looking at the files, I assume it's probably the same issues for postgre and litesql.

Norv

Noted, thank you for the report!

I would call it a bug, at code level, regarding consistency and implementing the documented interface. smf_db_create_table() is documented in the file to have a boolean return and it already does that in some cases, so it'd better do it.  :)
To-do lists are for deferral. The more things you write down the later they're done... until you have 100s of lists of things you don't do.

File a security report | Developers' Blog | Bug Tracker


Also known as Norv on D* | Norv N. on G+ | Norv on Github

Oranos

Interestingly enough, I only discovered this because I'm making an overly complicated (by complicated I mean fancy) installer for my next mod :P

live627

I should note this is also in PostgreSQL and SQLite as well as MySQL.

Joshua Dickerson

I feel like this was changed. Is this still a bug?
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

emanuele

Yep, still a bug...well, the documentation changed, now is no more documented the return value, so if you want you can say it's fixed. :P


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Joshua Dickerson

I know there was a lot of talk about it. Perhaps Norv or someone could fill us in on what the outcome was.
Come work with me at Promenade Group



Need help? See the wiki. Want to help SMF? See the wiki!

Did you know you can help develop SMF? See us on Github.

How have you bettered the world today?

emanuele

Similar problem for db_add_index: there are a couple of return false, but never a return true.


Take a peek at what I'm doing! ;D




Hai bisogno di supporto in Italiano?

Aiutateci ad aiutarvi: spiegate bene il vostro problema: no, "non funziona" non è una spiegazione!!
1) Cosa fai,
2) cosa ti aspetti,
3) cosa ottieni.

Illori


Joker™

array(
         'security_override' => true,
)


I noticed the change in the code in the DbPackages-mysql.php for both index and table.
Github Profile
Android apps
Medium

How to enable Post Moderation

"For the wise man looks into space and he knows there is no limited dimensions." - Laozi

All support seeking PM's get microwaved

Arantor

It's quite a bit different in the other backends because they do transactions and multiple queries to build tables and whatnot, but I've just committed a change for 2.1 that makes them return true once done successfully (since they'd fall into all the normal error handling if there's any failures...)

Advertisement: