-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rate limiting updates #141
Open
abaevbog
wants to merge
4
commits into
zotero:master
Choose a base branch
from
abaevbog:rate_limiting_updates
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
10142fd
using ->end() instead of exit in controllers
abaevbog 3efb9c3
on 429 error, make client wait till full capacity is reached before n…
abaevbog 1758fb9
removed unecessary header setting
abaevbog 3cbf246
default format for mapping action v1/v2 as json
abaevbog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,9 @@ public function mappings() { | |
$locale = !empty($_GET['locale']) | ||
? \Zotero\Schema::resolveLocale($_GET['locale']) | ||
: 'en-US'; | ||
|
||
unset($this->queryParams['format']); | ||
header("Content-Type: application/json"); | ||
|
||
if ($this->subset == 'itemTypeFields') { | ||
if (empty($_GET['itemType'])) { | ||
$this->e400("'itemType' not provided"); | ||
|
@@ -63,7 +65,7 @@ public function mappings() { | |
// Notes and attachments don't have creators | ||
if ($itemType == 'note' || $itemType == 'attachment') { | ||
echo "[]"; | ||
exit; | ||
$this->end(); | ||
} | ||
} | ||
|
||
|
@@ -77,9 +79,8 @@ public function mappings() { | |
$ttl = 60; | ||
$json = Z_Core::$MC->get($cacheKey); | ||
if ($json) { | ||
header("Content-Type: application/json"); | ||
echo $json; | ||
exit; | ||
$this->end(); | ||
} | ||
|
||
switch ($this->subset) { | ||
|
@@ -132,20 +133,21 @@ public function mappings() { | |
); | ||
} | ||
|
||
header("Content-Type: application/json"); | ||
$json = Zotero_Utilities::formatJSON($json); | ||
Z_Core::$MC->set($cacheKey, $json, $ttl); | ||
|
||
echo $json; | ||
exit; | ||
$this->end(); | ||
} | ||
|
||
|
||
public function newItem() { | ||
if (empty($_GET['itemType'])) { | ||
$this->e400("'itemType' not provided"); | ||
} | ||
|
||
|
||
unset($this->queryParams['format']); | ||
header("Content-Type: application/json"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we just set 'json' as the default There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. That is definitely cleaner |
||
|
||
$itemType = $_GET['itemType']; | ||
if ($itemType == 'attachment') { | ||
if (empty($_GET['linkMode'])) { | ||
|
@@ -200,9 +202,8 @@ public function newItem() { | |
$ttl = 60; | ||
$json = Z_Core::$MC->get($cacheKey); | ||
if ($json) { | ||
header("Content-Type: application/json"); | ||
echo $json; | ||
exit; | ||
$this->end(); | ||
} | ||
|
||
// Generate template | ||
|
@@ -325,12 +326,10 @@ public function newItem() { | |
unset($json['relations']); | ||
} | ||
|
||
header("Content-Type: application/json"); | ||
|
||
$json = Zotero_Utilities::formatJSON($json); | ||
Z_Core::$MC->set($cacheKey, $json, $ttl); | ||
|
||
echo $json; | ||
exit; | ||
$this->end(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these lines necessary?
format
defaults to JSON, so I would think thatoutputContentType()
inend()
would get it right. I think we were only callingheader()
because we weren't usingend()
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, these 2 lines can actually be removed.
The same 2 lines in the
newItem
function are still needed to get the right application/json content type for API v2