After fetching a page, it gets cached for the next time you may want to fetch it. However, when fetching an attachment as a page, there is an additional lookup that takes place to also pull the attachment data. This also gets added to cache, but
the entry ID doesn't match. So when you fetch it the second time, the attachment data is not in the expected entry. During Rebuild Content URLs, it first fetches all the pages in the batch to reduce queries. Then it cycles all the IDs in that batch and fetches them from cache in order to work on each one at a time. Since the working copy is missing the attachment data, when the content gets saved, the metadata is now missing some attachment information.
In 4.1.7, the cache structure was changed because some information in the cache is user-specific, and it was possible to pull that data for the wrong user in previous versions. However, the cache structure change was not applied to one path for creating cache entries, leading to the issue of an incorrect entry ID for some page-types.
In
src/addons/vw/vw/_core/controller/fetch/vw.php, find:
Code:
$this->verify_retval($node, $retval);
Replace with:
Code:
$this->verify_retval($node, $retval, $withVisitor);
Find (2x):
Code:
array_pop($this->doers);
Replace with (2x):
Code:
//array_pop($this->doers);
Find:
Code:
public function verify_retval(&$node, &$items)
Replace with:
Code:
public function verify_retval(&$node, &$items, $withVisitor = true)
Find:
Code:
$doer->verify_retval($this, $node, $items);
Replace with:
Code:
$doer->verify_retval($this, $node, $items, $withVisitor);
In
src/addons/vw/vw/_core/controller/fetch/stack/vw.php, find:
Code:
public function verify_retval(&$caller, &$node, &$items)
Replace with:
Code:
public function verify_retval(&$caller, &$node, &$items, $withVisitor = true)
Find (2x):
Code:
$caller->set_itemcache($node, $item);
Replace with (2x):
Code:
$caller->set_itemcache($node, $item, $withVisitor);
Find:
Code:
$tmp = $this->fetcher->get_doer($stack_node['accesskey'])->stack_info(
$stack_node['table'] == 'page' ? '' : $prep['p']['fields']['pageid'],
true
);
Replace with:
Code:
$tmp = $this->fetcher->get_doer($stack_node['accesskey'])->stack_info(
$stack_node['table'] == 'page' ? '' : $prep['p']['fields']['pageid'],
true,
$withVisitor
);
In
src/addons/vw/vw/_core/controller/fetch/index/vw.php, find:
Code:
public function verify_retval(&$caller, &$node, &$items)
Replace with:
Code:
public function verify_retval(&$caller, &$node, &$items, $withVisitor = true)
After making these changes, I was able to run Rebuild Content URLs without losing attachment metadata. You can modify Rebuild Content URLs to additionally count all the links/usages in the content. In
src/addons/vw/vw/_core/model/cron/deferred/settings/url/vw.php, find:
Code:
$itemdm->set_info('skip_links', 1);
Replace with:
Code:
//$itemdm->set_info('skip_links', 1);
When you are done, you may wish to change this line back, as it makes the tool do a LOT more work.