r103980 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r103979‎ | r103980 | r103981 >
Date:23:28, 22 November 2011
Author:jeroendedauw
Status:reverted
Tags:
Comment:
Follow up to r103977;
Modified paths:
  • /trunk/extensions/Reviews/includes/Review.php (modified) (history)
  • /trunk/extensions/Reviews/includes/ReviewRating.php (modified) (history)
  • /trunk/extensions/Reviews/sql/Reviews.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/Reviews/sql/Reviews.sql
@@ -27,7 +27,7 @@
2828 CREATE TABLE IF NOT EXISTS /*_*/review_ratings (
2929 rating_id INT unsigned NOT NULL auto_increment PRIMARY KEY,
3030 rating_review_id INT unsigned NOT NULL,
31 - rating_type TINYINT unsigned NOT NULL,
 31+ rating_type VARCHAR(255) NOT NULL,
3232 rating_value TINYINT unsigned NOT NULL
3333 ) /*$wgDBTableOptions*/;
3434
Index: trunk/extensions/Reviews/includes/Review.php
@@ -110,9 +110,15 @@
111111 $success = parent::insertIntoDB();
112112
113113 if ( $success && $this->ratings !== false ) {
 114+ $dbw = wfGetDB( DB_MASTER );
 115+ $dbw->begin();
 116+
114117 foreach ( $this->getRatings() as /* ReviewRating */ $rating ) {
 118+ $rating->setField( 'review_id', $this->getId() );
115119 $rating->writeToDB();
116120 }
 121+
 122+ $dbw->commit();
117123 }
118124
119125 return $success;
@@ -133,11 +139,19 @@
134140 $existing[$rating->getField( 'type' )] = $rating->getField( 'id' );
135141 }
136142
 143+ $dbw = wfGetDB( DB_MASTER );
 144+ $dbw->begin();
 145+
137146 foreach ( $this->getRatings() as /* ReviewRating */ $rating ) {
138147 if ( array_key_exists( $rating->getField( 'type' ), $existing ) ) {
139148 $rating->setField( 'id', $existing[$rating->getField( 'type' )] );
140149 }
 150+
 151+ $rating->setField( 'review_id', $this->getId() );
 152+ $rating->writeToDB();
141153 }
 154+
 155+ $dbw->commit();
142156 }
143157
144158 return $success;
@@ -194,7 +208,7 @@
195209 foreach ( $ratings as $type => $value ) {
196210 $objects[] = new ReviewRating( array(
197211 'type' => $type,
198 - 'id' => $value
 212+ 'value' => $value
199213 ) );
200214 }
201215
Index: trunk/extensions/Reviews/includes/ReviewRating.php
@@ -47,7 +47,7 @@
4848 'id' => 'id',
4949 'review_id' => 'int',
5050
51 - 'type' => 'int',
 51+ 'type' => 'str',
5252 'value' => 'int'
5353 );
5454 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r103977work on rating functionalityjeroendedauw23:04, 22 November 2011

Status & tagging log