Skip to content
Browse files

#$ [#27751] Installation - Check to ensure the schema file exists.

Thanks Michael and Mark
  • Loading branch information...
1 parent 4ff5c6d commit 2d0ece18e8694f0d4c04ed93584abab60e2117c5 @mbabker mbabker committed with infograf768 Mar 4, 2012
View
1 installation/CHANGELOG
@@ -28,6 +28,7 @@ $ -> Language fix or change
04-Mar-2012 Jean-Marie Simonet
# [#28190] com_search: Show Search Results results in PHP fatal error. Thanks John
+ #$ [#27751] Installation - Check to ensure the schema file exists. Thanks Michael and Mark
04-Mar-2012 Christophe Demko
# [#27770] loadposition strips the $ character from html modules
View
1 installation/language/en-AU/en-AU.ini
@@ -38,6 +38,7 @@ INSTL_DATABASE_HOST_DESC="This is usually "localhost""
INSTL_DATABASE_HOST_LABEL="Host Name"
INSTL_DATABASE_NAME_DESC="Some hosts allow only a certain DB name per site. Use table prefix in this case for distinct Joomla! sites."
INSTL_DATABASE_NAME_LABEL="Database Name"
+INSTL_DATABASE_NO_SCHEMA="No database schema exists for this database type."
INSTL_DATABASE_OLD_PROCESS_DESC="Any existing backup tables from former Joomla! installations will be replaced"
INSTL_DATABASE_OLD_PROCESS_LABEL="Old Database Process"
INSTL_DATABASE_PASSWORD_DESC="For site security using a password for the mysql account is mandatory"
View
1 installation/language/en-GB/en-GB.ini
@@ -38,6 +38,7 @@ INSTL_DATABASE_HOST_DESC="This is usually "localhost""
INSTL_DATABASE_HOST_LABEL="Host Name"
INSTL_DATABASE_NAME_DESC="Some hosts allow only a certain DB name per site. Use table prefix in this case for distinct Joomla! sites."
INSTL_DATABASE_NAME_LABEL="Database Name"
+INSTL_DATABASE_NO_SCHEMA="No database schema exists for this database type."
INSTL_DATABASE_OLD_PROCESS_DESC="Any existing backup tables from former Joomla! installations will be replaced"
INSTL_DATABASE_OLD_PROCESS_LABEL="Old Database Process"
INSTL_DATABASE_PASSWORD_DESC="For site security using a password for the mysql account is mandatory"
View
1 installation/language/en-US/en-US.ini
@@ -38,6 +38,7 @@ INSTL_DATABASE_HOST_DESC="This is usually "localhost""
INSTL_DATABASE_HOST_LABEL="Host Name"
INSTL_DATABASE_NAME_DESC="Some hosts allow only a certain DB name per site. Use table prefix in this case for distinct Joomla! sites."
INSTL_DATABASE_NAME_LABEL="Database Name"
+INSTL_DATABASE_NO_SCHEMA="No database schema exists for this database type."
INSTL_DATABASE_OLD_PROCESS_DESC="Any existing backup tables from former Joomla! installations will be replaced"
INSTL_DATABASE_OLD_PROCESS_LABEL="Old Database Process"
INSTL_DATABASE_PASSWORD_DESC="For site security using a password for the mysql account is mandatory"
View
12 installation/models/database.php
@@ -147,6 +147,12 @@ function initialise($options)
$type = $options->db_type;
$schema = 'sql/'.(($type == 'mysqli') ? 'mysql' : $type).'/joomla.sql';
+ // Check if the schema is a valid file
+ if (!JFile::exists($schema)) {
+ $this->setError(JText::sprintf('INSTL_ERROR_DB', JText::_('INSTL_DATABASE_NO_SCHEMA')));
+ return false;
+ }
+
// Attempt to import the database schema.
if (!$this->populateDatabase($db, $schema)) {
$this->setError(JText::sprintf('INSTL_ERROR_DB', $this->getError()));
@@ -189,7 +195,7 @@ function initialise($options)
$query->select('*');
$query->from('#__extensions');
$db->setQuery($query);
-
+
try
{
$extensions = $db->loadObjectList();
@@ -199,7 +205,7 @@ function initialise($options)
$this->setError($e->getMessage());
$return = false;
}
-
+
JFactory::$database = $db;
$installer = JInstaller::getInstance();
foreach ($extensions as $extension) {
@@ -451,7 +457,7 @@ public function populateDatabase(& $db, $schema)
if (!empty($query) && ($query{0} != '#')) {
// Execute the query.
$db->setQuery($query);
-
+
try
{
$db->query();

0 comments on commit 2d0ece1

Please sign in to comment.
Something went wrong with that request. Please try again.