r80462 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80461‎ | r80462 | r80463 >
Date:20:17, 17 January 2011
Author:btongminh
Status:deferred
Tags:license-work 
Comment:
Add support for both null revisions and existing revisions. This may be useless depending on the database design, but I want it out of the way.
Modified paths:
  • /branches/license-work/phase3/includes/filerepo/FileProperties.php (modified) (history)

Diff [purge]

Index: branches/license-work/phase3/includes/filerepo/FileProperties.php
@@ -9,7 +9,7 @@
1010 * @param $revision int Revision id
1111 */
1212 public function __construct( $file, $revision = null ) {
13 - $this->file = file;
 13+ $this->file = $file;
1414 $this->revId = $revision;
1515
1616 $this->authors = array();
@@ -69,14 +69,14 @@
7070 public function getAuthors() {
7171 return $this->authors;
7272 }
73 -
 73+
7474 /**
75 - * Save the licenses and authors to the database
 75+ * Save the licenses and authors to the database and create a new revision
7676 *
7777 * @param $comment string Edit summary
7878 * @param $minor bool Minor edit
79 - */
80 - public function save( $comment, $minor = false ) {
 79+ */
 80+ public function saveWithNewRevision( $comment, $minor = false ) {
8181 $dbw = $this->file->getRepo()->getMasterDB();
8282
8383 $rev = Revision::newNullRevision( $dbw,
@@ -84,12 +84,22 @@
8585 $comment, $minor );
8686 $rev->insertOn( $dbw );
8787
88 - $id = $rev->getId();
 88+ $this->save( $rev->getId() );
 89+ }
 90+
 91+ /**
 92+ * Save the licenses and authors to the database associated with a certain
 93+ * revision
 94+ *
 95+ * @param $revId int Revision id
 96+ */
 97+ public function save( $revId ) {
 98+ $dbw = $this->file->getRepo()->getMasterDB();
8999
90100 $insert = array();
91101 foreach ( $this->authors as $author ) {
92102 $a = array(
93 - 'fp_rev_id' => $id,
 103+ 'fp_rev_id' => $revId,
94104 'fp_key' => 'author',
95105 'fp_value_int' => $author->getId()
96106 );
@@ -102,7 +112,7 @@
103113 }
104114 foreach ( $this->licenses as $license ) {
105115 $insert[] = array(
106 - 'fp_rev_id' => $id,
 116+ 'fp_rev_id' => $revId,
107117 'fp_key' => 'license',
108118 'fp_value_int' => $license->getId(),
109119 );
@@ -110,6 +120,8 @@
111121
112122
113123 $dbw->insert( 'file_props', $insert, __METHOD__ );
 124+
 125+ $this->revId = $revId;
114126 }
115127 }
116128

Status & tagging log