Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

URL to article stays valid when unpublished or protected #8264

Closed
fritzmg opened this issue Mar 9, 2016 · 6 comments
Closed

URL to article stays valid when unpublished or protected #8264

fritzmg opened this issue Mar 9, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@fritzmg
Copy link
Contributor

fritzmg commented Mar 9, 2016

Problem

If you unpublish an article, its URL, i.e. /page/articles/article.html stays valid and simply shows an empty page - but with the title of the (unpublished) article and either description (teaser) of the article or, when not available, the description of the page of the article. Contao will only show a 404 page, if you delete the article completely.

Reproduction

  1. create a new article on any page
  2. fill in the article title and also an article teaser
  3. activate the Show teaser option
  4. publish the article and save
  5. go to the page in the frontend an copy the URL to the detail page of the article
  6. unpublish the article
  7. open the URL to the detail page of the article in the frontend again

Shortcut:

  1. create a new article on any page
  2. fill in the article title (and optionally the article alias)
  3. save the article (do not publish the article)
  4. open the following URL in the frontend: /page-alias/articles/article-alias.html

You'll see an empty page with the title of the unpublished article and, when available, the teaser of the article in the meta description (or the page's meta description otherwise).

Expected behaviour

  • unpublished articles should generate a 404 page when accessed
  • protected articles should generate a 403 page when accessed without access rights
@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 9, 2016

Possible fix or workaround: replace https://github.com/contao/core/blob/3.5.8/system/modules/core/modules/ModuleArticle.php#L61 with

$objHandler = new $GLOBALS['TL_PTY']['error_404']();
$objHandler->generate($this->alias);

@zonky2
Copy link

zonky2 commented Mar 9, 2016

o.k. - going well!

    public function generate($blnNoMarkup=false)
    {
        if (TL_MODE == 'FE' && !BE_USER_LOGGED_IN && (!$this->published || ($this->start != '' && $this->start > time()) || ($this->stop != '' && $this->stop < time())))
        {
-           return '';
+           $objHandler = new $GLOBALS['TL_PTY']['error_404']();
+           $objHandler->generate($this->alias);
        }

        $this->type = 'article';
        $this->blnNoMarkup = $blnNoMarkup;

        return parent::generate();
    }

@fritzmg fritzmg changed the title URL to article stays valid when unpublished URL to article stays valid when unpublished or protected Mar 10, 2016
@fritzmg
Copy link
Contributor Author

fritzmg commented Mar 10, 2016

The URL to protected articles stays valid too. The aforementioned workaround/fix has no effect in such a case.

I was wrong about seeing the title and teaser of the unpublished or protected article though - no information about the unpublished or protected article is visible in the frontend, when accessed via its URL. (At least I couldn't reproduce that now.)

@leofeyer leofeyer added this to the 3.5.9 milestone Mar 11, 2016
@leofeyer leofeyer self-assigned this Mar 16, 2016
@leofeyer
Copy link
Member

Fixed in d9ef512.

@zonky2
Copy link

zonky2 commented Mar 16, 2016

Thanks!

jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Mar 26, 2016
### 4.1.2 (2016-03-22)

 * Handle derived classes in the exception converter (see #462).
 * Prevent the autofocus attribute from being added multiple times (see contao/core#8281).
 * Respect the SSL settings of the root page when generating sitemaps (see contao/core#8270).
 * Read from the temporary file if it has not been closed yet (see contao/core#8269).
 * Always use HTTPS if the target server supports SSL connections (see contao/core#8183).
 * Adjust the meta wizard field length to the column length (see contao/core#8277).
 * Correctly handle custom mime icon paths (see contao/core#8275).
 * Show the 404 error page if an unpublished article is requested (see contao/core#8264).
 * Correctly count the URLs when rebuilding the search index (see contao/core#8262).
 * Ensure that every image has a width and height attribute (see contao/core#8162).
 * Set the correct mime type when embedding SVG images (see contao/core#8245).
 * Handle the "float_left" and "float_right" classes in the back end (see contao/core#8239).
 * Consider the fallback language if a page alias is ambiguous (see contao/core#8142).
 * Fix the error 403/404 redirect (see contao/website#74).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants