Open ivangretsky opened 2 years ago
@ivangretsky Can you try changing line 825 in /wire/core/MarkupQA.php from this:
if(($pagefile->page->id != $this->page->id && !$user->hasPermission('page-view', $pagefile->page))
to this:
if(($pagefile->page->id != $this->page->id && !$pagefile->page->viewable(false))
Does that enable it to work?
@ryancramerdesign , did try that and changing that line did not help.
@ivangretsky Thanks for trying it. Do you by any chance have access control enabled manually on any of your repeater templates or fields within them? If so, disable that. If not, then it sounds like we might need a full repeater check here then. Usually we don't because the PagePermissions module handles it internally, but occasionally there are cases where we do need to add a repeater check. Here's the entire block of code updated to add a full repeater access check, are you able to try this? (I don't yet have an environment with the same setup as yours). If so, replace the entire if($options['removeNoAccess']) { ... }
with this new one below:
if($options['removeNoAccess']) {
$page = $pagefile->page; /** @var Page|RepeaterPage $page */
$field = $pagefile->field;
$removeImage = false;
if(wireInstanceOf($page, 'RepeaterPage')) {
$page = $page->getForPageRoot();
$field = $page->getForFieldRoot();
}
if($page->id != $this->page->id && !$page->viewable(false)) {
$this->error("Image on page ($page) that user does not have view access to: $src");
$removeImage = true;
} else if($field && !$page->viewable($field)) {
$this->error("Image on page:field ($page:$field) that user does not have view access to: $src");
$removeImage = true;
}
if($removeImage) {
if($this->page->of()) $value = str_replace($img, '', $value);
return;
}
}
@ivangretsky can you provide more info for Ryan?
@ivangretsky Also the issue fixed in #1561 may be related
I have tried to replace the code as @ryancramerdesign suggested . The results are mixed.
Exception: Method DefaultPage::getForFieldRoot does not exist or is not callable in this context
unless I comment out the one string in the new code (see below).So we must be getting close) Sorry for not doing it earlier.
@ivangretsky Ivan, thank you for testing. Did you try the latest PW version, which contains the fix for issue 1561?
Nope. Will try upgrading.
Did upgrade to 3.0.199, but it did NOT fix the issue.
@ivangretsky are you using ProDrafts?
@cb2004 , yes, it is installed.
@cb2004 , thanks for your suggestion. Did try moving that line from init() to ready(), but it didn't seem to help,
@ryancramerdesign , do you have any ideas how we can move this forward? Did my testing results above help?
@ivangretsky can you provide instructions for a setup without using RepeaterMatrix? If I understand correctly, you have a repeater with textarea and CKE as inputfield, and enabled image access control? Can you do bd($page->getForRoot());
?
@ivangretsky ping
Short description of the issue
Images that are inserted inside (in my case multilang) textarea fields, that are part of Repeaters, that are in their case, are part of (inside) Repeater matrix fields are stripped out of output due to access settings. Images inside RM items are not - probably, there is some "special treatment" for them.
The Repeaters structure
The textarea settings
Expected behavior
Images should not be removed from any fields, that are filled from current page. Not from 1st level RM items, not from 2nd level Repeater/PM items inside of the 1st level items. I guess 3 levels deep would be ok if any depth restriction has to be imposed.
Setup/Environment