Merge "[JobQueue] Added a JobQueueRedis class."
[lhc/web/wiklou.git] / includes / db / ORMRow.php
index 1753afe..6acc124 100644 (file)
@@ -31,7 +31,7 @@
  * @author Jeroen De Dauw < jeroendedauw@gmail.com >
  */
 
-abstract class ORMRow implements IORMRow {
+class ORMRow implements IORMRow {
 
        /**
         * The fields of the object.
@@ -120,7 +120,8 @@ abstract class ORMRow implements IORMRow {
                        $result = $this->table->rawSelectRow(
                                $this->table->getPrefixedFields( $fields ),
                                array( $this->table->getPrefixedField( 'id' ) => $this->getId() ),
-                               array( 'LIMIT' => 1 )
+                               array( 'LIMIT' => 1 ),
+                               __METHOD__
                        );
 
                        if ( $result !== false ) {
@@ -263,8 +264,10 @@ abstract class ORMRow implements IORMRow {
                                switch ( $type ) {
                                        case 'array':
                                                $value = (array)$value;
+                                               // fall-through!
                                        case 'blob':
                                                $value = serialize( $value );
+                                               // fall-through!
                                }
 
                                $values[$this->table->getPrefixedField( $name )] = $value;
@@ -356,6 +359,8 @@ abstract class ORMRow implements IORMRow {
                        is_null( $functionName ) ? __METHOD__ : $functionName
                );
 
+               $this->table->releaseConnection( $dbw );
+
                // DatabaseBase::update does not always return true for success as documented...
                return $success !== false;
        }
@@ -389,7 +394,7 @@ abstract class ORMRow implements IORMRow {
                        $this->table->getName(),
                        $this->getWriteValues(),
                        is_null( $functionName ) ? __METHOD__ : $functionName,
-                       is_null( $options ) ? array( 'IGNORE' ) : $options
+                       $options
                );
 
                // DatabaseBase::insert does not always return true for success as documented...
@@ -399,6 +404,8 @@ abstract class ORMRow implements IORMRow {
                        $this->setField( 'id', $dbw->insertId() );
                }
 
+               $this->table->releaseConnection( $dbw );
+
                return $success;
        }
 
@@ -412,7 +419,7 @@ abstract class ORMRow implements IORMRow {
        public function remove() {
                $this->beforeRemove();
 
-               $success = $this->table->delete( array( 'id' => $this->getId() ) );
+               $success = $this->table->delete( array( 'id' => $this->getId() ), __METHOD__ );
 
                // DatabaseBase::delete does not always return true for success as documented...
                $success = $success !== false;
@@ -447,8 +454,8 @@ abstract class ORMRow implements IORMRow {
        }
 
        /**
-        * Gets called after successfull removal.
-        * Can be overriden to get rid of linked data.
+        * Gets called after successful removal.
+        * Can be overridden to get rid of linked data.
         *
         * @since 1.20
         */
@@ -573,6 +580,8 @@ abstract class ORMRow implements IORMRow {
                        $this->setField( $field, $this->getField( $field ) + $amount );
                }
 
+               $this->table->releaseConnection( $dbw );
+
                return $success;
        }