Page 1 of 1

getTableList() clarification

Posted: Fri Dec 02, 2011 3:32 pm
by matt_t_hat
On the Overview of the class NucleusPlugin (redefinable methods) in the documentation here there is a vital part of the documentation for getTableList() that I feel could use clarification.

It has to do with the use of sql_table() which has been with use since v2.0.

Which is correct?

Code: Select all

getTableList(){
return array('plugin_bob_mytable','plugin_bob_myothertable');
}


or

Code: Select all

getTableList(){
return array(sql_table('plugin_bob_mytable'),sql_table('plugin_bob_myothertable'));
}


If I assume lazy programming than the second would be the case but if I assume user-oriented "helpful" programming that has made assumptions of it's own then I should choose the first.

However neither option feels satisfactory to me as a good example of the way such data should be handled.

Regardless of my own minor niggle I still need to know the format that is expected in the return array.

Posted: Fri Dec 02, 2011 4:43 pm
by ftruscot
The method should return an array of table names ready for use by the backup process. It appears that the backup script takes each value returned in the array (as is), and tries to backup a table by that name.

So the plugin method getTableList() should return an array of table names as they appear in the db. For example, if a plugin implements this method in the following way (assuming a $MYSQL_PREFIX of 'lucy_'):

Code: Select all

function getTableList() {
   return array(
         sql_table('plug_myplugin_foo'),
         sql_table('plug_myplugin_bar'),
         'nucleus_fred_mertz',
         str_replace('fred','ethel','fred_mertz')
   );
}

The tables that would be backed up would be:

lucy_nucleus_plug_myplugin_foo,
lucy_nucleus_plug_myplugin_bar,
nucleus_fred_mertz,
ethel_mertz

Posted: Fri Dec 02, 2011 6:13 pm
by matt_t_hat
It's always good to clear these things up.