教义抛出致命错误



一个在本地服务器(XAMPP)上运行良好的网站,但在移动到实时托管后,Doctrine抛出了一个错误(仅在网站上的一个地方),作为POST请求对服务器的响应:

PHP Warning:  require(/tmp/__CG__EntitiesEcomProducts.php): failed to open stream: No such file or directory in [SERVER PATH]/php/Vendors/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 223
[24-Jan-2018 23:51:50 UTC] PHP Fatal error:  require(): Failed opening required '/tmp/__CG__EntitiesEcomProducts.php' (include_path='.:/opt/alt/php71/usr/share/pear') in [SERVER PATH]/php/Vendors/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php on line 223

已与托管管理员一起检查所有权限。

我没有使用Symfony。

主机上的PHP版本在本地主机和实时主机上都是7.1。

UPD2.抛出错误的不是特定的实体 - 而是其中的所有@ManyToOne关系。

上。我将代码简化为初始化 Doctrine 并运行与错误跟踪的相同代码:

$ItemOption= $this->EntityManager->getRepository($this->Settings->Ecom->get('repos')[3])->findOneById(1);

然后此实体引发错误:

class EcomProductsPrices{
/** @Id @Column(type="integer")  @GeneratedValue  **/
protected $id;
/**  @Column(type="string")  **/
protected $title;
/**  @Column(type="float",nullable=TRUE)  **/
protected $price;
/**  @Column(type="float",nullable=TRUE)  **/
protected $discount;
/**  @Column(type="integer",nullable=TRUE)  **/
protected $discountAfter;

/**  
*  @ManyToOne(targetEntity="EcomProducts", inversedBy="EcomProductsPrices",cascade={ "persist"} )
*   
**/
protected $EcomProducts;
/**  
*  @OneToMany(targetEntity="EcomCart", mappedBy="EcomProductsPrices",cascade={ "persist"} ) 
**/
protected $EcomCart;
public function __construct() {
$this->EcomCart = new DoctrineCommonCollectionsArrayCollection();
}
public function getId(){
return $this->id;
}
public function getTitle(){
return $this->title;
}
public function setTitle($title){
$this->title = $title;
}
public function getPrice(){
return $this->price;
}
public function setPrice($price=NULL){
$this->price = $price;
}
public function getDiscount(){
return $this->discount;
}
public function setDiscount($discount=NULL){
$this->discount = $discount;
}
public function getDiscountAfter(){
return $this->discountAfter;
}
public function setDiscountAfter($discountAfter=NULL){
$this->discountAfter = $discountAfter;
}
public function getEcomProducts(){
return $this->EcomProducts;
}
public function setEcomProducts(EcomProducts $EcomProducts){       
$this->EcomProducts = $EcomProducts;
}


public function RemoveEcomProducts(EcomProducts $EcomProducts){
$this->EcomProducts=NULL;            
}
public function clearEcomProducts(){
$this->EcomProducts->clear();
}
public function getEcomCart(){
return $this->EcomCart;
}
public function setEcomCart(EcomCart $EcomCart){       
if(is_array($EcomCart)){
foreach($EcomCart as $Join){
if(is_int($Join)){
$Join=$this->Kernel->EntityManager->getRepository($this->Kernel->Settings->ICatcher->get('php.entities-namespaces')[0].'EcomCart')->findOneById($Join);
}
if(!$this->EcomCart->contains($EcomCart)){
$this->EcomCart[] = $EcomCart;
$EcomCart->setEcomProductsPrices($this);
}
}
}
else{
if(!$this->EcomCart->contains($EcomCart)){
$this->EcomCart[] = $EcomCart;
$EcomCart->setEcomProductsPrices($this);
}
}
}

public function RemoveEcomCart(EcomCart $EcomCart){
if($this->EcomCart->contains($EcomCart)){
$this->EcomCart->removeElement($EcomCart);
$EcomCart->RemoveEcomProductsPrices($this);
}
}
public function clearEcomCart(){
$this->EcomCart->clear();
}


/** @PrePersist */
public function preCreate(){
}
/** @preUpdate */
public function preUpdate(){
}
/** @preRemove */
public function preRemove(){
}
}

该错误与加入EcomProducts有关 - 这是教义AbstractProxyFactor中显示的违规实体

但是当我更改以在此实体中查找一个时 - 没有错误:

class EcomOrder{
/** @Id @Column(type="integer")  @GeneratedValue  **/
protected $id;
/**  @Column(type="string",nullable=TRUE)  **/
protected $fullName;
/**  @Column(type="string",nullable=TRUE)  **/
protected $address1;
/**  @Column(type="string",nullable=TRUE)  **/
protected $address2;
/**  @Column(type="string",nullable=TRUE)  **/
protected $promocode;
/**  @Column(type="string",nullable=TRUE)  **/
protected $postcode;
/**  @Column(type="float",nullable=TRUE)  **/
protected $deliveryPrice;
/**  @Column(type="boolean",nullable=TRUE)  **/
protected $paid;
/**  @Column(type="boolean",nullable=TRUE)  **/
protected $paypalReturned;
/**  @Column(type="boolean",nullable=TRUE)  **/
protected $delivered;
/**  @Column(type="datetime",nullable=TRUE)  **/
protected $dateCreated;
/**  @Column(type="datetime",nullable=TRUE)  **/
protected $dateUpdated;

/**  
*  @OneToMany(targetEntity="EcomCart", mappedBy="EcomOrder",cascade={ "persist"} ) 
**/
protected $EcomCart;
public function __construct() {
$this->EcomCart = new DoctrineCommonCollectionsArrayCollection();
}
public function getId(){
return $this->id;
}
public function getFullName(){
return $this->fullName;
}
public function setFullName($fullName=NULL){
$this->fullName = $fullName;
}
public function getAddress1(){
return $this->address1;
}
public function setAddress1($address1=NULL){
$this->address1 = $address1;
}
public function getAddress2(){
return $this->address2;
}
public function setAddress2($address2=NULL){
$this->address2 = $address2;
}
public function getPromocode(){
return $this->promocode;
}
public function setPromocode($promocode=NULL){
$this->promocode = $promocode;
}
public function getPostcode(){
return $this->postcode;
}
public function setPostcode($postcode=NULL){
$this->postcode = $postcode;
}
public function getDeliveryPrice(){
return $this->deliveryPrice;
}
public function setDeliveryPrice($deliveryPrice=NULL){
$this->deliveryPrice = $deliveryPrice;
}
public function getPaid(){
return $this->paid;
}
public function setPaid($paid=NULL){
$this->paid = $paid;
}
public function getPaypalReturned(){
return $this->paypalReturned;
}
public function setPaypalReturned($paypalReturned=NULL){
$this->paypalReturned = $paypalReturned;
}
public function getDelivered(){
return $this->delivered;
}
public function setDelivered($delivered=NULL){
$this->delivered = $delivered;
}
public function getDateCreated(){
return $this->dateCreated;
}
public function setDateCreated($dateCreated=NULL){
if($dateCreated==NULL){
$this->dateCreated = new DateTime("now", new DateTimeZone('Europe/London'));
}
else{
$this->dateCreated=$dateCreated;
}
}
public function getDateUpdated(){
return $this->dateUpdated;
}
public function setDateUpdated($dateUpdated=NULL){
if($dateUpdated==NULL){
$this->dateUpdated = new DateTime("now", new DateTimeZone('Europe/London'));
}
else{
$this->dateUpdated=$dateUpdated;
}
}
public function getEcomCart(){
return $this->EcomCart;
}
public function setEcomCart(EcomCart $EcomCart){       
if(is_array($EcomCart)){
foreach($EcomCart as $Join){
if(is_int($Join)){
$Join=$this->Kernel->EntityManager->getRepository($this->Kernel->Settings->ICatcher->get('php.entities-namespaces')[0].'EcomCart')->findOneById($Join);
}
if(!$this->EcomCart->contains($EcomCart)){
$this->EcomCart[] = $EcomCart;
$EcomCart->setEcomOrder($this);
}
}
}
else{
if(!$this->EcomCart->contains($EcomCart)){
$this->EcomCart[] = $EcomCart;
$EcomCart->setEcomOrder($this);
}
}
}

public function RemoveEcomCart(EcomCart $EcomCart){
if($this->EcomCart->contains($EcomCart)){
$this->EcomCart->removeElement($EcomCart);
$EcomCart->RemoveEcomOrder($this);
}
}
public function clearEcomCart(){
$this->EcomCart->clear();
}


/** @PrePersist */
public function preCreate(){
$this->setDateCreated();
}
/** @preUpdate */
public function preUpdate(){
$this->setDateUpdated();
}
/** @preRemove */
public function preRemove(){
}
}

两个实体的相同代码在本地主机(XAMPP,PHP7.1,Windows)上没有任何错误。问题出在实时主机(PHP7.1,Linux)上。

通过将以下行添加到 Doctrine 的配置中解决了这个问题:

$config->setAutoGenerateProxyClasses(TRUE);

但是为什么它在本地主机上没有它就可以工作仍然是一个谜。

相关内容

  • 没有找到相关文章

最新更新