SMF icon indicating copy to clipboard operation
SMF copied to clipboard

Improper $smcFunc syntax

Open jasonclemons opened this issue 12 years ago • 5 comments

/Sources/ManageMaintenance.php Line 973

                $request = $smcFunc['db_query']('', '
                        SELECT MAX(' . $primary_key . ')
                        FROM {db_prefix}' . $cur_table,
                        array(
                        )
                );

Should this not be this?

                $request = $smcFunc['db_query']('', '
                        SELECT MAX({raw:primary_key})
                        FROM {db_prefix}{string:cur_table}',
                        array(
                                'primary_key' => $primary_key,
                                'cur_table' => $cur_table
                        )
                );

jasonclemons avatar Jan 26 '14 19:01 jasonclemons

Nope, that's not going to work for you because the string type will escape it first. And you can't use the raw type for that because you can't guarantee what db_prefix will or will not be.

Arantor avatar Jan 26 '14 19:01 Arantor

Ah, I see. I was just curious why the query wasn't following usual format.

jasonclemons avatar Jan 26 '14 19:01 jasonclemons

primary_key could be the subject of a raw, but the table name can't - and if you're going to make an exception on one, might as well really go to town!

Arantor avatar Jan 26 '14 21:01 Arantor

Just going through the code of the maintenance section while at work. Was working on cleaning up my old board which I just upgraded to 2.1, and noticed it was throwing a lot of errors. So I found a constructive way to waste time while getting paid.

Will work on it more when I get home and get my dev environment up and running.

jasonclemons avatar Jan 26 '14 22:01 jasonclemons

Nice :) It's all appreciated, thank you!

Arantor avatar Jan 26 '14 22:01 Arantor