r108821 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r108820‎ | r108821 | r108822 >
Date:17:09, 13 January 2012
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on logging code
Modified paths:
  • /trunk/extensions/EducationProgram/includes/EPDBObject.php (modified) (history)
  • /trunk/extensions/EducationProgram/includes/EPOrg.php (modified) (history)

Diff [purge]

Index: trunk/extensions/EducationProgram/includes/EPOrg.php
@@ -75,12 +75,10 @@
7676 * @see EPDBObject::createLogEntry()
7777 */
7878 protected function createLogEntry( $subType ) {
79 - $logEntry = new ManualLogEntry( 'institution', $subType );
80 -
81 - $logEntry->setPerformer( $GLOBALS['wgUser'] );
82 - $logEntry->setTarget( $this->getTitle() );
83 -
84 - return $logEntry;
 79+ return array(
 80+ 'type' => 'institution',
 81+ 'title' => $this->getTitle(),
 82+ );
8583 }
8684
8785 /**
Index: trunk/extensions/EducationProgram/includes/EPDBObject.php
@@ -459,26 +459,35 @@
460460 */
461461 protected function log( $subType ) {
462462 if ( $this->log ) {
463 - $logEntry = $this->createLogEntry( $subType );
 463+ if ( class_exists( 'ManualLogEntry' ) ) {
 464+ $info = $this->getLogInfo( $subType );
464465
465 - if ( createLogEntry !== false ) {
466 - $logid = $logEntry->insert();
467 - $logEntry->publish( $logid );
 466+ if ( $info !== false ) {
 467+ $logEntry = new ManualLogEntry( $info['type'], $subType );
 468+
 469+ $logEntry->setPerformer( array_key_exists( 'user', $info ) ? $info['user'] : $GLOBALS['wgUser'] );
 470+ $logEntry->setTarget( $info['title'] );
 471+
 472+ $logid = $logEntry->insert();
 473+ $logEntry->publish( $logid );
 474+ }
468475 }
 476+ else {
 477+ // TODO
 478+ }
469479 }
470480 }
471481
472482 /**
473 - * Override and create and return a log entry to
474 - * make the log method have an actual effect.
 483+ * Returns the info for the log entry or false if no entry should be created.
475484 *
476485 * @since 0.1
477486 *
478487 * @param string $subType
479488 *
480 - * @return false|ManualLogEntry
 489+ * @return array|false
481490 */
482 - protected function createLogEntry( $subType ) {
 491+ protected function getLogInfo( $subType ) {
483492 return false;
484493 }
485494

Status & tagging log