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

SimplifiedOverviewAndPublishing throws 503 "Call to a member function addRelatedRecord() on null" #105

Closed
YKWeyer opened this issue Oct 6, 2023 · 2 comments
Labels

Comments

@YKWeyer
Copy link
Contributor

YKWeyer commented Oct 6, 2023

Versions: TYPO3 11.5.31, in2publish 11.2.1, in2publish_core 11.0.7

When using SimplifiedOverviewAndPublishing, opening the Content Publisher overview module returns a 503 error for specific pages with the following error message:

Call to a member function addRelatedRecord() on null

It seems to happens in the ShallowRecordFinder in the addChildPagesRecursively method, on line 287 ($pageRecords[$pid]->addRelatedRecord($record);)

My guess is, sometimes the translations will be delivered by the database before the origin records, since they all have the same sorting value (used by SingleDatabaseRepository::findByProperty). For example in our pages table, when looking for records under a specific pid and using the sorting column to order results, the translation with uid 61483 will come after its parent record 75:

image

But the loop expects the origin for translations (used as $pid) to be already in the $pageRecords array. A possible workaround would be to add the languageField as an additional (asc) order field in SingleDatabaseRepository::findByProperty:

         if (!empty($GLOBALS['TCA'][$table]['ctrl']['sortby'])) {
             $query->orderBy($GLOBALS['TCA'][$table]['ctrl']['sortby']);
         } elseif (!empty($GLOBALS['TCA'][$table]['ctrl']['default_sortby'])) {
             $orderByClauses = QueryHelper::parseOrderBy($GLOBALS['TCA'][$table]['ctrl']['default_sortby']);
             foreach ($orderByClauses as $orderByClause) {
                 if (!empty($orderByClause[0])) {
                     $query->addOrderBy($orderByClause[0], $orderByClause[1]);
                 }
             }
         } else {
             $query->orderBy('uid');
         }

+        if (!empty($GLOBALS['TCA'][$table]['ctrl']['languageField'])) {
+            $query->addOrderBy($GLOBALS['TCA'][$table]['ctrl']['languageField']);
+        }
+

         $result = $query->execute();

That being said, I am a little unsure, since I assume this issue would affect most of the multilingual websites, and I am wondering why it didn't surface until now. Maybe it's an edge case that only happens in our setup?

@sbusemann
Copy link
Contributor

Planned for team: https://projekte.in2code.de/issues/59565

@dhoffmann1979
Copy link
Member

PR is merged into develop-v11

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

No branches or pull requests

3 participants