r110952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r110951‎ | r110952 | r110953 >
Date:19:48, 8 February 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on logging and revisoning
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPCourse.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPPageObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPRevisionedObject.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -81,17 +81,6 @@
8282
8383 /**
8484 * (non-PHPdoc)
85 - * @see EPDBObject::getLogInfo()
86 - */
87 - protected function getLogInfo( $subType ) {
88 - return array(
89 - 'type' => 'institution',
90 - 'title' => $this->getTitle(),
91 - );
92 - }
93 -
94 - /**
95 - * (non-PHPdoc)
9685 * @see EPDBObject::loadSummaryFields()
9786 */
9887 public function loadSummaryFields( $summaryFields = null ) {
Index: trunk/extensions/EducationProgram/includes/EPRevisionedObject.php
@@ -92,7 +92,6 @@
9393
9494 /**
9595 * Store the current version of the object in the revisions table.
96 - * TODO: add handling for comment, minor edit, ect stuff
9796 *
9897 * @since 0.1
9998 *
@@ -105,7 +104,7 @@
106105 if ( $this->revAction !== false ) {
107106 $revision->setFields( array(
108107 'minor_edit' => $this->revAction->isMinor(),
109 - 'deleted' => $this->revAction->deleted(),
 108+ 'deleted' => $this->revAction->isDelete(),
110109 'time' => $this->revAction->getTime(),
111110 'comment' => $this->revAction->getComment(),
112111 'user_id' => $this->revAction->getUser()->getId(),
@@ -133,6 +132,7 @@
134133 if ( $info !== false ) {
135134 if ( $this->revAction !== false ) {
136135 $info['user'] = $this->revAction->getUser();
 136+ $info['comment'] = $this->revAction->getComment();
137137 }
138138
139139 $info['subtype'] = $subType;
@@ -205,7 +205,7 @@
206206 $result = parent::insert();
207207
208208 if ( $result ) {
209 - $this->storeRevision( $this->getCurrentRevision() );
 209+ $this->storeRevision( EPRevision::newFromObject( $this ) );
210210 $this->log( 'add' );
211211 }
212212
@@ -217,16 +217,36 @@
218218 * @see EPDBObject::remove()
219219 */
220220 public function remove() {
 221+ $object = clone $this;
 222+ $object->loadFields();
 223+
221224 $success = parent::remove();
222225
223226 if ( $success ) {
224 - $this->log( 'remove' );
 227+ $object->onRemoved();
225228 }
226229
227230 return $success;
228231 }
229232
230 - public function logRmove() {
 233+ /**
 234+ * @since 0.1
 235+ *
 236+ * @param EPRevisionAction $revAction
 237+ */
 238+ public function handleRemoved( EPRevisionAction $revAction ) {
 239+ $this->setRevisionAction( $revAction );
 240+ $this->onRemoved();
 241+ }
 242+
 243+ /**
 244+ * Do logging and revision storage after a removal.
 245+ * The object needs to have all it's fields loaded.
 246+ *
 247+ * @since 0.1
 248+ */
 249+ protected function onRemoved() {
 250+ //$this->storeRevision( EPRevision::newFromObject( $this ) );
231251 $this->log( 'remove' );
232252 }
233253
Index: trunk/extensions/EducationProgram/includes/EPCourse.php
@@ -787,5 +787,5 @@
788788
789789 EPUtils::log( $info );
790790 }
791 -
 791+
792792 }
Index: trunk/extensions/EducationProgram/includes/EPPageObject.php
@@ -25,6 +25,7 @@
2626 'edit-right' => 'ep-course',
2727 'identifier' => 'name',
2828 'list' => 'Courses',
 29+ 'log-type' => 'course',
2930 ),
3031 'EPOrg' => array(
3132 'ns' => EP_NS_INSTITUTION,
@@ -36,6 +37,7 @@
3738 'edit-right' => 'ep-org',
3839 'identifier' => 'name',
3940 'list' => 'Institutions',
 41+ 'log-type' => 'institution',
4042 ),
4143 );
4244
@@ -119,19 +121,29 @@
120122 $success = true;
121123
122124 if ( count( $objects ) > 0 ) {
123 - $success = static::delete( $conditions );
 125+ $success = true;//static::delete( $conditions );
124126
125127 if ( $success ) {
126128 $revAction->setDelete( true );
127129
128130 foreach ( $objects as /* EPPageObject */ $object ) {
129 - // TODO
130 - // $object->logRemove();
 131+ $object->handleRemoved( $revAction );
131132 }
132133 }
133134 }
134135
135136 return $success;
136137 }
 138+
 139+ /**
 140+ * (non-PHPdoc)
 141+ * @see EPRevisionedObject::getLogInfo()
 142+ */
 143+ protected function getLogInfo( $subType ) {
 144+ return array(
 145+ 'type' => self::$info[get_called_class()]['log-type'],
 146+ 'title' => $this->getTitle(),
 147+ );
 148+ }
137149
138 -}
\ No newline at end of file
 150+}

Status & tagging log