Sync upstream updates: JSON schema rules, transaction monitoring and template escaping

BI
22m ago
+3957-221

Laravel Updates

  • Encode the request URL behind the exception page's copy button, so a crafted URL cannot inject script.
  • Keep encoded parameters intact when they are used as numeric query parameters.
  • Add the protected disconnectDatabaseConnections() test teardown hook, called after the parallel-testing teardown callbacks so callbacks that use the database are cleaned up too. In Hypervel it flushes the testing resolver and purges the pools, since the manager holds no connections in pooled mode.
  • Reject invalid dynamic component, binding and slot names instead of compiling them into Blade.
  • Add JsonSchema::rules() to derive validation rules from a JSON schema, with documentation.
  • Limit chained local $ref resolution to 64 levels, so a crafted schema cannot exhaust resources.
  • Check the normalized key when testing guarded attributes, so an alternate spelling such as is-admin cannot reach a mutator for a guarded is_admin.
  • Escape Stringable values and prepended defaults when merging component attributes. Htmlable values stay raw.
  • Compare user IDs as strings in the broadcasting routes stub, so string keys such as UUIDs are accepted.
  • Test the autocomplete prompt fallback, which Hypervel already registers.
  • Keep trans_choice conditions that follow a spaced | separator.
  • Stop an empty input field from hiding an uploaded file with the same name, which let the file skip its validation rules.
  • Align Relation::withCasts() and its tests with upstream. Hypervel already applied the casts to models created through the relation.
  • Add model(), modelOrFail() and models() to form requests for loading models from input IDs, with documentation.
  • Pass write options through copyToDisk() and moveToDisk(), including the scoped filesystem proxy and Sentry's filesystem decorator.
  • Add lockForNoKeyUpdate() to the query builder. PostgreSQL uses for no key update, which still blocks other writers but lets inserts that reference the row check their foreign keys. skipLocked() works with it in either order.
  • Test that logging in a user without a password clears the previous password hash. Hypervel already did this.
  • Dispatch UniqueJobSkipped when the scheduler skips a unique job because its lock is held.
  • Add whenTransactionRunsLongerThan() to connections and the DB manager. Connection callbacks belong to the current borrower and are cleared when the connection returns to the pool. Manager callbacks are registered at boot and time every borrower of the named connection, including a transaction rolled back on release.
  • Allow a manager's default driver to be an enum.
  • Run the database tests against PostgreSQL 19.
  • Use strict doubles in two ported tests.

Additional Hypervel changes

  • Require hypervel/guzzle 8.6.0.1 and hypervel/guzzle-promises 3.2, and exempt both forks from the Composer release cooldown.
  • Add a literal option to the gt, gte, lt and lte rules. It compares against the given value even when an input field has the same name, so gt:10,literal never reads a field called 10. JSON schema exclusive bounds use it and keep full float precision.
  • Fix JSON schema rule generation: lists nested under a wildcard check uniqueness per list instead of across every parent, uniqueness checks on array items treat 0.0 and -0.0 as equal and compare uploaded files by identity, and a value is nullable only when its type, enum or anyOf branches allow null.
  • Keep each transaction's duration separate when a callback, listener or overridden event hook runs another transaction, and when completion events are deferred.
  • Fix the DB manager's query duration monitor for connection names with a read or write role. A base name covers both roles, and a role-qualified name matches only that role.
  • Resolve a prepended component attribute default only once, and build the guarded-attribute patterns once per check instead of once per guarded key.
  • Fix the ->email() call in the JsonSchema::rules() documentation example, which does not exist, to ->format('email').

Summary by cubic

Syncs a batch of upstream Laravel updates covering security fixes in Blade and request handling, new validation and database features, and test hardening.

  • Fixes XSS vectors: the exception page's copy-URL button encodes the request URL, dynamic component and slot names are validated before compilation, and Stringable component attributes are escaped.
  • Prevents an empty input from shadowing an uploaded file and bypassing its validation rules; closes a guarded-attribute bypass via alternate spellings like is-admin.
  • Adds JsonSchema::rules() for deriving validation rules, with strict enum/anyOf checks and a literal option on gt, gte, lt and lte.
  • Adds whenTransactionRunsLongerThan() on connections and the DB manager, lockForNoKeyUpdate() for PostgreSQL, and model(), modelOrFail() and models() on form requests.
  • Passes write options through copyToDisk()/moveToDisk(), limits JSON schema $ref chaining to 64 levels, and runs database tests against PostgreSQL 19.

[!NOTE]

Sync upstream: JSON schema validation rules, transaction duration monitoring, Blade escaping fixes

  • Adds JsonSchema::rules() to derive validation rules from object schemas, with new rules MatchesAnyOf, MatchesEnum, DistinctArrayItems, and RejectEmptyString; caps schema fragments at JsonSchema::MAX_NODES (20,000) and lowers local $ref depth from 256 to 64 levels.
  • Adds transaction-duration monitoring: Connection::whenTransactionRunsLongerThan() and DatabaseManager::whenTransactionRunsLongerThan() run callbacks when the outermost transaction exceeds a threshold; manager-level handlers use event listeners while connection-level handlers run directly.
  • Fixes Blade template handling in ComponentAttributeBag.php: merge() no longer resolves appendable defaults twice, and null/boolean/Htmlable values are not escaped. DynamicComponent.php now validates component, binding, and slot names against a safe character set and throws InvalidArgumentException otherwise.
  • Other changes: lockForNoKeyUpdate() on the query builder (PostgreSQL grammar support), literal comparisons for gt/gte/lt/lte, FormRequest model lookup helpers (model(), modelOrFail(), models()), options support for copyToDisk()/moveToDisk(), UniqueJobSkipped event on skipped scheduled jobs, request input all() now replaces blank input values with colliding uploaded files, and guarded-attribute checks match studly-normalized names.
  • Risk: the $ref depth limit drop from 256 to 64 in Deserializer.php may reject schemas that previously deserialized; all() blank-value/file merging in InteractsWithInput.php changes combined input behavior for empty text values; isGuarded() in GuardsAttributes.php now blocks more attribute spellings, which could reject mass assignment that previously passed.

Macroscope summarized fd68f0d.

Summary by CodeRabbit

  • New Features
    • Monitor long-running transactions with configurable callbacks.
    • Build validation rules from JSON Schemas, and retrieve models directly from request input.
    • Pass visibility settings or storage-specific options when copying or moving files.
    • Use PostgreSQL’s FOR NO KEY UPDATE locking mode.
  • Bug Fixes
    • Improved handling of uploaded files that share keys with request input, guarded model attributes, encoded query values, and dynamic component names.
    • Unique scheduled jobs now emit a skip event when applicable.
  • Documentation
    • Expanded guidance for database monitoring, file transfers, request model retrieval, validation, and query locking.