Problems with additional contexts
Closed this issue · 4 comments
gravinos commented
Hello Bob, excellent contribution!
It works great if you site with only one context, but when you have more contexts, that are not "web" returns error!
As it does not complete the url correctly with "site_url" or "base_url" setting.
Exception: Client error: HEAD https://www.domain.com/news/en-context.html resulted in a 404 Not Found response
in this case the correct url is: https://www.domain.com/en/news/en-context.html
Thanks, regards.
BobRay commented
Can you try replacing the code of the
core/components/refreshcache/processors/getlist.class.php file with the
code below?
On Fri, Mar 12, 2021 at 4:17 AM Gravino Design ***@***.***> wrote:
Hello Bob, excellent contribution!
It works great if you site with only one context, but when you have more
contexts, that are not "web" returns error!
As it does not complete the url correctly with "site_url" or "base_url"
setting.
Exception: Client error: HEAD https://www.domain.com/news/en-context.html
resulted in a 404 Not Found response
in this case the correct url is:
https://www.domain.com/en/news/en-context.html
Thanks, regards.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#4>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACRZIQZ7VK4UD32AVVZSFLTDHL2HANCNFSM4ZB4XVIQ>
.
<?php
if (! defined('MODX_CORE_PATH')) {
/* For dev environment */
include 'c:/xampp/htdocs/addons/assets/mycomponents/instantiatemodx/instantiatemodx.php';
$modx->log(modX::LOG_LEVEL_ERROR, 'Instantiated MODX');
}
require_once MODX_CORE_PATH . 'model/modx/modprocessor.class.php';
class refreshcacheGetListProcessor extends modObjectGetListProcessor {
public $classKey = 'modResource';
public $defaultSortField = 'pagetitle';
public $defaultSortDirection = 'asc';
public $objectType = 'modResource';
public function initialize() {
parent::initialize();
$limit = $this->modx->getOption('rc.limit', null, 0, true);
$this->setProperty('limit', $limit);
return true;
}
public function prepareQueryBeforeCount(xPDOQuery $c) {
$c->select('id,pagetitle,uri,context_key');
$fields = array(
'cacheable:=' => '1',
'deleted:!=' => '1',
'class_key:!=' => 'modWebLink',
'published:!=' => '0',
'AND:class_key:!=' => 'modSymLink',
);
$c->where($fields);
return $c;
}
public function prepareRow(xPDOObject $object) {
$ta = $object->toArray('', false, true, true);
$ta['uri'] = $this->modx->makeUrl($ta['id'],
$ta['context_key'], "", "full");
/*if (empty($ta['uri'])) {
$this->modx->makeUrl($ta['id'], "", "", "full");
} else {
$ta['uri'] = MODX_SITE_URL . $ta['uri'];
}*/
return $ta;
}
public function getData() {
$d = parent::getData();
return $d;
}
}
return 'refreshcacheGetListProcessor';
gravinos commented
Hi Bob!
Seems to work fine!! I have no errors in the log and resources are properly cached for all contexts!
Thanks
BobRay commented
Thanks! I'll try to get out a new version soon.
BobRay commented
Version 1.2.1 released.