我已从我的
id
中删除了列/属性 Entity
,我认为存在一些缓存问题,导致在尝试访问 Entity
时出现以下错误:
Uncaught ReflectionException: Given object is not an instance of the class this property was declared in in [...]/vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php:33
Stack trace:
#0 .../vendor/doctrine/persistence/src/Persistence/Reflection/TypedNoDefaultReflectionPropertyBase.php(33): ReflectionProperty->isInitialized(Object(Project\Entities\Entity))
#1 .../vendor/doctrine/orm/src/UnitOfWork.php(586): Doctrine\Persistence\Reflection\TypedNoDefaultReflectionProperty->getValue(Object(Project\Entities\Entity))
...
Creation of dynamic property Project\Entities\Entity::$id is deprecated;
.../vendor/doctrine/persistence/src/Persistence/Reflection/RuntimeReflectionProperty.php; 60
我已经运行了
php config/cli-config.php orm:generate-proxies
(成功生成了新代理),但是当尝试以下任何操作来清除缓存时:
php config/cli-config.php orm:clear-cache:query
php config/cli-config.php orm:clear-cache:metadata
php config/cli-config.php orm:clear-cache:result
我收到这样的错误:
In MemcachedAdapter.php line 300:
MemcachedAdapter client error: connection failure
“修补程序”是将
isDevMode
参数更改为 true
:
return new EntityManager(
DriverManager::getConnection($params),
ORMSetup::createAttributeMetadataConfiguration(
paths: [__DIR__ . '/../Entities'],
isDevMode: true, // :(
proxyDir: __DIR__ . '/../../../tmp',
),
);
请帮助我正确修复这些错误。我不知道接下来要做什么/检查。
运行于:
cli-config.php
基本上是:
ConsoleRunner::run(new SingleManagerProvider($entity_manager));
澄清一下:
我已经改变了这个:
#[Id]
#[Column(name: 'id', type: Types::INTEGER, updatable: false, options: ['unsigned' => true])]
#[GeneratedValue]
private int $id;
对此:
#[Id]
#[OneToOne(targetEntity: Base::class, inversedBy: 'entity')]
#[JoinColumn(name: 'id', referencedColumnName: 'id', unique: true)]
private Base $base;
和
SHOW CREATE TABLE entity;
给出:
CREATE TABLE `entity` (
`id` int unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `entity_base_fk` (`id`),
CONSTRAINT `entity_base_fk` FOREIGN KEY (`id`) REFERENCES `base` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
原来是因为
apcu cache
哪个
只能由网络服务器访问。
并且在
php.ini
apc
被 CLI 禁用,解释了为什么 orm:clear-cache
默认为 MemcachedAdapter
apc.enable_cli=0
启用它并没有帮助,因为它们是网络服务器和 CLI 的不同缓存,因此我需要使用例如在网络服务器中触发
apcu_clear_cache()
curl
到特定(安全)脚本