Page 1 of 1

DATA_COMMENT_DELETED on deleting trackback

Posted: Sun Apr 03, 2011 6:10 pm
by LazyBadger
Text in such form means (usually) "No string constant found", referecnce found only once, in index.php

Code: Select all

if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) {
    if ($res[1] == 'comment' && serendipity_deleteComment($res[2], $res[3], 'comments')) {
        define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Sun Apr 03, 2011 6:17 pm
by garvinhicking
Hi!

I don't understand, what do you mean?

Regards,
Garvin

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Sun Apr 03, 2011 6:22 pm
by LazyBadger
DATA_COMMENT_DELETED string must be defined in lang-file or some other way, but this doesn't happen,when it needed
Is it more clean?

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Sun Apr 03, 2011 10:43 pm
by garvinhicking
Hi!

The problem is, DATA_COMMENT_DELETED is emitted that way in templates, without sprintf() substitution. We cannot change it to a language file because then the substitution would need to take place in the template, and that would mean every template author had to change their template.

Since the %s substitution is already done through COMMENT_DELETED, I do not think this is a problem.

Regards,
Garvin

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 5:59 am
by LazyBadger
garvinhicking wrote:Since the %s substitution is already done through COMMENT_DELETED, I do not think this is a problem
I don't know there and how it's (substitution) broken, but it happens, in other case I never saw "DATA_COMMENT_DELETED" instead of normal "human-ready" text. This IS a ploblem (well, annoyance) now,because it make frontend of Serendipity not perfect

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 10:36 am
by garvinhicking
Hi!

What do you mean, you never saw DATA_COMMENT_DELETED? It should get the content of "COMMENT_DELETED" of the langauge file.

COMMENT_DELETED is set to "Comment #%s has successfully been deleted" in the language file. Now the code puts the ID of the deleted comment inside that string and saves it as the constant DATA_COMMENT_DELETED. So this contains "Comment #4711 has successfully been deleted" for example, and the templates output this from the entries.tpl file...

Regards,
Garvin

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 10:48 am
by LazyBadger
garvinhicking wrote:Hi!

What do you mean, you never saw DATA_COMMENT_DELETED? It should get the content of "COMMENT_DELETED" of the langauge file.
It should, but not get - I try to say it from the first message. I see human-readable text for trackback deleted from @define('TRACKBACK_DELETED'..., but second line below this is pure "DATA_COMMENT_DELETED" as-is without expanding and substitution. Do you want screenshot?

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 11:32 am
by LazyBadger
You can delete pingback from me to "IE9 has trouble with CSS Content-Types" entry in blog for testing purposes

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 1:23 pm
by garvinhicking
Hi!

Maybe the problem is deleting pingbacks.

Can you modify your code like this:

Code: Select all

if (preg_match(PAT_DELETE, $uri, $res) && $serendipity['serendipityAuthedUser'] === true) {
    if ($res[1] == 'comment' && serendipity_deleteComment($res[2], $res[3], 'comments')) {
        define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));
    } elseif ( $res[1] == 'trackback' && serendipity_deleteComment($res[2], $res[3], 'trackbacks') ) {
        define('DATA_TRACKBACK_DELETED', sprintf(TRACKBACK_DELETED, $res[2]));
    } else {
      define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));
    }
} else {
    define('DATA_COMMENT_DELETED', false);
    define('DATA_TRACKBACK_DELETED', false);
}
The additional line should take care that the constants are ALWAYS defined, also when the type is neither "comments" nor "trackbacks".

Regards,
Garvin

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 2:13 pm
by LazyBadger
If you said about such diff as result

Code: Select all

--- mayorat.e-city.net.ru/web/blog/index.php	Чт июн 11 15:14:16 2009
+++ index.php	Пн апр  4 17:46:38 2011
@@ -63,6 +63,8 @@
         define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));
     } elseif ( $res[1] == 'trackback' && serendipity_deleteComment($res[2], $res[3], 'trackbacks') ) {
         define('DATA_TRACKBACK_DELETED', sprintf(TRACKBACK_DELETED, $res[2]));
+    } else {
+      define('DATA_COMMENT_DELETED', sprintf(COMMENT_DELETED, $res[2]));
     }
 } else {
     define('DATA_COMMENT_DELETED', false);
I test it now

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 2:23 pm
by LazyBadger
With patched version of index.php - same bad result, sorry
Обратная ссылка #14 была успешно удалена
DATA_COMMENT_DELETED

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Mon Apr 04, 2011 2:37 pm
by garvinhicking
Hi!

Hm, then I don't really understand it...DATA_COMMENT_DELETED should always be defined now (with "false") so it should show an empty string, not the constant name...

Regards,
Garvin

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Tue Apr 05, 2011 9:43 am
by LazyBadger
Can I ask to poke my nose in a place in the code, where the visualization result of the substitution happens? Maybe I'm dumb, but I can't find it - I'll try to start debug session

Re: DATA_COMMENT_DELETED on deleting trackback

Posted: Tue Apr 05, 2011 10:41 am
by garvinhicking
Hi!

I'd suggest to do a grep/find in all files for "DATA_COMMENT_DELETED". As far as I can see, the output happens in the entries.tpl file...?

Regards,
Garvin