You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

技术问询:Drupal 8与Drupal 9的核心差异(除Symphony更新外)

Drupal 8 vs Drupal 9: Core Differences Beyond Symfony Version Updates

Hey there, let's dive into the key distinctions between Drupal 8 and Drupal 9—beyond the widely discussed Symfony upgrade (from 3.x/4.x to 4.x/5.x). These changes are all about cleaning up technical debt, modernizing the stack, and making Drupal more maintainable and performant for developers and site owners alike.

1. Full Removal of Deprecated Code

Drupal 8 was a major rewrite, and over its lifecycle, it accumulated tons of deprecated functions, classes, hooks, and APIs to ease the transition from Drupal 7. Drupal 9 wipes all that deprecated code entirely.

For example:

  • The old drupal_set_message() function is gone—you must now use the MessengerInterface service:
    // Drupal 8 (deprecated)
    drupal_set_message('Hello world');
    
    // Drupal 9 (required)
    \Drupal::messenger()->addMessage('Hello world');
    
  • Deprecated hooks like hook_node_view() are removed; you’ll need to use the entity-agnostic hook_ENTITY_TYPE_view() instead.

This cleanup makes the codebase leaner, faster, and eliminates confusion between "old" and "new" ways of doing things.

2. Modernized Frontend Tech Stack

Drupal 9 brought significant upgrades to frontend tools that directly impact editors and developers:

  • CKEditor 5 replaces CKEditor 4: The default WYSIWYG editor got a complete overhaul. CKEditor 5 offers a more intuitive interface, real-time collaboration support, better media embedding, and customizable editor "presets" tailored to different content types.
  • jQuery 3.x instead of 1.x: Upgrading to jQuery 3.x fixes compatibility issues with modern browsers, improves performance, and removes outdated jQuery APIs that were already deprecated in Drupal 8.
  • Twig 2/3 Upgrade: Twig (Drupal’s templating engine) got a major version bump. This brings faster template rendering, stricter syntax checks, and new features like improved loop handling and better error messages. You might need to adjust templates using old Twig filters or tags (e.g., {% filter %} syntax changes).

3. Core Module Shuffles & Improvements

Drupal 9 streamlined its core module set and enhanced key features:

  • Contrib Shift for Non-Essential Modules: Modules like Forum and Color were moved from core to contributed projects. This reduces core bloat, letting the community maintain these modules more flexibly.
  • Media Module Enhancements: The core Media module (introduced in Drupal 8) got major improvements in Drupal 9—including a more user-friendly media library, better integration with content types, and support for additional media sources.
  • Layout Builder Polishing: Layout Builder (stable in Drupal 8.7) became more robust in Drupal 9, with better UI/UX, improved template support, and new layout options that make it easier to build custom page layouts without code.

4. Performance & Efficiency Boosts

Beyond the Symfony upgrade, Drupal 9 includes several under-the-hood optimizations:

  • Database Query Optimizations: Core database queries were refined to reduce load times, especially for complex sites with large datasets.
  • Improved Caching Mechanisms: Cache tags and contexts were made more efficient, reducing unnecessary cache invalidations and improving overall site speed.
  • PHP Version Requirements: Drupal 9 requires PHP 7.3 or higher (later updated to 7.4+), while Drupal 8 supported back to PHP 5.5.9. Higher PHP versions bring native performance gains, better memory management, and support for modern language features.

5. Strengthened Security & Compliance

Drupal 9 prioritized security and modern compliance standards:

  • Default HTTPS Support: Drupal 9 encourages HTTPS by default, with improved configuration tools to enforce secure connections.
  • Strict CSRF Protection: Cross-Site Request Forgery (CSRF) protections were tightened, reducing vulnerabilities in form submissions and API requests.
  • Updated Third-Party Libraries: All core dependencies (like Guzzle, Symfony Components, and Twig) were updated to their latest secure versions, patching known vulnerabilities and ensuring long-term support.

6. API Consistency & Simplification

Drupal 9 cleaned up inconsistent APIs to make development more intuitive:

  • Unified Entity APIs: Entity-related functions and interfaces were standardized, reducing redundant ways to interact with entities (nodes, users, etc.).
  • Form API Refinements: The Form API got tweaks to remove deprecated methods and streamline form creation, making it easier to build and maintain complex forms.
  • Service Container Improvements: Dependency injection became more consistent, with fewer "magic" functions and clearer ways to access core services.

Wrapping Up

Drupal 9 isn’t just a "minor upgrade" to Drupal 8—it’s a polished, leaner version of the platform that eliminates technical debt, modernizes key tools, and sets the stage for future versions like Drupal 10. If you’re upgrading from Drupal 8, starting with the 8.9.x branch (the last stable Drupal 8 release) is critical, as it includes all the compatibility layers needed to transition smoothly to Drupal 9.

内容的提问来源于stack exchange,提问作者Wasim Khan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.09 15:17:41