?
avatar jsanchezgr
jsanchezgr
28 Jan 2016

When installing a component, if the sql file has a line starting with # the following statement will be ignored.

SQL Snippet

# Insert content history rows

INSERT INTO `#__content_types` (`type_title`, `type_alias`, `table`, `content_history_options`)
...

The issue is in splitSql()method of JDatabaseDriver. where both lines are returned as a single one. After spliting, there is a check to ignore comments, so the entire line (comment and insert) is skipped.

JInstaller sinppet where splitSql() is called

// Create an array of queries from the sql file
$queries = JDatabaseDriver::splitSql($buffer);

if (count($queries) == 0)
{
    // No queries to process
    return 0;
}

// Process each query in the $queries array (split out of sql file).
foreach ($queries as $query)
{
    $query = trim($query);

    if ($query != '' && $query{0} != '#')
    {
        $db->setQuery($query);

        if (!$db->execute())
        {
            JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING, 'jerror');

            return false;
        }
    }
}
avatar jsanchezgr jsanchezgr - open - 28 Jan 2016
avatar brianteeman brianteeman - change - 28 Jan 2016
The description was changed
Labels Added: ?
avatar brianteeman brianteeman - change - 16 Feb 2016
Status New Closed
Closed_Date 0000-00-00 00:00:00 2016-02-16 18:01:53
Closed_By brianteeman
avatar brianteeman
brianteeman - comment - 16 Feb 2016

Closing as we have a PR #9137


This comment was created with the J!Tracker Application at issues.joomla.org/joomla-cms/9008.

avatar brianteeman brianteeman - close - 16 Feb 2016

Add a Comment

Login with GitHub to post a comment