dokufreaks / plugin-blogtng

http://dokuwiki.org/plugin:blogtng
GNU General Public License v2.0
36 stars 18 forks source link

tags in "blog pagination" has a bug! #123

Open WeTogetherDo opened 7 years ago

WeTogetherDo commented 7 years ago

When you want to use "tags" in , it can't been executed.

So I read the source code, I found a bug in file "helper/entry.php".

public function xhtml_pagination($conf){ ... $query = 'SELECT A.pid, A.page FROM entries A'.$tag_table.' WHERE '.$blog_query.$tag_query.' AND GETACCESSLEVEL(page) >= '.AUTH_READ; ... }

It should be change to

$query = 'SELECT A.pid, A.page FROM entries A'.$tag_table.' WHERE GETACCESSLEVEL(page) >='.AUTH_READ.' AND '.$blog_query.$tag_query;

Klap-in commented 7 years ago

I don't understand what I should use to reproduce this. What should I do?

And your solution is just switching the execution sequence, is that really helping??

WeTogetherDo commented 7 years ago

Yes. If you don't change the execution sequence,for example,when you use tags, the sql may be

SELECT A.pid, A.page FROM entries A, tags B WHERE (blog = 'default') AND (tag = 'wiki' OR tag = 'tips') AND A.p id = B.pid GROUP BY A.pid AND GETACCESSLEVEL(page) >= 1

But the sql must be

SELECT A.pid, A.page FROM entries A, tags B WHERE GETACCESSLEVEL(page) >= 1 and (blog = 'default') AND (tag = 'wiki' OR tag = 'tips') AND A.p id = B.pid GROUP BY A.pid

Klap-in commented 7 years ago

I think I understand the case. Thanks for explaining! So the issue is that the GROUP BY A.pid part is placed before the GETACCESSLEVEL(page) >= 1 part of the query.

I prefer that the GETACCESSLEVEL(page) >= 1 is executed as latest part of the WHERE, for performance reasons (it calls php functions from MySQL). Another approach is storing the GROUP BY in a separate variable, and joining it after the GETACCESSLEVEL part.

WeTogetherDo commented 7 years ago

Problem is in line 291 of file "helper/entry.php".

line 291: ') AND A.pid = B.pid GROUP BY A.pid'

When you have tags ,the query will be like as ") AND A.pid = B.pid GROUP BY A.pid and GETACCESSLEVEL(page) >=1"

This is the problem.

kp-org commented 6 years ago

Not sure if this is related what I did recognize, but it looks similar. To me it looks like syntax extensions of plugins will not be parsed - more worse at least not all.

The 'abstract' 'line is limited to 50 chars by default, so "tags" have to be exist inside this limit. Lets say you use the bbcode plugin and use the "monospace" tag [b][/b] against the initial syntax of 2 apostrophes.

[m]something[/m] was written .... --> doesn't work (tags will be displayed) ''something" was written ... --> is parsed correctly, the "abstract" line doesn't show tags

Unfortunately bbcode's [color] tag is removed correct, so it seems that not all tags are effected. Additional entries in entities.(local.)conf will not be parsed and removed.

I tried the changes from @WeTogetherDo, but it doesn'work for me.

Klap-in commented 6 years ago

@kp-org abstract creation is offtopic. Please create separate issue. (the abstract is about 250 characters. It is stored using the metadata render, not xhtml renderer. Plugins should just use (indirectly) the $renderer->cdata() method for the text. https://github.com/splitbrain/dokuwiki/blob/master/inc/parser/metadata.php )