-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fixes: Error PHP Array to string conversion at .../oc/lib/private/template/functions.php#36 #18921
Conversation
A new inspection was created. |
@@ -33,7 +33,7 @@ | |||
* @param string|array $string the string which will be escaped and printed | |||
*/ | |||
function p($string) { | |||
print(OC_Util::sanitizeHTML($string)); | |||
implode(print(OC_Util::sanitizeHTML($string))); |
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.
Shouldn't this be print(implode( ?
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.
Yep.
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.
Maybe something like:
if(is_array($string)) {
$string = implode($string);
}
print(OC_Util::sanitizeHTML($string));
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.
👍 to @MorrisJobke 's improvement, otherwise implode()
will eat the input string and return null.
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.
like it. 👍 :)
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.
print(implode( doesn't work by the way. don't do it! will break everything... end of the world stuff. you know, hellfire raining from the skies. think sulfur burning. or that fat guy after having a lot of onions...
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.
@zyrill Can you fix your PR with the suggested improvements?
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, I will. I'm in a meeting now, give me a few hours.
@MorrisJobke anything else I need to do? I'm rather new to the github experience... |
👍 |
function p($string) {
$sanitized = OC_Util::sanitizeHTML($string);
if (is_array($sanitized)) {
$sanitized = implode($sanitized);
}
print $sanitized;
} |
if (is_array($sanitized)) { | ||
$sanitized = implode($sanitized); | ||
} | ||
print $sanitized; |
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.
Sorry for nitpicking: can you please add brackets after print
? For coding guidelines compliance ;)
Thanks.
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.
I was the one who left it out. Sorry.
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.
I've just applied this to 8.1.3 and it doesn't work!
Get an error message:
Error occurred while checking server setup
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.
I've just applied this to 8.1.3 and it doesn't work!
It is still in development.
Hello, I am not familar with how this works on this page. I just want to say I've tested this to 8.1.3 and this code works for me function p($string) {
$sanitized = OC_Util::sanitizeHTML($string);
if (is_array($sanitized)) {
$sanitized = implode($sanitized);
}
print ($sanitized); Thanks. |
The above fix by @widac doesn't work for me on 8.1.3, i got blank page accessing to owncloud webui after that. function p($string) {
print(OC_Util::sanitizeHTML($string));
} |
Alright, got the brackets in. Any more comments? |
Can we get the 11 commits squashed into 1 because it only changes 5 lines. ;) Then I think this is fine for review. If you need help by juggling with git feel free to ping me in IRC (#owncloud-dev on freenode) |
|
…wncloud/lib/private/template/functions.php#36 See #17468 for bug description. Incorporated changes proposed by @MorrisJobke and by @szepeviktor, see #18921
:hurray: |
Puh, wär hätte gedacht, dass squashen so schwierig ist. Danke, @MorrisJobke. :) |
@zyrill Because you asked about CI - I created a local branch and PR to trigger CI: #19612 @DeepDiver1975 We need to focus on CI for forks after the release ;) |
@LukasReschke what do you think ? |
Fair enough from my PoV. Though I'd vote only for master and no backport. |
Any update on this? I also got this error on a fresh install on stable 8.2 |
The checks are failing; that's not good. But I'm here to confirm that it (=changing that 1 function) did fix the error I had on fresh install (stable 8.2.0). |
@nickvergessen @PVince81 @LukasReschke Lets get this in :) |
Please review ;) |
👍 I tested on stable 8.2 and the error did not raise again |
I'm not sure, when it's an array it still fails to implode. |
It is meant to be called with an array: |
This is the weird thing ... The problem here is that it is kind of public API ... cc @DeepDiver1975 |
Should we change the PHPDoc - it doesn't work before anyways. |
Anything needed that I can help with? |
We first need a consensus ;) |
Do we actually know where the original error comes from ? Which template/app is calling this function with an array ? |
I activated contacts and calendar. Both don't throw the error on the admin page anymore. I guess we should simply fix the PHPDoc to only accept |
yes, agreeed |
|
Sorry for saying this: We will close this here and need to check where this method is called in the wrong way. If you have still this problem it would be nice to get a stack trace or at least all installed apps including their versions. Thanks |
Hi, this is definitely not fixed. I need to manually apply the fix in functions.php now since 2015-11-19 after every single Owncloud update.
|
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
See #17468 for bug description.