Skip to content

Commit

Permalink
Minor database fixups
Browse files Browse the repository at this point in the history
* NewDataDictionary is incorrect, use 'new Dictionary' instead
* db_table_exists should factor in new approach to prefixes and suffixes
* plugin_api doesn't need to check if the 'plugin' table exists
  • Loading branch information
davidhicks committed Feb 25, 2012
1 parent ffc662b commit fa83030
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions application/core/database_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,14 @@ function db_insert_id( $table = null, $field = "id" ) {
* @return bool indicating whether the table exists
*/
function db_table_exists( $tableName ) {
global $g_db;

if( is_blank( $tableName ) ) {
return false;
}

$tableName = $g_db->getTableNamePrefix() . $tableName . $g_db->getTableNameSuffix();

$tables = db_get_table_list();

# Can't use in_array() since it is case sensitive
Expand Down
4 changes: 2 additions & 2 deletions application/core/plugin_api.php
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ function plugin_upgrade( $p_plugin ) {
$t_schema = $p_plugin->schema();

global $g_db;
$t_dict = NewDataDictionary( $g_db );
$t_dict = new Dictionary( $g_db );

$i = $t_schema_version + 1;
while( $i < count( $t_schema ) ) {
Expand Down Expand Up @@ -844,7 +844,7 @@ function plugin_register_installed() {
* Post-signals EVENT_PLUGIN_INIT.
*/
function plugin_init_installed() {
if( OFF == config_get_global( 'plugins_enabled' ) || !db_table_exists( 'plugin' ) ) {
if( config_get_global( 'plugins_enabled' ) == OFF ) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion public/admin/upgrade_unattended.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function print_test_result( $p_result, $p_hard_fail = true, $p_message = '' ) {

while(( $i <= $lastid ) && !$g_failed ) {
echo 'Create Schema ( ' . $upgrade[$i][0] . ' on ' . $upgrade[$i][1][0] . ' )';
$dict = NewDataDictionary( $g_db );
$dict = new Dictionary( $g_db );

if( $upgrade[$i][0] == 'InsertData' ) {
$sqlarray = call_user_func_array( $upgrade[$i][0], $upgrade[$i][1] );
Expand Down

0 comments on commit fa83030

Please sign in to comment.