Skip to content

Remove unused methods of OC_Json - #8791

Merged
MorrisJobke merged 1 commit into
masterfrom
cleanup-oc_json
Mar 22, 2018
Merged

Remove unused methods of OC_Json#8791
MorrisJobke merged 1 commit into
masterfrom
cleanup-oc_json

Conversation

@MorrisJobke

Copy link
Copy Markdown
Member

Ref #8375 and #7827

@MorrisJobkeMorrisJobke added 3. to review Waiting for reviews technical debt 🧱 🤔🚀 labels Mar 12, 2018
@MorrisJobkeMorrisJobke added this to the Nextcloud 14 milestone Mar 12, 2018
Comment threadlib/private/legacy/api.php Outdated
if ($format == 'json') {
return OC_JSON::encode($response);
if (is_array($response)) {
array_walk_recursive($response, array('OC_JSON', 'to_string'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What kind of dark hackery is this

$value = (string)$value;
? 🙈

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not ask question you don't want answered

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤐

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's basically an object which use cast to a string (calling then the __toString() method explicitly). Otherwise the json_encode would fail with an error, that it only can serialize strings, integer, bool and date (the types it knows how to serialize).

Comment threadlib/private/legacy/eventsource.php Outdated

private function encode($data) {
if (is_array($data)) {
array_walk_recursive($data, array('OC_JSON', 'to_string'));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not even a public method

protectedstaticfunctionto_string(&$value) {
🙈

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:/ Need to work on this yes :/

@MorrisJobkeMorrisJobke added 2. developing Work in progress and removed 3. to review Waiting for reviews labels Mar 12, 2018
@codecov

codecovBot commented Mar 13, 2018

Copy link
Copy Markdown

Codecov Report

Merging #8791 into master will increase coverage by 0.04%.
The diff coverage is 0%.

@@ Coverage Diff @@## master #8791 +/- ##
============================================
+ Coverage 51.89% 51.93% +0.04% - Complexity 25278 25279 +1 
============================================
Files 1604 1607 +3 Lines 94798 94872 +74 Branches 1377 1377 ============================================
+ Hits 49193 49275 +82 + Misses 45605 45597 -8
Impacted FilesCoverage ΔComplexity Δ
lib/public/JSON.php0% <ø> (ø)6 <0> (-1)⬇️
lib/private/legacy/eventsource.php0% <0%> (ø)13 <0> (ø)⬇️
lib/private/legacy/json.php12% <0%> (+1.28%)19 <0> (-4)⬇️
lib/public/DB.php25% <0%> (-75%)4% <0%> (+3%)
...aring/lib/Controller/MountPublicLinkController.php21.52% <0%> (-20.37%)24% <0%> (+10%)
lib/public/Share.php35.29% <0%> (-4.71%)7% <0%> (+1%)
settings/Controller/GroupsController.php64.61% <0%> (-3.72%)9% <0%> (ø)
lib/public/Util.php56.88% <0%> (-3.32%)48% <0%> (+3%)
apps/dav/lib/CalDAV/Activity/Provider/Base.php76.78% <0%> (-2.58%)16% <0%> (-3%)
apps/updatenotification/lib/UpdateChecker.php71.42% <0%> (-1.3%)8% <0%> (ø)
... and 45 more

@MorrisJobke

Copy link
Copy Markdown
MemberAuthor

Ready for review again. I dropped the public interfaces that aren't used outside of lib/private and migrated the remaining ones to the private methods.

@rullzerrullzer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

Signed-off-by: Morris Jobke <hey@morrisjobke.de>
@MorrisJobke

Copy link
Copy Markdown
MemberAuthor

@ChristophWurst@skjnldsv Ready for review

@ChristophWurstChristophWurst left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@ChristophWurstChristophWurst added 4. to release Ready to be released and/or waiting for tests to finish and removed 3. to review Waiting for reviews labels Mar 21, 2018
@MorrisJobke
MorrisJobke merged commit be35b54 into masterMar 22, 2018
@MorrisJobke
MorrisJobke deleted the cleanup-oc_json branch March 22, 2018 08:54
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4. to releaseReady to be released and/or waiting for tests to finishtechnical debt🧱 🤔🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@MorrisJobke@rullzer@ChristophWurst