Skip to content

Strip SQL -- comments before executing migration statements#6

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-comment-cleanup-in-migrations
Draft

Strip SQL -- comments before executing migration statements#6
Copilot wants to merge 2 commits into
mainfrom
copilot/fix-comment-cleanup-in-migrations

Conversation

Copy link
Copy Markdown

Copilot AI commented May 26, 2026

When a SQL statement is commented out with --, the migration engine was attempting to execute the comment as a query, causing a crash.

Changes

  • src/MigrationCore.php: In executeQueryFile(), apply preg_replace('/--.*/', '', $line) to each non-separator line before accumulating it into the current statement. Lines that become empty after stripping are skipped entirely.
} else {
    $line = trim((string)preg_replace('/--.*/', '', $line));
    if ($line === '') {
        continue;
    }
    // ...accumulate $line into $current_request
}
  • test/MigrationCoreSecurityTest.php: Three new tests covering inline trailing comments, fully-commented-out query segments, and mixed comment/SQL files.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHPCSStandards/PHP_CodeSniffer/zipball/0ca86845ce43291e8f5692c7356fccf3bcf02bf4
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/fzed51/console-options/zipball/2ff65bb78ffcd7e70ef75189a715e664e78b8fff
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/fzed51/pdo-helper/zipball/cd1a040b53ab53a2b79d92abb8ab3ad0dd5eee82
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/myclabs/DeepCopy/zipball/07d290f0c47959fd5eed98c95ee5602db07e0b6a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/nikic/PHP-Parser/zipball/dca41cd15c2ac9d055ad70dbfd011130757d1f82
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phar-io/manifest/zipball/54750ef60c58e43759730615a392c31c80e23176
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phar-io/version/zipball/4f7fd7836c6f332bb2933569e566a0d6c4cbed74
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/phpstan/phpstan/zipball/8be50c3992107dc837b17da4d140fbbdf9a5c5bd
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/sebastianbergmann/cli-parser/zipball/15c5dd40dc4f38794d383bb95465193f5e0ae180
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/183a9b2632194febd219bb9246eee421dad8d45e
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/code-unit/zipball/54391c61e4af8078e5b276ab082b6d3c54c9ad64
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/comparator/zipball/2c95e1e86cb8dd41beb8d502057d1081ccc8eca9
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/complexity/zipball/ee41d384ab1906c68852636b6de493846e13e5a0
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/diff/zipball/b4ccd857127db5d41a5b676f24b51371d76d8544
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/environment/zipball/a5c75038693ad2e8d4b6c15ba2403532647830c4
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/70a298763b40b213ec087c51c739efcaa90bcd74
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/global-state/zipball/3be331570a721f9a4b5917f4209773de17f747d7
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/lines-of-code/zipball/d36ad0d782e5756913e42ad87cb2890f4ffe467a
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/f5b498e631a74204185071eb41f33f38d64608aa
    • Triggering command: REDACTED, pid is -1 (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ZpZhMl /usr/bin/composer install --no-interaction --ignore-platform-req=ext-xdebug en git k/_temp/ghcca-no--quiet git bran�� ed04922802c15e1de5d7447b4856de949cf56^{commit}' git d92ad903^{commit} en git /home/REDACTED/.co--hard git (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/6e1a43b411b2ad34146dee7524cb13a068bb35f9
    • Triggering command: REDACTED, pid is -1 (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/ZpZhMl /usr/bin/composer install --no-interaction --ignore-platform-req=ext-xdebug en git k/_temp/ghcca-no--quiet git bran�� ed04922802c15e1de5d7447b4856de949cf56^{commit}' git d92ad903^{commit} en git /home/REDACTED/.co--hard git (http block)
  • https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2c1ed04922802c15e1de5d7447b4856de949cf56
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/2f3a64888c814fc235386b7387dd5b5ed92ad903
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-invoker/zipball/c1ca3814734c07492b3d4c5f794f4b0995333da2
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/3e0404dc6b300e6bf56415467ebcb3fe4f33e964
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3b415def83fbcb41f991d9ebf16ae4ad8b7837b3
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/adc7262fccc12de2b30f12a8aa0b33775d814f00
    • Triggering command: REDACTED, pid is -1 (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/f6458abbf32a6c8174f8f26261475dc133b3d9dc
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/f77d2d4e78738c98d9a68d2596fe5e8fa380f449
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c687e3387b99f5b03b6caa64c74b63e2936ff874
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/staabm/side-effects-detector/zipball/d8334211a140ce329c13726d4a715adbddd0a163
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/HRFIQg /usr/bin/composer install (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/vVFooF /usr/bin/composer install --no-interaction --prefer-dist (http block)
    • Triggering command: /usr/bin/php8.3 /usr/bin/php8.3 -n -c /tmp/QCItwh /usr/bin/composer install --no-interaction git com-sebastianbergit (http block)
  • https://api.github.com/repos/theseer/tokenizer/zipball/b7489ce515e168639d17feec34b8847c326b0b3c
    • Triggering command: REDACTED, pid is -1 (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI linked an issue May 26, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix cleanup of comments in migration scripts Strip SQL -- comments before executing migration statements May 26, 2026
Copilot AI requested a review from fzed51 May 26, 2026 00:35
Copilot finished work on behalf of fzed51 May 26, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nettoyage des commentaires

2 participants