Skip to content

Commit

Permalink
minor edits for zotero#153
Browse files Browse the repository at this point in the history
  • Loading branch information
abaevbog committed Jun 23, 2023
1 parent ecbbbc2 commit e1a47e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion controllers/ApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ public function init($extra) {

// Sorting by Item Type or Added By currently require writing to shard tables, so don't
// send those to the read replicas
if ($this->queryParams['sort'] == 'itemType' || $this->queryParams['sort'] == 'addedBy' || $this->queryParams['sort'] == 'editedBy') {
if (in_array($this->queryParams['sort'], ['itemType', 'addedBy', 'editedBy'])) {
Zotero_DB::readOnly(false);
}

Expand Down
8 changes: 4 additions & 4 deletions model/Items.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ public static function search($libraryID, $onlyTopLevel = false, array $params =
$sql .= "JOIN tmpItemTypeNames TITN ON (TITN.itemTypeID=$itemTypeIDSelector) ";
break;

case 'editedBy':
case 'addedBy':
case 'editedBy':
$isGroup = Zotero_Libraries::getType($libraryID) == 'group';
$userParameter = $params['sort'] == "editedBy" ? 'lastModifiedByUserID' : 'createdByUserID';
$userParameter = $params['sort'] == "addedBy" ? 'createdByUserID' : 'lastModifiedByUserID';
if ($isGroup) {
$sql2 = "SELECT DISTINCT $userParameter FROM items
JOIN groupItems USING (itemID) WHERE
Expand Down Expand Up @@ -551,9 +551,9 @@ public static function search($libraryID, $onlyTopLevel = false, array $params =
case 'date':
$orderSQL = "$sortTable.value";
break;

case 'editedBy':

case 'addedBy':
case 'editedBy':
if ($isGroup && $createdByUserIDs) {
$orderSQL = "TCBU.username";
}
Expand Down

0 comments on commit e1a47e3

Please sign in to comment.