简体   繁体   English

Drupal 9 - 代码修改不生效

[英]Drupal 9 - Code modification doesn't take effect

I am trying to debug some code on my Drupal 9 application.我正在尝试在我的Drupal 9应用程序上调试一些代码。

For example, at the file web/index.php , I try to add die('Was here')例如,在文件web/index.php中,我尝试添加die('Was here')

<?php 

    use Drupal\Core\DrupalKernel;
    use Symfony\Component\HttpFoundation\Request;

    $autoloader = require_once 'autoload.php';

    //My code is here
    die('Was here');

    $kernel = new DrupalKernel('prod', $autoloader);

    $request = Request::createFromGlobals();
    $response = $kernel->handle($request);
    $response->send();
    $kernel->terminate($request, $response);

At first, I got the result on my browser.起初,我在浏览器上得到了结果。 Next I delete this die function, and when i refresh my browser, I get the same as before as if I didn't change the code接下来我删除这个die function,当我刷新浏览器时,我得到的和以前一样,就好像我没有更改代码一样

After some minutes, the expected result is shown in my browser.几分钟后,预期的结果会显示在我的浏览器中。 So weird太奇怪了

So I am wondering why is Drupal isn't taking that code change into account.所以我想知道为什么 Drupal 没有考虑到代码更改。

Btw, I run the command drush cr but it didn't change anything顺便说一句,我运行命令drush cr但它没有改变任何东西

That sounds like PHP OpCode Cache.这听起来像 PHP 操作码缓存。 You can see if its enabled or not in the Drupal status report under "PHP OPcode caching".您可以在“PHP OPcode 缓存”下的 Drupal 状态报告中查看其是否启用。 There's a page on on disabling Drupal Caching [here][1] which includes a section on opcache.有一个关于禁用 Drupal 缓存的页面 [这里][1] 其中包括关于 opcache 的部分。 I believe to disable opcache you can add an entry to your php.ini file.我相信要禁用 opcache,您可以在 php.ini 文件中添加一个条目。

opcache.enable=0

Be sure to restart relevant services like php-fpm.一定要重启相关服务,如 php-fpm。 And verify it was effective in the Drupal status report.并在 Drupal 状态报告中验证它是否有效。 [1]: https://www.drupal.org/node/2598914 [1]: https://www.drupal.org/node/2598914

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM