Closed GoogleCodeExporter closed 9 years ago
I started working on this, and got caught up in cleaning more $_GET excess :)
First step: collect the value $_GET['table'] once, early in the script,
reducing the number of isset() checks and making it possible to check if the
table is actually a view. $target_table is now used to hold the value.
Original comment by dreadnaut
on 4 Jan 2014 at 5:18
Attachments:
Looks good! :)
Original comment by crazy4ch...@gmail.com
on 4 Jan 2014 at 5:36
Step 2: add Database->getTypeOfTable($table) which returns 'view' or 'table',
and replace all $_GET['view'] checks relative to the table/view setting.
Turns out, there was just *one* place where the 'view' parameter was used for
other reasons.
Original comment by dreadnaut
on 4 Jan 2014 at 6:04
Attachments:
Lastly, some clean up: in some places a $table variable was actually filled
with $_GET['table'], so I replaced that with our new $target_table.
I'd say I'm done with this, ready for review and commit!
Original comment by dreadnaut
on 4 Jan 2014 at 6:13
Attachments:
Whops, I found some more view=1 around the code. Here's the complete patch.
Original comment by dreadnaut
on 4 Jan 2014 at 6:17
Attachments:
Thanks. Looks good. And amazing how many places we add view=1 just to for one
simple place where we check for it and checking is so easy ;)
Only one thing: Please use $db->quote_id($table):
$result = $this->select("SELECT * FROM `sqlite_master` WHERE
`name`=".$db->quote_id($table), 'assoc');
$table could contain quotes or stuff...
Next step would be to make sure the is no view=1 left.
Original comment by crazy4ch...@gmail.com
on 4 Jan 2014 at 6:22
Updated to include quote_id()
$result = $this->select("SELECT `type` FROM `sqlite_master` WHERE `name`='"
. $this->quote_id($table) . "'", 'assoc');
Original comment by dreadnaut
on 4 Jan 2014 at 6:27
Attachments:
You don't need quotes around quote_id() as it adds them automatically.
And maybe better use quote in this case, as from an SQL point of view, this is
a value that should be in single quotes and not a tablename that should be in
double quotes. Although SQLite does not care much.
$result = $this->select("SELECT `type` FROM `sqlite_master` WHERE `name`="
. $this->quote($table), 'assoc');
And I think getTypeOfTable should be part of the Database class.
Original comment by crazy4ch...@gmail.com
on 4 Jan 2014 at 6:34
Here the version with quote(). getTypeOfTable is already in the Database class,
I'm using $this if you check.
Original comment by dreadnaut
on 4 Jan 2014 at 6:37
Attachments:
Ah sorry. Looks good. Go for it! (commit)
Original comment by crazy4ch...@gmail.com
on 4 Jan 2014 at 6:38
This issue was closed by revision r450.
Original comment by dreadnaut
on 4 Jan 2014 at 6:56
Thanks for fixing this.
As this affects only maintainability and some more testing might be good, I
think we don't need to push it into upcoming 1.9.5 final. So it will make it
into 1.9.6.
(I'd like to have 1.9.5 RC1 and 1.9.5 to be exactly the same code if no bugs
found in RC1)
Original comment by crazy4ch...@gmail.com
on 4 Jan 2014 at 7:18
Original issue reported on code.google.com by
crazy4ch...@gmail.com
on 17 Mar 2013 at 11:16