Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/197777
Change subject: WIP: Illustrate collections
......................................................................
WIP: Illustrate collections
This sets a page image when absent when the user views a collection
This is not perfect (if a user shares a URL before visiting that collection
it will not be illustrated) but it seems the safest way to do this efficiently
for the time being.
Ideally this should be run on every insert/remove operation but that would mean
iterating through all items in a collection and 3 saves to the database (we
have to
check the list exists first before adding the item and then we have to access
all the
items in that collection to access the page imageS)
Bug: T91675
Change-Id: I026b8fe21626d76825e617b753c6d4c6f1769907
---
M includes/models/Collection.php
M includes/specials/SpecialGather.php
2 files changed, 3 insertions(+), 4 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Gather
refs/changes/77/197777/1
diff --git a/includes/models/Collection.php b/includes/models/Collection.php
index 47aebe0..332c916 100644
--- a/includes/models/Collection.php
+++ b/includes/models/Collection.php
@@ -123,7 +123,7 @@
public function updateImageToApi( $image ) {
$api = new ApiMain( new FauxRequest( array(
'action' => 'editlist',
- 'lstid' => $this->getId(),
+ 'id' => $this->getId(),
'image' => $image,
) ) );
$api->execute();
@@ -162,7 +162,7 @@
if ( isset( $lists[0] ) ) {
$list = $lists[0];
$collection = new Collection( $id,
$user, $list['label'], $list['description'],
- $list['public'],
$list['image'], $list['watchlist'] );
+ $list['public'],
$list['image'], isset( $list['watchlist'] ) && $list['watchlist'] );
}
}
diff --git a/includes/specials/SpecialGather.php
b/includes/specials/SpecialGather.php
index b0d477e..a4130a2 100644
--- a/includes/specials/SpecialGather.php
+++ b/includes/specials/SpecialGather.php
@@ -94,9 +94,8 @@
if ( !$collection->hasImage() && $this->isOwner( $user
) && !$collection->isWatchlist() ) {
// try to set the collection image to the first
item in the collection.
try {
- echo 'here';
$collection->updateImageToApi(
$collection->getSuggestedImage() );
- } catch ( Exception $e ) {
+ } catch ( UsageException $e ) {
}
}
}
--
To view, visit https://gerrit.wikimedia.org/r/197777
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I026b8fe21626d76825e617b753c6d4c6f1769907
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Gather
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits