Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
[SOLVED] false positives in variables. a bug?
I am working on my localhost on a trilingual site (using the gbp_permanent_links plugin) and I am getting false positives on variables.
This is my code and the tag trace result when on an individual article
<txp:article_custom limit="1">
<txp:variable name="englishcf" value='<txp:custom_field name="englishID" />' />
<txp:if_variable name="englishcf" value="">
<a href="/en/"><txp:image id="8" /></a>
<txp:else />
<txp:permlink id='<txp:variable name="englishcf" />'><txp:image id="8" /></txp:permlink>
</txp:if_variable>
from here on it screws up
<txp:variable name="russiancf" value='<txp:custom_field name="russianID" />' />
<txp:if_variable name="russiancf" value="">
<a href="/ru/"><txp:image id="7" /></a>
<txp:else />
<txp:permlink id='<txp:variable name="russiancf" />'><txp:image id="7" /></txp:permlink>
</txp:if_variable>
</txp:article_custom>
here’s the problematic tag trace…
...
<txp:variable name="russiancf" value='<txp:custom_field name="russianID" />' />
[attribute 'value']
<txp:custom_field name="russianID" />
[/attribute]
<txp:if_variable name="russiancf" value="">
and the false positive
[<txp:if_variable name="russiancf" value="">: true]
The above should return a false!!!
<txp:image id="7" />
[SQL (0.00032496452331543): select * from aa_txp_image as txp_image where id = 7 limit 1]
</txp:if_variable>
...
This mis-behaviour results in showing two image 7s one linked to /ru/ and the other to the article id
Can anyone spot if I am using the wrong code? Or is it a bug?
Also… Previously I used the if_custom_field tag which also produced the same result.
Last edited by colak (2011-09-08 14:32:30)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] false positives in variables. a bug?
Please post the full unmodified tag trace from the problem page, and all used gbp_permanent_link rules.
colak wrote:
Or is it a bug?
Sorry, but bug in exactly what? Variables? Custom_fields? Unlikely, don’t think so. Gbp_permanent_links?
Offline
Re: [SOLVED] false positives in variables. a bug?
Gbp_permanent_links
I disabled that plugin and the behaviour remains:(
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Offline
Re: [SOLVED] false positives in variables. a bug?
here it is. The problem starts with the second variable named russiancf.
<txp:article_custom limit="1">
[SQL (0.0012099742889404): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where 1=1 and Status = 4 and Posted <= now() order by Posted desc limit 0, 1]
[article 3]
<txp:variable name="englishcf" value='<txp:custom_field name="englishID" />' />
[attribute 'value']
<txp:custom_field name="englishID" />
[/attribute]
<txp:if_variable name="englishcf" value="">
[<txp:if_variable name="englishcf" value="">: false]
<txp:permlink id='<txp:variable name="englishcf" />'>
[attribute 'id']
<txp:variable name="englishcf" />
[/attribute]
[SQL (0.00030016899108887): select ID as thisid, Section as section, Title as title, url_title, unix_timestamp(Posted) as posted from aa_textpattern as textpattern where ID = 1]
<txp:image id="8" />
[SQL (0.00028300285339355): select * from aa_txp_image as txp_image where id = 8 limit 1]
</txp:permlink>
</txp:if_variable>
<txp:variable name="russiancf" value='<txp:custom_field name="russianID" />' />
[attribute 'value']
<txp:custom_field name="russianID" />
[/attribute]
<txp:if_variable name="russiancf" value="">
[<txp:if_variable name="russiancf" value="">: true]
<txp:image id="7" />
[SQL (0.00032496452331543): select * from aa_txp_image as txp_image where id = 7 limit 1]
</txp:if_variable>
</txp:article_custom>
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] false positives in variables. a bug?
colak wrote:
here it is.
That small portion from the tag trace doesn’t show any apparent problem. Everything seems to work as expected.
The problem starts with the second variable named russiancf.
According to the tag trace the custom field russianID for article ID#3 is empty. And as you are matching it against “empty” it will return true. Make sure it indeed isn’t empty, you are fetching the correct article. If the problem persists, then please post your full tag trace (all of it) and your high diagnostics.
Offline
Re: [SOLVED] false positives in variables. a bug?
Gocom wrote:
According to the tag trace the custom field russianID for article ID#3 is empty. And as you are matching it against “empty” it will return true. Make sure it indeed isn’t empty, you are fetching the correct article. If the problem persists, then please post your full tag trace (all of it) and your high diagnostics.
Hi Jukka,
Thanks for looking into this. The problem is that the custom field is not empty and the parsed page shows two image 7s one using the custom field’s value and the other not. it now only shows one which is linked to /ru/. Not the custom field’s value!
here’s the complete tag trace.
<!-- Runtime: 0.1397 -->
<!-- Query time: 0.029403 -->
<!-- Queries: 35 -->
<!-- Memory: 7640Kb, <txp:image /> -->
<!-- txp tag trace:
[SQL (0.0011899471282959): select name, data from aa_txp_lang as txp_lang where lang='en-gb' AND ( event='public' OR event='common')]
[SQL (0.0063610076904297): select name, code, version from aa_txp_plugin as txp_plugin where status = 1 AND type IN (0,1) order by load_order]
[SQL (0.000762939453125): select name,code,version from aa_txp_plugin as txp_plugin where status = 1 AND name='gbp_admin_library']
[SQL (0.00066900253295898): select name, html as type from aa_txp_prefs as txp_prefs where event = 'permlinks' AND html <> 'gbp_partial']
[SQL (0.0011651515960693): select name,code,version from aa_txp_plugin as txp_plugin where status = 1 AND name='mem_postmaster_library']
[SQL (0.00066614151000977): select ID, Section from aa_textpattern as textpattern where ID = 0 and Section = 'el' and Status >= 4 limit 1]
[SQL (0.00021696090698242): select page, css from aa_txp_section as txp_section where name = '' limit 1]
[SQL (0.00019311904907227): select REPLACE(name, 'gbp_permanent_links_', '') AS id from aa_txp_prefs as txp_prefs where `event` = 'permlinks' AND `name` REGEXP '^gbp_permanent_links_.{13}$']
[SQL (0.0001990795135498): select name from aa_txp_section as txp_section where (`name` like 'el' or `name` like 'el') limit 1]
[SQL (0.00026798248291016): select name from aa_txp_category as txp_category where (`name` like 'plirofories' or `name` like 'plirofories') and `type` = 'article' limit 1]
[SQL (0.00017499923706055): select ID, Posted from aa_textpattern as textpattern where `ID` = '2' and `Section` = 'el' and (`Category1` = 'plirofories' OR `Category2` = 'plirofories') and `Status` >= 4 limit 1]
[SQL (0.00017285346984863): select url_title from aa_textpattern as textpattern where (`url_title` like 'plirofories' or `url_title` like 'plirofories') and `Section` = 'el' and (`Category1` = 'plirofories' OR `Category2` = 'plirofories') and `Status` >= 4 limit 1]
[SQL (0.00060391426086426): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from aa_textpattern where Posted > '2011-08-22 10:04:56' and Section = 'el' and Status=4 and Posted < now() order by Posted asc limit 1]
[SQL (0.0003960132598877): select ID, Title, url_title, unix_timestamp(Posted) as uposted
from aa_textpattern where Posted < '2011-08-22 10:04:56' and Section = 'el' and Status=4 and Posted < now() order by Posted desc limit 1]
[SQL (0.00023913383483887): select css, page from aa_txp_section as txp_section where name = 'el' limit 1]
[SQL (0.0009608268737793): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where ID=2 and Status >= 4]
[article 2]
[SQL (0.00069403648376465): select user_html from aa_txp_page as txp_page where name='greek']
[Page: greek]
<txp:page_title />
<txp:site_url />
<txp:feed_link flavor="atom" format="link" label="Atom" />
<txp:feed_link flavor="rss" format="link" label="RSS" />
<txp:rvm_css format="link" />
[SQL (0.00065398216247559): select css from aa_txp_section as txp_section where name='el']
<txp:rsd />
<txp:section />
<txp:text item="go_nav" />
<txp:text item="go_content" />
<txp:text item="go_search" />
<txp:search_input match="any" label="" size="25">
[SQL (0.00028204917907715): select form from aa_txp_form where `name` = 'search_input' limit 1]
</txp:search_input>
<txp:if_article_list>
[<txp:if_article_list>: false]
</txp:if_article_list>
<txp:if_individual_article>
[<txp:if_individual_article>: true]
<txp:article_custom limit="1">
[SQL (0.0011758804321289): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where 1=1 and Status = 4 and Posted <= now() order by Posted desc limit 0, 1]
[article 3]
<txp:variable name="englishcf" value='<txp:custom_field name="englishID" />' />
[attribute 'value']
<txp:custom_field name="englishID" />
[/attribute]
<txp:if_variable name="englishcf" value="">
[<txp:if_variable name="englishcf" value="">: false]
<txp:permlink id='<txp:variable name="englishcf" />'>
[attribute 'id']
<txp:variable name="englishcf" />
[/attribute]
[SQL (0.00066399574279785): select ID as thisid, Section as section, Title as title, url_title, unix_timestamp(Posted) as posted from aa_textpattern as textpattern where ID = 1]
<txp:image id="8" />
[SQL (0.00034189224243164): select * from aa_txp_image as txp_image where id = 8 limit 1]
</txp:permlink>
</txp:if_variable>
<txp:variable name="russiancf" value='<txp:custom_field name="russianID" />' />
[attribute 'value']
<txp:custom_field name="russianID" />
[/attribute]
<txp:if_variable name="russiancf" value="">
[<txp:if_variable name="russiancf" value="">: true]
<txp:image id="7" />
[SQL (0.00065708160400391): select * from aa_txp_image as txp_image where id = 7 limit 1]
</txp:if_variable>
</txp:article_custom>
</txp:if_individual_article>
<txp:link_to_home>
<txp:image id="11" />
[SQL (0.00066590309143066): select * from aa_txp_image as txp_image where id = 11 limit 1]
</txp:link_to_home>
<txp:site_url />
<txp:category_list parent="el" exclude="el" break="li" wraptag="">
[SQL (0.00063896179199219): select lft, rgt from aa_txp_category as txp_category where type = 'article' and name = 'el']
[SQL (0.0003359317779541): select name, title from aa_txp_category as txp_category where (lft between 2 and 9) and type = 'article' and name != 'default' and name not in('el') order by lft ASC]
<txp:category section="default" title="1" link="1" />
<txp:category section="default" title="1" link="1" />
<txp:category section="default" title="1" link="1" />
</txp:category_list>
<txp:if_article_list>
[<txp:if_article_list>: false]
<txp:article_custom allowoverride="0">
[SQL (0.0018231868743896): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where 1=1 and Status = 4 and Posted <= now() order by Posted desc limit 0, 10]
[article 3]
<txp:if_custom_field name="images_category">
[<txp:if_custom_field name="images_category">: false]
<txp:article_custom id="1" allowoverride="0">
[SQL (0.00075602531433105): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where 1=1 and Status >= 4 and Posted <= now() and ID IN (1) order by Posted desc limit 0, 10]
[article 1]
<txp:images category='<txp:custom_field name="images_category" />' break="" limit="6" sort="rand()">
[attribute 'category']
<txp:custom_field name="images_category" />
[/attribute]
[SQL (0.00080609321594238): select * from aa_txp_image as txp_image where category IN ('default_slide_show') order by rand() limit 0, 6]
<txp:image />
<txp:image />
<txp:image />
<txp:image />
</txp:images>
</txp:article_custom>
</txp:if_custom_field>
[article 2]
<txp:if_custom_field name="images_category">
[<txp:if_custom_field name="images_category">: false]
<txp:article_custom id="1" allowoverride="0">
[SQL (0.001147985458374): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where 1=1 and Status >= 4 and Posted <= now() and ID IN (1) order by Posted desc limit 0, 10]
[article 1]
<txp:images category='<txp:custom_field name="images_category" />' break="" limit="6" sort="rand()">
[attribute 'category']
<txp:custom_field name="images_category" />
[/attribute]
[SQL (0.00074601173400879): select * from aa_txp_image as txp_image where category IN ('default_slide_show') order by rand() limit 0, 6]
<txp:image />
<txp:image />
<txp:image />
<txp:image />
</txp:images>
</txp:article_custom>
</txp:if_custom_field>
[article 1]
<txp:if_custom_field name="images_category">
[<txp:if_custom_field name="images_category">: true]
<txp:images category='<txp:custom_field name="images_category" />' break="" limit="6" sort="rand()">
[attribute 'category']
<txp:custom_field name="images_category" />
[/attribute]
[SQL (0.0011889934539795): select * from aa_txp_image as txp_image where category IN ('default_slide_show') order by rand() limit 0, 6]
<txp:image />
<txp:image />
<txp:image />
<txp:image />
</txp:images>
</txp:if_custom_field>
</txp:article_custom>
</txp:if_article_list>
<txp:if_search>
[<txp:if_search>: false]
<txp:if_article_list>
[<txp:if_article_list>: false]
<txp:article>
<txp:title />
<txp:body />
<txp:related_articles limit="10" sort="rand()" />
[SQL (0.0012531280517578): select *, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as uLastMod, unix_timestamp(Expires) as uExpires from aa_textpattern as textpattern where ID != 2 and Status = 4 and Posted <= now() and (Category1 in('plirofories') or Category2 in('plirofories')) order by rand() limit 0,10]
[SQL (0.00081586837768555): select Form from aa_txp_form as txp_form where name='comments_display']
[Form: comments_display]
<txp:text item="comment" />
<txp:comments_invite textonly="1" showalways="1" showcount="0" />
<txp:comments />
<txp:if_comments_preview>
[<txp:if_comments_preview>: false]
</txp:if_comments_preview>
<txp:if_comments_allowed>
[<txp:if_comments_allowed>: false]
</txp:if_comments_allowed>
</txp:article>
</txp:if_article_list>
</txp:if_search>
<txp:php>
</txp:php>
[ ~~~ secondpass ~~~ ]
-->
Last edited by colak (2011-09-08 11:45:22)
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] false positives in variables. a bug?
You sure that you are actually trying to get the data off from the correct article? While you are on article ID#2’s individual article page, the actual data is from article ID#3, as all the tags are inside article_custom tag. According the tag trace the custom field is empty for the article which has ID 3, not ID 2.
Offline
Re: [SOLVED] false positives in variables. a bug?
Gocom wrote:
You sure that you are actually trying to get the data off from the correct article? While you are on article ID#2’s individual article page, the actual data is from article ID#3, as all the tags are inside article_custom tag. According the tag trace the custom field is empty for the article which has ID 3, not ID 2.
That was it! I’ve now changed <txp:article_custom limit="1">
to <txp:article_custom id='<txp:article_id />'>
and it works just fine!
Once again, thanks soo much for all your help.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: [SOLVED] false positives in variables. a bug?
colak wrote:
Once again, thanks soo much for all your help.
You’re welcome. It’s fun spending extra hour for asking something. It’s also nice to spend 10-30 minutes writing a reply, and then someone removes the post/topic. Especially like when it happens in my plugins’ support request topics. Very fun. Do you know how high my rage level is now ;-)
Offline