Add native plain text literal URL rewrites#285
Open
adamziel wants to merge 1 commit into
Open
Conversation
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.
What changed
Adds
wp_native_apis_rewrite_plain_text_literal_urls()to the native APIs extension for known plain-text leaf values.The new primitive accepts compact
source-origin\x1ftarget-prefixrows separated by\x1e, rewrites HTTP(S) source-origin matches, and returnsfalseinstead of guessing when a value contains structured-data delimiters or a source-origin match is not bounded as a URL origin.Why
Reprint now has a rigorous PHP plain-text literal fast path, but that path still runs for hundreds of thousands of SQL values under PHP.wasm. Moving the narrow, parser-owned leaf rewrite into the native extension cuts that hot path without reintroducing naive URL replacement in structured containers.
Benchmarks
PHP.wasm 8.4.21, native APIs extension built from this branch, 2,000 iterations of the new
plain-text-literal-url-rewritebenchmark workload:Reprint large SQL rewrite-only profile, 262 MB dump, both PHP.wasm native manifests loaded:
Validation
cargo test -qinextensions/native-apisvendor/bin/phpcs -d memory_limit=1G bin/benchmark-native-apis.php extensions/native-apis/tests/verify-native-apis.phpphp -l extensions/native-apis/tests/verify-native-apis.php && php -l bin/benchmark-native-apis.phpRUSTFLAGS='-C link-arg=-undefined -C link-arg=dynamic_lookup' extensions/native-apis/build-extension.shphp -d extension=$(pwd)/extensions/native-apis/target/release/libwp_native_apis.dylib extensions/native-apis/tests/verify-native-apis.phpextensions/native-apis/build-playground-extension.sh /Users/cloudnik/conductor/workspaces/studio/amsterdam/.context/wasm-extensions/php-toolkit-native-literalwp_native_apis_rewrite_plain_text_literal_urls()using the built manifestcomposer lintstill reports existing repository-wide warnings unrelated to this PR; the changed PHP files pass PHPCS directly.