/** * Method to process SQL updates previous to the install process * * @param JInstallerAdapter $parent Class calling this method * * @return boolean True on success */ public function preprocessUpdates($parent) { $manifest = $parent->get('manifest'); if (isset($manifest->update)) { if (isset($manifest->update->attributes()->folder)) { $path = $manifest->update->attributes()->folder; if (isset($manifest->update->pre) && isset($manifest->update->pre->schemas)) { $schemapaths = $manifest->update->pre->schemas->children(); if (count($schemapaths)) { $sourcePath = $parent->getParent()->getPath('source'); // If it just upgraded redCORE to a newer version using RFactory for database, it forces using the redCORE database drivers if (substr(get_class(JFactory::$database), 0, 1) == 'J' && $this->extensionElement != 'com_redcore') { RFactory::$database = null; JFactory::$database = null; JFactory::$database = RFactory::getDbo(); } $db = JFactory::getDbo(); $dbDriver = strtolower($db->name); $schemapath = ''; if ($dbDriver == 'mysqli') { $dbDriver = 'mysql'; } foreach ($schemapaths as $entry) { if (isset($entry->attributes()->type)) { $uDriver = strtolower($entry->attributes()->type); if ($uDriver == 'mysqli') { $uDriver = 'mysql'; } if ($uDriver == $dbDriver) { $schemapath = (string) $entry; break; } } } if ($schemapath != '') { $files = str_replace('.sql', '', JFolder::files($sourcePath . '/' . $path . '/' . $schemapath, '\\.sql$')); usort($files, 'version_compare'); if (count($files)) { foreach ($files as $file) { if (version_compare($file, $this->oldVersion) > 0) { $buffer = file_get_contents($sourcePath . '/' . $path . '/' . $schemapath . '/' . $file . '.sql'); $queries = RHelperDatabase::splitSQL($buffer); if (count($queries)) { foreach ($queries as $query) { if ($query != '' && $query[0] != '#') { $db->setQuery($query); if (!$db->execute(true)) { JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_SQL_ERROR', $db->stderr(true)), JLog::WARNING, 'jerror'); return false; } } } } } } } } } } } } return true; }