Closed ansonphong closed 8 years ago
Phong, when you say:-
So what I’d like to do is add wpautop() on comment read to pw_get_comment(s) filters, although what happens then is that if you then go to edit the comment, you get the HTML tags in there. This is what we intend to fix.
do you mean that we need to fix the side effect of having the tags show in the edit box?
Yes, and also we need to read it before the content is embedded, so the proposed method is as described.
OK, this is done now and committed to postworld - 4 files affected - and one template file in RSV2 comment-default.html. Please review and let me know, and let's do some good testing first.
Hi Michel, Perhaps this is an implementation error on my behalf - do I need to change anything in the comment embedding or template? I didn't see any changes to the comment template.
I have pulled the latest on Postworld, I see the changes made --- my cache is disabled, and I'm in development mode locally - although I can't notice any difference in the functionality.
For instance :
VIEW COMMENT: (looks good)
COMMENT IN DATABASE: (looks good)
But when I go to edit the comment
EDIT COMMENT: (we are seeing the HTML, not the raw comment data)
Any suggestions?
did you also get the RSV2 theme update? there is a minor change made to comments-default.html
One more thing, when you look at the networks tab in google chrome - do you see the pw_get_comment call when clicking the edit icon? and does it return the comment without formatting?
ok, I haven't integrated the comments-default.html change. the network tab is giving the correct response, so the issue is in my implementation - I'll look at the changes in the new template. Thanks.
data: {comment_ID:150038, comment_post_ID:214718, comment_author:phong, comment_author_email:asun@phong.com,…}
comment_ID: "150038"
comment_agent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36"
comment_approved: "1"
comment_author: "phong"
comment_author_IP: "::1"
comment_author_email: "asun@phong.com"
comment_author_url: ""
comment_content: "Testing the creation of a new comment.↵↵Second paragraph.↵↵Third paragraph.↵↵Video embed:↵http://www.youtube.com/watch?v=38peWm76l-U"
comment_date: "2013-12-11 22:09:11"
comment_date_gmt: "2013-12-11 22:09:12"
comment_parent: "0"
comment_points: 0
comment_post_ID: "214718"
comment_type: ""
display_name: "phong"
time_ago: "57 minutes ago"
user_id: "1"
user_profile_url: "http://localhost:8888/u/phong/"
user_voted: 0
status: 200
version: "0.1"
yes, that is the change in RSV2 repo, it's a very minor one, probably a single word, but this is where i tell it to read the comment from the raw field returned instead of the original one.
Hi Michel, I just pulled from the RSV2 repo, and it just went into delete mode and wiped out a lot of the updated plugins which had been installed.
It looks like this is the commit, and then the subsequent merge which did all the damage: https://github.com/phongmedia/RSV2/commit/bbff663ebd40023f5bcc4bdf3a77dcb12d3c0e73
I'm not sure how this happened, perhaps you didn't pull before making the changes, or you updated plugins locally not by pulling so it over-wrote them on the repo. Unclear what the cause is, although I would like to prevent this from happening again.
As a result, I'm going to rollback to before this commit and only preserve the changes to comment-default.html
426c63d6bc562cfeb33ae3147d361c9476b8b5e4
I think by pulling before doing development would prevent this from happening in the future for the most part. Any ideas what happened?
Hi Michel,
As a result of the last commit there, the only method that was working properly was to git reset --hard
to the commit before your last commit, so you'll see your last commit is deleted. I have carried over the template changes.
If there are any other changes made, let me know.
Please re-clone the repo or prevent your local system from doing major over-writing somehow. It's all good I got it worked out, I'd just like to prevent this from happening again.
Thanks.
One small glitch I came across is that on the second time editing a comment, it gives the error Error editing comment
, although the editing actually works fine.
Phong, I am really sorry for the disturbance and wasted time i caused, this is very embarassing. I admit i have seen strange things happen with GIT yesterday, when i tried to commit, it kept trying to commit deletion of some plugins, and i got very confused why this is happening, although i just pulled within the same couple of hours of starting to code. so i made a commit, but didn't push it. Then, i totally ignored this repo, and cloned it elsewhere and committed/pushed only the single comments template. I am not sure how the scenario happened where these plugins are deleted, but i am sorry it is definitely my mistake. The only logical explanation is that after ignornig this repo, i went in and pushed it by mistake. I intend to read more about GIT, as we are moving all our projects into GIT, so i need to make sure i know it by heart, so i can clean up all the mess that my team would create, like you just did.
As for the error above, i am looking at it and will keep you posted shortly.
here is the warning that we are getting:-
( ! ) Warning: Illegal offset type in isset or empty in D:\wamp\www\RSV2\wp-includes\cache.php on line 618
Call Stack
# Time Memory Function Location
1 0.0011 277016 {main}( ) ..\admin-ajax.php:0
2 2.0552 37814392 do_action( ) ..\admin-ajax.php:81
3 2.0552 37815848 call_user_func_array ( ) ..\plugin.php:429
4 2.0552 37815880 pw_save_comment_loggedIn( ) ..\plugin.php:429
5 2.5662 37865816 pw_save_comment( ) ..\postworld_ajax.php:844
6 2.7174 37899448 pw_get_comment( ) ..\postworld_comments.php:445
7 2.7174 37900168 get_comment( ) ..\postworld_comments.php:115
8 2.7175 37900592 wp_cache_get( ) ..\comment.php:142
9 2.7175 37900736 WP_Object_Cache->get( ) ..\cache.php:113
10 2.7175 37900736 WP_Object_Cache->_exists( ) ..\cache.php:453
( ! ) Warning: array_key_exists(): The first argument should be either a string or an integer in D:\wamp\www\RSV2\wp-includes\cache.php on line 618
Call Stack
# Time Memory Function Location
1 0.0011 277016 {main}( ) ..\admin-ajax.php:0
2 2.0552 37814392 do_action( ) ..\admin-ajax.php:81
3 2.0552 37815848 call_user_func_array ( ) ..\plugin.php:429
4 2.0552 37815880 pw_save_comment_loggedIn( ) ..\plugin.php:429
5 2.5662 37865816 pw_save_comment( ) ..\postworld_ajax.php:844
6 2.7174 37899448 pw_get_comment( ) ..\postworld_comments.php:445
7 2.7174 37900168 get_comment( ) ..\postworld_comments.php:115
8 2.7175 37900592 wp_cache_get( ) ..\comment.php:142
9 2.7175 37900736 WP_Object_Cache->get( ) ..\cache.php:113
10 2.7175 37900736 WP_Object_Cache->_exists( ) ..\cache.php:453
11 2.7185 37900784 array_key_exists ( ) ..\cache.php:618
i will look more into it, this is happening only, when you click edit, and save the comment without changing it, the warning happens on save, but you will only see it when editing once again.
actually before digging more into this, could you please confirm this is not a cache/plugin issue, the warning above seems to be more related to some caching parameters. if there is caching, can we disable it and try again? or just let me know how to test it out.
ok, I'll have a look into that next week, as it's low priority. about the git issues, no problem - it took me a while to figure it out, but I take it as a learning experience which furthers my knowledge of git. good thing there is lots of helpful information on Stackoverflow!
yea git is very good to learn. the thing that was causing me the biggest issues in the past is when working with nested repositories as submodules --- what I learned is that you have to always commit and push your changes to the submodules before updating a parent repository, otherwise it references non-existant trees, and you have to do some git magic to get it back on track.
anyways that is just to say, git is very sophisticated and amazing to use, although there's a steep learning curve and so issues like this happen especially at the beginning. glad you're researching more about git - maybe you already know more than me!
In Wordpress, there are different ways of saving the data. One method includes saving all the
<p>
and<br>
HTML tags in the database tables, and the other method is where we effectively save paragraphs as effectively\n\n
and line breaks as\n
.The posts are being currently stored with the
<p>
tags stored in the database, and comments are being stored with\n\n
. The way it’s currently setup IS working well. This is intensional for various reasons.There is a filter which runs in the core of Wordpress which corresponds somewhat with TinyMCE’s functionality which adds the paragraph tags from
\n\n
before display. The Wordpress filter/function is calledwpautop()
. This converts\n\n
into<p>
Now where the issue comes in — currently you will see that the comments on RSV2 don’t have paragraph breaks. If they do have breaks, it’s due to them being saved with
<p>
in the database, so you get the<p>
tags visible when editing the comment. This is not common.Display of a comment:![image](https://f.cloud.github.com/assets/4825055/1700137/e9db6642-5ff2-11e3-8350-f3066d80da51.png)
Editing the comment: (you can see there are line breaks which weren't being displayed)![image](https://f.cloud.github.com/assets/4825055/1700138/f3b65bae-5ff2-11e3-9c67-8f07ffb91b69.png)
So what I’d like to do is add
wpautop()
on comment read topw_get_comment(s)
filters, although what happens then is that if you then go to edit the comment, you get the HTML tags in there. This is what we intend to fix.Additionally, there is a function I developed called
pw_embed_content()
which turns oEmbed service provider URLs into live embeds. What then happens, is you additionally get the embed code/iframes while editing a comment, which then wipes them when saving.To fix all this, what we need to do is on comment edit, we need to read via AJAX from the original comment without the pre-formatting. This is the only addition that needs to be made, as you’ve already built in AJAX procedures which process the comment via PHP before displaying.
To assist, I have made an amendment to the
pw_get_comment()
function, which allows you to set the fields to ‘edit’ mode by setting the$fields
parameter toedit
.This will return the
comment_content
raw without running it through thewpautop
andpw_embed_content
filter functions, ready for editing. Currently the filters are fully disabled (thus no line breaks or media embeds), though you can re-enable them while developing. You will find them on line 168-9 forpw_get_comment
and 337-8 forpw_get_comments
in php/postworld_comments.php
This will allow us to edit the comments as raw text, and display them with wpautop and embedded media separately.
Does all this make sense? Let me know if you have any questions related to this.