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

[BUG] Multi-View not working correctly #1302

Open
beatrycze-volk opened this issue Aug 15, 2024 · 1 comment · Fixed by #1345
Open

[BUG] Multi-View not working correctly #1302

beatrycze-volk opened this issue Aug 15, 2024 · 1 comment · Fixed by #1345
Assignees
Labels
🐛 bug A non-security related bug.

Comments

@beatrycze-volk
Copy link
Collaborator

Description

Class parameter documentArray is null if document is accessed by uid.

Reproduction

Steps to reproduce the behaviour:

  1. Install TYPO3 11.x with PHP 8.x
  2. Click on link to display document page e.g. https://sachsendigital.ddev.site
  3. See error

Expected Behavior

The documentArray parameter should be assigned for each type of document, not only ones accessed by URL.

Screenshots and Examples

documentarrayerror

Environment

  • RDBMS version: MariaDB 10.3
  • TYPO3 version: 11.5.37
  • PHP version: 8.2

Additional Context

The function getDocumentByUid is not adjusted:

    private function getDocumentByUid(int $documentId)
    {
        $doc = null;
        $this->document = $this->documentRepository->findOneByIdAndSettings($documentId);

        if ($this->document) {
            $doc = AbstractDocument::getInstance($this->document->getLocation(), $this->settings, true);
        } else {
            $this->logger->error('Invalid UID "' . $documentId . '" or PID "' . $this->settings['storagePid'] . '" for document loading');
        }

        return $doc;
    }

The function getDocumentByUrl has necessary adjustments:

    protected function getDocumentByUrl(string $documentId)
    {
        $doc = AbstractDocument::getInstance($documentId, $this->settings, true);

        if (isset($this->settings['multiViewType']) && $doc->tableOfContents[0]['type'] === $this->settings['multiViewType']) {
            $childDocuments = $doc->tableOfContents[0]['children'];
            $i = 0;
            foreach ($childDocuments as $document) {
                $this->documentArray[] = AbstractDocument::getInstance($document['points'], $this->settings, true);
                if (!isset($this->requestData['docPage'][$i]) && isset(explode('#', $document['points'])[1])) {
                    $initPage = explode('#', $document['points'])[1];
                    $this->requestData['docPage'][$i] = $initPage;
                }
                $i++;
            }
        } else {
            $this->documentArray[] = $doc;
        }
        .....

        return $doc;
  }
@beatrycze-volk beatrycze-volk changed the title [BUG] Recent adjustment of musical sources iterates over non-existing variable [BUG] Recent adjustment of musical sources uses non-assigned array in count fucntion Aug 15, 2024
@beatrycze-volk beatrycze-volk changed the title [BUG] Recent adjustment of musical sources uses non-assigned array in count fucntion [BUG] Recent adjustment of musical sources uses non-assigned array in count function Aug 15, 2024
@sebastian-meyer sebastian-meyer added the 🐛 bug A non-security related bug. label Aug 19, 2024
@sebastian-meyer sebastian-meyer changed the title [BUG] Recent adjustment of musical sources uses non-assigned array in count function [BUG] Calling count() on null Aug 20, 2024
@sebastian-meyer
Copy link
Member

sebastian-meyer commented Oct 8, 2024

Re-opening this, because #1345 was only a temporary fix. Multi-View still isn't completely implemented!

See also comments in

/**
* Get document from repository by uid.
*
* @access private
*
* @param int $documentId The document's UID
*
* @return AbstractDocument
*/
private function getDocumentByUid(int $documentId)
{
// TODO: implement multiView as it is in getDocumentByUrl
$doc = null;
$this->document = $this->documentRepository->findOneByIdAndSettings($documentId);
if ($this->document) {
$doc = AbstractDocument::getInstance($this->document->getLocation(), $this->settings, true);
// fix for count(): Argument #1 ($value) must be of type Countable|array, null given
$this->documentArray[] = $doc;
} else {
$this->logger->error('Invalid UID "' . $documentId . '" or PID "' . $this->settings['storagePid'] . '" for document loading');
}
return $doc;
}

@sebastian-meyer sebastian-meyer changed the title [BUG] Calling count() on null [BUG] Multi-View not working correctly Oct 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug A non-security related bug.
Projects
None yet
3 participants