Skip to content

Commit a1ed414

Browse files
Bug Fix in uploads - null checks for Wikidata Place (commons-app#4567)
Fixes commons-app#4565
1 parent 6d073d2 commit a1ed414

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

app/src/main/java/fr/free/nrw/commons/db/AppDatabase.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import fr.free.nrw.commons.upload.depicts.DepictsDao
1414
* The database for accessing the respective DAOs
1515
*
1616
*/
17-
@Database(entities = [Contribution::class, Depicts::class, UploadedStatus::class], version = 8, exportSchema = false)
17+
@Database(entities = [Contribution::class, Depicts::class, UploadedStatus::class], version = 9, exportSchema = false)
1818
@TypeConverters(Converters::class)
1919
abstract class AppDatabase : RoomDatabase() {
2020
abstract fun contributionDao(): ContributionDao

app/src/main/java/fr/free/nrw/commons/upload/PageContentsCreator.java

+9-5
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,28 @@ class PageContentsCreator {
2626
private final Context context;
2727

2828
@Inject
29-
public PageContentsCreator(Context context) {
29+
public PageContentsCreator(final Context context) {
3030
this.context = context;
3131
}
3232

33-
public String createFrom(Contribution contribution, String countryCode) {
33+
public String createFrom(final Contribution contribution, final String countryCode) {
3434
StringBuilder buffer = new StringBuilder();
3535
final Media media = contribution.getMedia();
3636
buffer
3737
.append("== {{int:filedesc}} ==\n")
3838
.append("{{Information\n")
39-
.append("|description=").append(media.getFallbackDescription())
40-
.append("{{ on Wikidata|").append(contribution.getWikidataPlace().getId()).append("}}")
39+
.append("|description=").append(media.getFallbackDescription()).append("\n");
40+
if (contribution.getWikidataPlace() != null) {
41+
buffer.append("{{ on Wikidata|").append(contribution.getWikidataPlace().getId())
42+
.append("}}");
43+
}
44+
buffer
4145
.append("\n")
4246
.append("|source=").append("{{own}}\n")
4347
.append("|author=[[User:").append(media.getAuthor()).append("|")
4448
.append(media.getAuthor()).append("]]\n");
4549

46-
String templatizedCreatedDate = getTemplatizedCreatedDate(
50+
final String templatizedCreatedDate = getTemplatizedCreatedDate(
4751
contribution.getDateCreated(), contribution.getDateCreatedSource());
4852
if (!StringUtils.isBlank(templatizedCreatedDate)) {
4953
buffer.append("|date=").append(templatizedCreatedDate);

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class UploadWorker(var appContext: Context, workerParams: WorkerParameters) :
290290
//Upload the file from stash
291291
var countryCode: String? =null
292292
with(contribution.wikidataPlace?.location){
293-
if(contribution.wikidataPlace?.isMonumentUpload!!) {
293+
if (contribution.wikidataPlace?.isMonumentUpload == true) {
294294
countryCode =
295295
reverseGeoCode(contribution.wikidataPlace?.location!!)?.toLowerCase()
296296
}

0 commit comments

Comments
 (0)