Moodle
  1. Moodle
  2. MDL-19303 META: XMLDB Editor various bugs/improvements
  3. MDL-31527

XMLDB Editor - misnamed default table for blocks (and probably other types)

    Details

    • Testing Instructions:
      Hide

      Choose any built-in block which does not currently have any database tables.
      Create a 'db' subfolder for that block and make sure it is writeable by your web server (chmod a+w is a simple, if insecure way of achieving this)
      Open up the XMLDB editor, scroll down to the block and click on 'Create', 'Load', 'Edit' (in that order).
      Expected result:
      Default table is called 'block_XXX' (where XXX is the name of the block)
      Current result:
      Default table is called 'XXX' (just the name of the block)

      Show
      Choose any built-in block which does not currently have any database tables. Create a 'db' subfolder for that block and make sure it is writeable by your web server (chmod a+w is a simple, if insecure way of achieving this) Open up the XMLDB editor, scroll down to the block and click on 'Create', 'Load', 'Edit' (in that order). Expected result: Default table is called 'block_XXX' (where XXX is the name of the block) Current result: Default table is called 'XXX' (just the name of the block)
    • Workaround:
      Hide

      Remember to rename the table

      Show
      Remember to rename the table
    • Affected Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE, MOODLE_23_STABLE
    • Fixed Branches:
      MOODLE_21_STABLE, MOODLE_22_STABLE
    • Pull Master Branch:
      MDL-31527_xmldb_table_names

      Description

      If you are create a block, with no database tables, then use the XMLDB editor to create a install.xml file, the the name of the table will not include the 'block_' prefix (I assume this is the same for other plugin types).

      This wouldn't be a major issue, except that attempting to submit a plugin (or even an updated version of a plugin) to the Moodle.org plugins database will give an unavoidable error if your database block's database tables don't start 'block_'. This is annoying if you are releasing a new plugin (as it involves a whole lot of search and replace) and doubly so if you are trying to release an update (as you then need to add upgrade code to rename the tables as well).

        Gliffy Diagrams

          Activity

          Hide
          Michael de Raadt added a comment -

          Thanks for reporting that, Davo.

          I've put that on the backlog.

          In the meantime feel free to help us work on this issue. If you are able to provide a patch, please add a patch label so we will spot it.

          Show
          Michael de Raadt added a comment - Thanks for reporting that, Davo. I've put that on the backlog. In the meantime feel free to help us work on this issue. If you are able to provide a patch, please add a patch label so we will spot it.
          Hide
          Davo Smith added a comment -

          Working on a fix

          Show
          Davo Smith added a comment - Working on a fix
          Hide
          Davo Smith added a comment -

          This does a quick loop through the results of 'get_plugin_types' to identify the plugin type that the database is being created for, then (unless it is of type 'mod') prepends 'plugintype_' onto the default table to create.

          Show
          Davo Smith added a comment - This does a quick loop through the results of 'get_plugin_types' to identify the plugin type that the database is being created for, then (unless it is of type 'mod') prepends 'plugintype_' onto the default table to create.
          Hide
          Rajesh Taneja added a comment - - edited

          Thanks for one more spot-on patch, Davo
          Only thing is @param in dockblock for get_plugin_type.
          It should be

          @param string $dirpath path to the db file for this plugin
          

          Please refer http://docs.moodle.org/dev/Coding_style#Functions

          FYI: Spacing is not mandatory

          Show
          Rajesh Taneja added a comment - - edited Thanks for one more spot-on patch, Davo Only thing is @param in dockblock for get_plugin_type. It should be @param string $dirpath path to the db file for this plugin Please refer http://docs.moodle.org/dev/Coding_style#Functions FYI: Spacing is not mandatory
          Hide
          Davo Smith added a comment -

          I've updated the repo with the fixed PHPDocs

          Show
          Davo Smith added a comment - I've updated the repo with the fixed PHPDocs
          Hide
          Rajesh Taneja added a comment -

          Thanks for the quick fix, Davo.
          Pushing it for integration review.

          Show
          Rajesh Taneja added a comment - Thanks for the quick fix, Davo. Pushing it for integration review.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          Integrated (21, 22 & master), thanks!

          Show
          Eloy Lafuente (stronk7) added a comment - Integrated (21, 22 & master), thanks!
          Hide
          Andrew Davis added a comment -

          Works as described. Passing.

          Show
          Andrew Davis added a comment - Works as described. Passing.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          It is late here and I'm very tired but I didn't want to go to sleep before expressing my admiration for your amazing collaboration. Thanks!

          Closing as fixed, heading to zzzZZZzzz, niao

          Show
          Eloy Lafuente (stronk7) added a comment - It is late here and I'm very tired but I didn't want to go to sleep before expressing my admiration for your amazing collaboration. Thanks! Closing as fixed, heading to zzzZZZzzz, niao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: