Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All links in cached page appended with ?stage=Live in v4.11.11 of framework #150

Open
ollyradford opened this issue Nov 21, 2022 · 5 comments

Comments

@ollyradford
Copy link

As reported in issue #102 (for SS v3), cached links still have the stage appended when static publishing in SS v4.

Tested with silverstripe v4.11.11 and staticpublishqueue v5.2.

Did anyone figure out the cause?

@lars-lemon8
Copy link
Contributor

Hi Olly,

Your issue is also referenced here -> symbiote/silverstripe-queuedjobs#361

Can you elaborate a bit on how to replicate this ? I'm running the staticpublisher in production (from cli) and do not have this problem.

@ollyradford
Copy link
Author

After digging a bit more, I found that "?stage=Live" is only appended to page links when static publishing via the “StaticCacheFullBuildJob”, but not “GenerateStaticCacheJob”.

The latter being used to refresh the cache when edits to a page are published.

I am developing on a windows environment (XAMPP) and can't seem to get the build tasks to run on the command line with sake. So I use the "/dev/tasks/SilverStripe-StaticPublishQueue-Task-StaticCacheFullBuildTask?flush=1" in the browser to queue a full build and then run this in the QueuedJob section.

On a side note, the browser outputs "SilverStripe\StaticPublishQueue\Job\StaticCacheFullBuildJob added to the queue for immediate processing", yet the job is just queued and needs to be manually run.

I hope that helps track down the cause, but let me know if you need anything else.

To others that are also need a quick fix, I worked around this by overriding urlsToCache() on Page.php so publishing any page adds a full build using the "GenerateStaticCacheJob" which doesn't append the stage:

use SilverStripe\Control\Director;
use SilverStripe\StaticPublishQueue\Contract\StaticallyPublishable;
use SilverStripe\StaticPublishQueue\Extension\Publishable\PublishableSiteTree;
use SilverStripe\StaticPublishQueue\Job;
use SilverStripe\StaticPublishQueue\Publisher;
use SilverStripe\Versioned\Versioned;

////

public function urlsToCache()
{

	  $urls = [];
	  $livePages = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE);
	  foreach ($livePages as $page) {

	  	  // skip pages using the exclude class, if using
	  	  if ($page->hasExtension(ExcludeFromStaticPublisher::class)) {
		  	  continue;
	  	  }

     	  	   if ($page->hasExtension(PublishableSiteTree::class) || $page instanceof StaticallyPublishable) {
		  	  $url = Director::absoluteURL($page->Link());
		  	  $url = str_replace( '?stage=Live', '', $url ); // forece removal of stage url param
        	  	  $urls[$url] = 0;
      	  	  }
	  }

	  return $urls;

}

Cheers,
Olly

@lars-lemon8
Copy link
Contributor

I dot not see this issue in V5.3.0.

Oddly enough, for me the problem is that the StaticCacheFullBuild job adds a couple of ?stage=Stage urls to the list of urls to process. In my case, out of 182 url's in total, 7 of them have the stage added to the URL.

This results in the task being paused and stuck on 175 (182-7) correctly published pages.

@ollyradford , can you try reproducing this with a the latest versions of all modules ?

@michalkleiner
Copy link
Contributor

@lars-lemon8 is there something special about those 7 pages? Custom extensions? Redirector pages? Something else?

@lars-lemon8
Copy link
Contributor

@michalkleiner , They are included in a urlsToCache() method. I created a related ticket for the issue -> #159

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants