Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2015-07-27 03:00:59

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Expired moan

Consider the following scenario:

Preference “Publish expired articles?” set to No.

Article tag:

<txp:article expired="1">
	<txp:title />
</txp:article>

Generates titles for all articles, both expired or otherwise.

Add in if_expired:

<txp:article expired="1">
	<txp:title />
	<txp:if_expired>EXPIRED</txp:if_expired>
</txp:article>

Still get all articles, but now for each one there’s an error message:

Tag error: <txp:if_expired> ->  Textpattern Notice: publish_expired_articles_prefs_off while parsing form None on page test

textpattern/publish/taghandlers.php:2047 trigger_error()
if_expired()
textpattern/vendors/Textpattern/Tag/Registry.php:80 call_user_func()
textpattern/lib/txplib_publish.php:477 Textpattern_Tag_Registry->process()
textpattern/lib/txplib_publish.php:398 processTags()
textpattern/publish.php:950 parse()
textpattern/publish.php:1050 doArticles()
textpattern/publish.php:673 parseArticles()
article()
textpattern/vendors/Textpattern/Tag/Registry.php:80 call_user_func()

So the questions are:

  1. Why does TXP throw an error when I’ve explicitly told the tab to output expired articles
  2. Is there any point to the error message anyway?
  3. Am I just confused?

Offline

#2 2015-07-27 06:16:22

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Expired moan

You are forbidden to show expired articles, and they are showing themselves, and therefore get a warning (not error).

TxP code:

    if (!$publish_expired_articles && $production_status != 'live') {
        trigger_error(gTxt('publish_expired_articles_prefs_off'), E_USER_NOTICE);
    }

Although I do not see the point of this warning. Output of articles occurs without warning, and the warning is issued only if_expired. I would have removed the warning.


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#3 2015-07-27 06:44:23

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Expired moan

makss wrote #293713:

You are forbidden to show expired articles, and they are showing themselves, and therefore get a warning (not error).

TxP code:

if (!$publish_expired_articles && $production_status != 'live') {...

Although I do not see the point of this warning. Output of articles occurs without warning, and the warning is issued only if_expired. I would have removed the warning.

Yes, I’d expect that explicitly asking for expired articles (expired="1") should override any complaints.

Offline

#4 2015-07-27 09:22:52

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Expired moan

Another thing, this code is executed without any warning and generated links to articles already expired.

<txp:article_custom expired="1">
	<txp:permlink><txp:title /></txp:permlink>
</txp:article_custom>

Textpattern for expired articles return code 410. It makes no sense to refer to such articles.
I think need to <txp:permlink /> to issue a warning for expired articles (if $publish_expired_articles == ‘no’) and/or not return link to expired article.

Warning inside if_expired meaningless. Many sites show titles of past events or actions, and why not? But to put invalid links (<txp:permlink />) to them is not necessary.

Last edited by makss (2015-07-27 09:37:22)


aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#5 2015-07-27 21:07:02

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: Expired moan

Does seem a bit odd to throw a warning. Guess it comes down to whether a tag attribute should override a pref. Would you please be able to put forward a patch that makes this work sensibly, makss?

In theory, the article tag doesn’t accept expired as an attribute, but due to its close ties with article_custom it does silently accept them. And the same issue affects article_custom anyway.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#6 2015-07-27 22:06:57

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Expired moan

Bloke wrote #293748:

Hi Stef & makss, thanks for looking into this.

Does seem a bit odd to throw a warning. Guess it comes down to whether a tag attribute should override a pref.

Isn’t expired="1" already overriding a pref?

In theory, the article tag doesn’t accept expired as an attribute, but due to its close ties with article_custom it does silently accept them. And the same issue affects article_custom anyway.

Yes I was just being lazy and keeping the example code short … hopefully one day the article/ article_custom quirkiness might be a thing of the past.

Offline

#7 2015-07-27 22:20:05

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,270
Website GitHub

Re: Expired moan

gomedia wrote #293755:

Isn’t expired="1" already overriding a pref?

Sort of yes. Just not doing a very good job of it.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2015-07-27 22:50:28

gomedia
Plugin Author
Registered: 2008-06-01
Posts: 1,373

Re: Expired moan

Bloke wrote #293756:

Sort of yes. Just not doing a very good job of it.

I think it’s doing a fine job … by providing additional functionality. It’s just the “Tag error:” whinging that needs to disappear!

Offline

#9 2015-07-28 10:19:59

makss
Plugin Author
From: Ukraine
Registered: 2008-10-21
Posts: 355
Website

Re: Expired moan

Pull request: Remove unnecessary warning in if_expired tag

Pull request: Avoid links to expired articles

  • For expired articles is returned link to site_url/#expired_article
  • Show warning permlink_to_expired_article if production_status != 'live'

aks_cron : Cron inside Textpattern | aks_article : extended article_custom tag
aks_cache : cache for TxP | aks_dragdrop : Drag&Drop categories (article, link, image, file)

Offline

#10 2015-08-20 09:50:41

wet
Developer Emeritus
From: Schoerfling, Austria
Registered: 2005-06-06
Posts: 3,323
Website Mastodon

Re: Expired moan

makss wrote #293780:

  • For expired articles is returned link to site_url/#expired_article

I’d rather continue to adhere to the HTTP protocol using a ‘410 Gone’ response.

Offline

Board footer

Powered by FluxBB