-
Notifications
You must be signed in to change notification settings - Fork 44
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
[MAINTENANCE] Format XML output of OAI-PMH #1473
Conversation
Here are some numbers for
So this pull request reduces the size of the answer for this specific OAI-PMH request from 6172 bytes to 2046 bytes. |
Signed-off-by: Stefan Weil <[email protected]>
$xmlOutput = $this->view->render(); | ||
|
||
// Format the XML. | ||
$dom = new \DOMDocument(); |
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.
$dom = new \DOMDocument(); | |
$dom = new DOMDocument(); |
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.
Note that the code already uses new \DOMDocument();
in function getMetsData
. This is more safe and efficient than new DOMDocument();
which should only be used if this function were overridden in the current namespace.
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.
Codacy complained because you declared use DOMDocument;
at the top of the file, but then added the namespace in this line anyways. The use-statement already makes clear that there is no such function/object in current namespace and the global version should be used.
The reason why getMetsData()
uses new \DOMDocument();
is, that before your changes we didn't have an use-statement for DOMDocument
. Strictly speaking we should remove the backslash from getMetsData
as well, now.
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.
Codacy complained about my new code before I added the use
statement. I added it to fix the Codacy warning.
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.
Both is true: Codacy generally discourages using any namespaces in the code in favor of declaring all used namespaced functions and objects per use-statement.
So Codacy first complained about the missing use-statement and then complained about a namespace in code for which a use-statement exists.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1473 +/- ##
============================
============================
☔ View full report in Codecov by Sentry. |
The current XML output is generated with a Fluid template. Therefore it is badly formatted with lots of empty lines and unnecessary whitespace.