PHP: WordPress templates with inline HTML report whole-file parse_unusable on 0.12.1

未關閉
#3,073 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
42/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
c, php
領域
compilers

研究方向

The payload names no source file for the PHP extractor, so start from the inline-HTML masking introduced for #2000/#2389 and find where the <?php open tag on the first line changes the parse verdict. Run the four-case script at /tmp/cbm-test/repro.py, which compares <?php $a = 1; ?> with the tags on their own lines. Done means the WordPress-style block file reports parse_partial with its PHP symbols extracted, and the repro script exits 0.

由索引模型根據 Issue 內容生成。

描述

bug parsing/quality

PHP: WordPress templates (inline HTML after ?>) report whole-file parse_unusable on 0.12.1

Version: codebase-memory-mcp 0.12.1 (macOS arm64, Apple Silicon)
Related: #2000 / #2389 (inline HTML masking) — the fix works for plain
templates, but the verdict still flips to whole-file parse_unusable for
very common WordPress / ACF shapes.

What happens

Indexing a theme alone in a fresh temp dir reports parse_unusable
(whole_file, ~4 nodes extracted instead of the ~230 nodes you get with the
same file re-shaped):

file result
block/v2/service-cta-4/service-cta-4.php parse_unusable, nodes=4
includes/nav/Navigation.php (class + inline HTML form markup) parse_unusable, nodes=4
same file, HTML head with <?php on its own line, ?> on its own line partial, nodes=5

Because parse_unusable throws away line ranges, check_index_coverage
answers read_source_directly for those paths, so the whole block library
(63/942 files in a large theme, the biggest part of the graph) is gone.

Reproduction

Single file, fresh temp dir each run:

import json, os, shutil, subprocess
CVM = "/path/to/codebase-memory-mcp"
ROOT = "/tmp/repro"

def verdict(body):
    shutil.rmtree(ROOT, ignore_errors=True)
    os.makedirs(ROOT)
    open(os.path.join(ROOT, "t.php"), "w").write(body)
    r = subprocess.run([CVM, "cli", "--json", "index_repository", "--repo-path", ROOT,
                        "--name", "repro", "--mode", "fast"], capture_output=True, text=True)
    r2 = json.loads(json.loads(r.stdout)["content"][0]["text"])
    return r2.get("parse_unusable_count", 0), r2.get("nodes", 0)

# A. WordPress block: php inline on line 1, html tail.
print(verdict('<?php $a = 1; ?>\n<div class="p-4"><?= $v ?></div>\n'))      # ( 1, 4)
# B. The same file with the php tag alone on line 1 / closing alone:
print(verdict('<?php\n$a = 1;\n?>\n<div class="p-4"><?= $v ?></div>\n'))    # ( 0, 5)
# C. Pure php control:
print(verdict('<?php\nfunction f() { return 1; }\n'))                        # ( 0, 6)

Moving the <?php/?> tags onto their own lines flips the file from
parse_unusable to parse_partial (html masked, symbols extracted). The
html-masking pass (#2389) is not consistently in effect for the inline-open
shape.

Expected

Same class of input as #2000: PHP symbols should keep being extracted and
the file should be parse_partial — not parse_unusable with no symbols.
The check_index_coverage "unusable" verdict hides the ranges and makes
callers re-read every template.

Environment

  • codebase-memory-mcp 0.12.1, cli index_repository --mode fast (the MCP
    server tool behaves identically)
  • repro: /tmp/cbm-test/repro.py (4-case assert, exit 0/1)
  • macOS 26, arm64
主要語言
C
星號
45.8k
分支
3.8k
平均合併
2 天 18 小時
30 天內合併 PR
108

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

DeusData/codebase-memory-mcp 的其他 Issue

查看 DeusData/codebase-memory-mcp 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。