Index: branches/license-work/phase3/includes/filerepo/FileProperties.php |
— | — | @@ -9,7 +9,7 @@ |
10 | 10 | * @param $revision int Revision id |
11 | 11 | */ |
12 | 12 | public function __construct( $file, $revision = null ) { |
13 | | - $this->file = file; |
| 13 | + $this->file = $file; |
14 | 14 | $this->revId = $revision; |
15 | 15 | |
16 | 16 | $this->authors = array(); |
— | — | @@ -69,14 +69,14 @@ |
70 | 70 | public function getAuthors() { |
71 | 71 | return $this->authors; |
72 | 72 | } |
73 | | - |
| 73 | + |
74 | 74 | /** |
75 | | - * Save the licenses and authors to the database |
| 75 | + * Save the licenses and authors to the database and create a new revision |
76 | 76 | * |
77 | 77 | * @param $comment string Edit summary |
78 | 78 | * @param $minor bool Minor edit |
79 | | - */ |
80 | | - public function save( $comment, $minor = false ) { |
| 79 | + */ |
| 80 | + public function saveWithNewRevision( $comment, $minor = false ) { |
81 | 81 | $dbw = $this->file->getRepo()->getMasterDB(); |
82 | 82 | |
83 | 83 | $rev = Revision::newNullRevision( $dbw, |
— | — | @@ -84,12 +84,22 @@ |
85 | 85 | $comment, $minor ); |
86 | 86 | $rev->insertOn( $dbw ); |
87 | 87 | |
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(); |
89 | 99 | |
90 | 100 | $insert = array(); |
91 | 101 | foreach ( $this->authors as $author ) { |
92 | 102 | $a = array( |
93 | | - 'fp_rev_id' => $id, |
| 103 | + 'fp_rev_id' => $revId, |
94 | 104 | 'fp_key' => 'author', |
95 | 105 | 'fp_value_int' => $author->getId() |
96 | 106 | ); |
— | — | @@ -102,7 +112,7 @@ |
103 | 113 | } |
104 | 114 | foreach ( $this->licenses as $license ) { |
105 | 115 | $insert[] = array( |
106 | | - 'fp_rev_id' => $id, |
| 116 | + 'fp_rev_id' => $revId, |
107 | 117 | 'fp_key' => 'license', |
108 | 118 | 'fp_value_int' => $license->getId(), |
109 | 119 | ); |
— | — | @@ -110,6 +120,8 @@ |
111 | 121 | |
112 | 122 | |
113 | 123 | $dbw->insert( 'file_props', $insert, __METHOD__ ); |
| 124 | + |
| 125 | + $this->revId = $revId; |
114 | 126 | } |
115 | 127 | } |
116 | 128 | |