Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
API Make SSViewer#process return HTMLText not string
This means that you dont have to worry about casting it as HTMLText again when using the result in a template or other context However in some situations code might be assuming it can check with is_string, in which case you now need to use instanceof HTMLText
- Loading branch information
Hamish Friedlander
authored and
Sam Minnee
committed
Mar 13, 2013
1 parent
9bd6dd9
commit 743a186
Showing
7 changed files
with
24 additions
and
14 deletions.
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
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 |
---|---|---|
|
@@ -295,5 +295,8 @@ public function debug() { | |
</ul> | ||
DBG; | ||
} | ||
|
||
|
||
public function __toString() { | ||
return $this->forTemplate(); | ||
} | ||
} |
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
743a186
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.
@sminnee This appears to have caused a slight issue with doing something like:
Previously, that would have returned a JSON object of
But now it returns
My reading of the docs is, that the
json_encode
function turns the object into a json object based on it's public variables (class being the only one in this instance).I'm not sure of a way to make
json_encode
use some other function to determine how it should be represented (in 5.3, you can in 5.4 - see http://www.php.net/manual/en/class.jsonserializable.php).Not sure how best to patch this? Either the docs need to make it very clear that you need to be casting as string in these circumstances (I think it's very big deal for updgrades) or the Convert::array2json() needs to walk the entire array making sure that all items are strings and casting them as such - but equally, that could break other code that relies on encoding an object and not a string...
743a186
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.
Yeah, you now need to cast as strings, like
$jsonEncode[$page->ID] = (string)$page->forTemplate();
- it's a difficult change to catch, as it's only needed where the behaviour for objects is different than the behavior for strings. It is briefly mentioned in the 3.1 upgrade docs but that should probably be expanded.743a186
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'm happy with that position, if it is the way it's being put now, then sure. But i do think it's a big deal and needs to be made very clear in the docs.