Repository navigation
MBlock-Migration: Felder nach Kommentar am Zeilenende und mit Block-Index > 0 - #473
Merged
Merged
Conversation
…ndex > 0 Der Analyzer ordnete Anweisungen nach einer Zeile mit Kommentar am Ende nicht mehr dem Block-Formular zu (Kommentar stand am Anfang der Folgeanweisung). Felder wie "$id.2.extern" wurden nicht erkannt und nicht konvertiert. Tests und Fixture ergänzt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
|
Caution Review failedThe pull request is closed. WalkthroughMoin. Der Analyzer und der Konverter erkennen bei der MBlock-Migration Feldnamen mit beliebigen numerischen Block-Indizes. Der Analyzer überspringt außerdem führende Zeilenendkommentare bei der Prüfung von Statements. Neue Tests und eine Fixture prüfen diese Fälle. ChangesMBlock-Migration
Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Possibly related PRs
Merge Risk:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Beim Umstellen eines bestehenden Projekts (REDAXO 5.21, sechs MBlock-Module) hat
mform:migrateFelder übersehen. Zwei Ursachen:$mform->addTextField("$id.0.alt", [...]); // use string for x.0 json values.formRegion()zerlegt den Code an;– der Kommentar landet am Anfang der nächsten Anweisung, die dann nicht mehr mit$mform->beginnt und ausgeblendet wird. Folge: Diese Felder fehlen in Analyse, Key-Map und Konvertierung. Besonders unangenehm beiaddCustomLinkField("$id.0.1")– die Daten werden dann nicht von1auflinkumbenannt."$id.2.extern"/"$id.3.content"wurden weder erkannt noch im Eingabe-Code umgeschrieben. MBlock nummeriert den Index beim Speichern ohnehin um und speichert nurexternbzw.content.Lösung
MBlockModuleAnalyzer::formRegion(): Für die Zuordnung zum Formular werden führende//- und#-Kommentarzeilen einer Anweisung übersprungen (#[für Attribute bleibt ausgenommen, wie inblankComments()).\.\d+\.statt\.0\.), auch bei verschachtelten Namen.Tests
Neue Fixture
mblock_trailing_comments_input.php.txt(Muster aus dem Praxisfall, ohne Projektdaten) und drei Tests:testKeepsFieldsAfterTrailingComments– Custom-Link,altund Feld nach#-Kommentar werden erkannt, Key-Map1 => link.testRecognizesFieldsWithNonZeroBlockIndex–"$id.2.target","$id.3.content".testConvertInputStripsNonZeroBlockIndexAndKeepsCommentedLines– Konverter schreibt alle Felder um.Ohne die Korrektur schlagen die drei neuen Tests fehl; mit ihr:
OK (64 tests, 252 assertions).Summary by CodeRabbit