I guess I found the problem. At least it seems so.
Correct me if I'm wrong, but it seems that when dokuwiki parser is parsing the sidebar page, page ID is the sidebar page ID, not the wiki page ID.
I tested it the following way. I inserted the same text into sidebar and a wiki page (they both are in same namespace):
[[:test:start|Test]] \\
[[:test:sidebar|Test sidebar]] \\
Now when I type in my browser
http://localhost/wiki/test/start
I see this in the sidebar
Test
Test sidebar
and this in the wiki page
Test
Test sidebar
Consequently when I type in my browser
http://localhost/wiki/test/sidebar
I see this in the sidebar
Test
Test sidebar
and this in the wiki page (which is actually the same sidebar just displayed as wiki page)
Test
Test sidebar
Is there any way to synchonize the two?