View Issue Details

IDProjectCategoryView StatusLast Update
371PHPOF2Defaultpublic7 Nov 2011 17:12
Reportertimj Assigned To 
PrioritynormalSeveritymajorReproducibilityalways
Status newResolutionopen 
Product Version0.12.1 
Summary371: Add compatibility with MDB2 2.5.0b3+
DescriptionMDB2 2.5.0b3+ broke backwards compatibility :-(
See http://pear.php.net/bugs/bug.php?id=17858
TagsNo tags attached.
Attached Files
DB.php.bug371.patch (1,399 bytes)   
Index: DB.php
===================================================================
--- DB.php	(revision 50448)
+++ DB.php	(working copy)
@@ -27,7 +27,7 @@
 require_once 'PHPOF2/DBTable.php';
 
 
-class PHPOF2_DB extends MDB2 {
+abstract class PHPOF2_DB_Abstract extends MDB2 {
 
 	const LOB_PLACEHOLDER =   '!lob-data-present!';
 	const LOB_DELETEPENDING = '!lob-delete-pending!';
@@ -63,7 +63,7 @@
 	 * @param array $options Options to pass; can include any standard MDB2 options plus additional PHPOF2 ones (see the full documentation for this method)
 	 * @return MDB2
 	 */
-	function &factory($dsn, $options = false)
+	static function factoryInstance($dsn, $options = false)
 	{
 		// Options that are specific to PHPOF2_DB and are not to be passed to MDB2
 		// (MDB2 throws errors if it gets options it doesn't know about)
@@ -135,4 +135,28 @@
 		}
 		return $mdb2;
 	}
+	
+	public static function getApiVersion()
+	{
+		return self::apiVersion();
+	}
 }
+
+if (version_compare(PHPOF2_DB_Abstract::getApiVersion(), '2.5.0b3', '>=')) {
+	class PHPOF2_DB extends PHPOF2_DB_Abstract
+	{
+		static function factory($dsn, $options=false)
+		{
+			return self::factoryInstance($dsn, $options);
+		}
+	}
+} else {
+	class PHPOF2_DB extends PHPOF2_DB_Abstract
+	{
+		function &factory($dsn, $options=false)
+		{
+			$instance = self::factoryInstance($dsn, $options);
+			return $instance;
+		}
+	}
+}
DB.php.bug371.patch (1,399 bytes)   

Activities

mrosenquist

7 Nov 2011 12:11

reporter   ~406

Hi Tim,

From the comments on the pear bug it there wll not be any resolution. So I have put in place attached a possible fix, it is hacky but it is the cleanest solution for this situation that I could think of.

timj

7 Nov 2011 17:12

manager   ~407

That's a really clever hack :-)

Issue History

Date Modified Username Field Change
14 Sep 2010 12:19 timj New Issue
7 Nov 2011 12:07 mrosenquist File Added: DB.php.bug371.patch
7 Nov 2011 12:11 mrosenquist Note Added: 406
7 Nov 2011 17:12 timj Note Added: 407