Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1052 from realityking/dboptimize

Remove dependency on several classes from the database package.
  • Loading branch information...
commit e11b726f9fc2c183ae39c0d58e84b4e7be89e6f0 2 parents ea7522a + 638b863
@LouisLandry LouisLandry authored
View
18 libraries/joomla/database/driver.php
@@ -180,20 +180,22 @@ public static function getConnectors()
// Instantiate variables.
$connectors = array();
- // Get a list of types.
- $types = JFolder::files(__DIR__ . '/driver');
+ // Get an iterator and loop trough the driver classes.
+ $iterator = new DirectoryIterator(__DIR__ . '/driver');
- // Loop through the types and find the ones that are available.
- foreach ($types as $type)
+ foreach ($iterator as $file)
{
- // Ignore some files.
- if (($type == 'index.html') || stripos($type, 'importer') || stripos($type, 'exporter') || stripos($type, 'query') || stripos($type, 'exception'))
+ $fileName = $file->getFilename();
+
+ // Only load for php files.
+ // Note: DirectoryIterator::getExtension only available PHP >= 5.3.6
+ if (!$file->isFile() || substr($fileName, strrpos($fileName, '.') + 1) != 'php')
{
continue;
}
// Derive the class name from the type.
- $class = str_ireplace('.php', '', 'JDatabaseDriver' . ucfirst(trim($type)));
+ $class = str_ireplace('.php', '', 'JDatabaseDriver' . ucfirst(trim($fileName)));
// If the class doesn't exist we have nothing left to do but look at the next type. We did our best.
if (!class_exists($class))
@@ -206,7 +208,7 @@ public static function getConnectors()
if ($class::isSupported() || $class::test())
{
// Connector names should not have file extensions.
- $connectors[] = str_ireplace('.php', '', $type);
+ $connectors[] = str_ireplace('.php', '', $fileName);
}
}
View
2  libraries/joomla/database/driver/postgresql.php
@@ -1020,7 +1020,7 @@ public function getAlterDbCharacterSet( $dbName )
/**
* Get the query string to create new Database in correct PostgreSQL syntax.
*
- * @param JObject $options JObject coming from "initialise" function to pass user
+ * @param object $options object coming from "initialise" function to pass user
* and database name to database driver.
* @param boolean $utf True if the database supports the UTF-8 character set,
* not used in PostgreSQL "CREATE DATABASE" query.
View
2  libraries/joomla/database/exception.php
@@ -20,6 +20,6 @@
* @since 11.1
* @deprecated 12.3 Use semantic exceptions instead
*/
-class JDatabaseException extends Exception
+class JDatabaseException extends RuntimeException
{
}
View
6 libraries/joomla/database/exporter/mysql.php
@@ -53,7 +53,7 @@ class JDatabaseExporterMysql extends JDatabaseExporter
/**
* An array of options for the exporter.
*
- * @var JObject
+ * @var object
* @since 11.1
*/
protected $options = null;
@@ -67,7 +67,7 @@ class JDatabaseExporterMysql extends JDatabaseExporter
*/
public function __construct()
{
- $this->options = new JObject;
+ $this->options = new stdClass;
$this->cache = array('columns' => array(), 'keys' => array());
@@ -292,7 +292,7 @@ public function setDbo(JDatabaseDriverMysql $db)
*/
public function withStructure($setting = true)
{
- $this->options->set('with-structure', (boolean) $setting);
+ $this->options->withStructure = (boolean) $setting;
return $this;
}
View
6 libraries/joomla/database/exporter/postgresql.php
@@ -53,7 +53,7 @@ class JDatabaseExporterPostgresql extends JDatabaseExporter
/**
* An array of options for the exporter.
*
- * @var JObject
+ * @var object
* @since 12.1
*/
protected $options = null;
@@ -67,7 +67,7 @@ class JDatabaseExporterPostgresql extends JDatabaseExporter
*/
public function __construct()
{
- $this->options = new JObject;
+ $this->options = new stdClass;
$this->cache = array('columns' => array(), 'keys' => array());
@@ -306,7 +306,7 @@ public function setDbo(JDatabasePostgresql $db)
*/
public function withStructure($setting = true)
{
- $this->options->set('with-structure', (boolean) $setting);
+ $this->options->withStructure = (boolean) $setting;
return $this;
}
View
18 libraries/joomla/database/factory.php
@@ -177,24 +177,6 @@ public function getQuery($name, JDatabaseDriver $db = null)
}
/**
- * Static method to get an instance of a JTable class if it can be found in
- * the table include paths. To add include paths for searching for JTable
- * classes @see JTable::addIncludePath().
- *
- * @param string $type The type (name) of the JTable class to get an instance of.
- * @param string $prefix An optional prefix for the table class name.
- * @param array $config An optional array of configuration values for the JTable object.
- *
- * @return mixed A JTable object if found or boolean false if one could not be found.
- *
- * @since 12.1
- */
- public function getTable($type, $prefix = 'JTable', $config = array())
- {
- return JTable::getInstance($type, $prefix, $config);
- }
-
- /**
* Gets an instance of a factory object to return on subsequent calls of getInstance.
*
* @param JDatabaseFactory $instance A JDatabaseFactory object.
View
6 libraries/joomla/database/importer/mysql.php
@@ -51,7 +51,7 @@ class JDatabaseImporterMysql extends JDatabaseImporter
/**
* An array of options for the exporter.
*
- * @var JObject
+ * @var object
* @since 11.1
*/
protected $options = null;
@@ -65,7 +65,7 @@ class JDatabaseImporterMysql extends JDatabaseImporter
*/
public function __construct()
{
- $this->options = new JObject;
+ $this->options = new stdClass;
$this->cache = array('columns' => array(), 'keys' => array());
@@ -646,7 +646,7 @@ public function setDbo(JDatabaseDriverMysql $db)
*/
public function withStructure($setting = true)
{
- $this->options->set('with-structure', (boolean) $setting);
+ $this->options->withStructure = (boolean) $setting;
return $this;
}
View
6 libraries/joomla/database/importer/postgresql.php
@@ -51,7 +51,7 @@ class JDatabaseImporterPostgresql extends JDatabaseImporter
/**
* An array of options for the exporter.
*
- * @var JObject
+ * @var object
* @since 12.1
*/
protected $options = null;
@@ -65,7 +65,7 @@ class JDatabaseImporterPostgresql extends JDatabaseImporter
*/
public function __construct()
{
- $this->options = new JObject;
+ $this->options = new stdClass;
$this->cache = array('columns' => array(), 'keys' => array());
@@ -788,7 +788,7 @@ public function setDbo(JDatabasePostgresql $db)
*/
public function withStructure($setting = true)
{
- $this->options->set('with-structure', (boolean) $setting);
+ $this->options->withStructure = (boolean) $setting;
return $this;
}
View
4 libraries/legacy/categories/categories.php
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
- * @subpackage Application
+ * @subpackage Categories
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -13,7 +13,7 @@
* JCategories Class.
*
* @package Joomla.Platform
- * @subpackage Application
+ * @subpackage Categories
* @since 11.1
*/
class JCategories
View
4 libraries/legacy/help/help.php
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
- * @subpackage Language
+ * @subpackage Help
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -13,7 +13,7 @@
* Help system class
*
* @package Joomla.Platform
- * @subpackage Language
+ * @subpackage Help
* @since 11.1
*/
class JHelp
View
4 libraries/legacy/menu/menu.php
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
- * @subpackage Application
+ * @subpackage Menu
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -13,7 +13,7 @@
* JMenu class
*
* @package Joomla.Platform
- * @subpackage Application
+ * @subpackage Menu
* @since 11.1
*/
class JMenu extends JObject
View
4 libraries/legacy/pathway/pathway.php
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
- * @subpackage Application
+ * @subpackage Pathway
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -15,7 +15,7 @@
* The user's navigated path within the application.
*
* @package Joomla.Platform
- * @subpackage Application
+ * @subpackage Pathway
* @since 11.1
*/
class JPathway extends JObject
View
4 libraries/legacy/request/request.php
@@ -1,7 +1,7 @@
<?php
/**
* @package Joomla.Platform
- * @subpackage Environment
+ * @subpackage Request
*
* @copyright Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
@@ -31,7 +31,7 @@
* can be passed through an input filter to avoid injection or returned raw.
*
* @package Joomla.Platform
- * @subpackage Environment
+ * @subpackage Request
* @since 11.1
* @deprecated 12.1 Get the JInput object from the application instead
*/
View
6 tests/suites/unit/joomla/database/database/JDatabaseExporterMySqlTest.php
@@ -549,21 +549,21 @@ public function testWithStructure()
);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The default use of withStructure should result in true.'
);
$instance->withStructure(true);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The explicit use of withStructure with true should result in true.'
);
$instance->withStructure(false);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isFalse(),
'The explicit use of withStructure with false should result in false.'
);
View
6 tests/suites/unit/joomla/database/database/JDatabaseExporterPostgresqlTest.php
@@ -649,21 +649,21 @@ public function testWithStructure()
);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The default use of withStructure should result in true.'
);
$instance->withStructure(true);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The explicit use of withStructure with true should result in true.'
);
$instance->withStructure(false);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isFalse(),
'The explicit use of withStructure with false should result in false.'
);
View
6 tests/suites/unit/joomla/database/database/JDatabaseImporterMySqlTest.php
@@ -825,21 +825,21 @@ public function testWithStructure()
);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The default use of withStructure should result in true.'
);
$instance->withStructure(true);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The explicit use of withStructure with true should result in true.'
);
$instance->withStructure(false);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isFalse(),
'The explicit use of withStructure with false should result in false.'
);
View
6 tests/suites/unit/joomla/database/database/JDatabaseImporterPostgresqlTest.php
@@ -1036,21 +1036,21 @@ public function testWithStructure()
);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The default use of withStructure should result in true.'
);
$instance->withStructure(true);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isTrue(),
'The explicit use of withStructure with true should result in true.'
);
$instance->withStructure(false);
$this->assertThat(
- $instance->options->get('with-structure'),
+ $instance->options->withStructure,
$this->isFalse(),
'The explicit use of withStructure with false should result in false.'
);
Please sign in to comment.
Something went wrong with that request. Please try again.