2012-04-10 5 views
0

私はSymfony 1.4にモジュールを作成しました。それは期待どおりに動作します。それにもかかわらず、dev.phpモードでは、の構文エラーが表示されます。Symfony 1.4:dev.phpモードでエラーが発生しました。非dev.phpモードで動作します

見てみましょう:

http://honeylumpi.mobi/dev.php/panelparameter 
NOTE: panelparameter is the admin-module that I created. 

を私が取得:

Parse error: syntax error, unexpected T_STRING in /home/lola/hl/honey-lumpi/cache/cms/dev/modules/autoPanelparameter/actions/actions.class.php on line 66 

さて、ラインで私が手actions.class.phpの:

Warning: stream_get_contents() expects parameter 1 to be resource, null given in /home/lola/hl/honey-lumpi/lib/model/sitebuilder/PanelParameter.php on line 22 

そしてラインでの PanelParameter.php

/** 
* Returns the serialized value. 
* 
* @return string 
*/ 
public function getSerializedValue() 
{ 
    $res = parent::getValue(); 
    $retval = stream_get_contents($res); <-- This is line 22! 
    rewind($res); 
    return $retval; 
} 

私は実際には、ヌルで、来るエコーを追加し、。しかし、私は理由を知らない。私はそのコードがSymfonyによって自動生成されると信じています。私はその問題を解決する方法を知らない。再び、モジュールはうまく動作しますが、dev.phpでエラーが発生します。私はキャッシュをクリアするなど

EDIT:私は、私が生成されるかわからないsymfonyのウェブサイトを作るためのSitebuilderを知らなかった

<?php 

/** 
* Subclass for representing a row from the 'PanelParameter' table. 
* 
* 
* 
* @package lib.model 
*/ 
class PanelParameter extends BasePanelParameter 
{ 
    private $condition; 

/** 
* Returns the serialized value. 
* 
* @return string 
*/ 
public function getSerializedValue() 
{ 
    $res = parent::getValue(); 
    $retval = stream_get_contents($res); 
    rewind($res); 
    return $retval; 
} 

/** 
* Sets the value already serialized. 
* 
* @param string $v 
*/ 
public function setSerializedValue ($v) 
{ 
    parent::setValue($v); 
} 

/** 
* Returns the value of the parameter. 
* 
* @return mixed 
*/ 
public function getValue() 
{ 
    // get serialized value 
    $v = $this->getSerializedValue(); 

    // unserialize 
    $value = @unserialize($v); 

    // check for error 
    if (false === $value) 
    { 
     if ('b:0;' != $v) 
     { 
      if (PHP_VERSION_ID < 50300) 
      { 
       gxLog::a(__CLASS__, "cannot unserialize parameter #{$this->id} {$this->name} value:{$v}"); 
       $value = null; 
      } 
      else 
      { 
       // try to fix array indexes 
       $cb = create_function('$m', 'return "s:".strlen($m[1]).":\"$m[1]\"";'); 
       $v = preg_replace_callback('/i:([0-9]{12,})/', $cb, $v); 
       $value = @unserialize($v); 
       if (false === $value) 
       { 
        gxLog::a(__CLASS__, "cannot unserialize parameter #{$this->id} {$this->name} value:{$v}"); 
        $value = null; 
       } 
      } 
     } 
    } 

    // return unserialized value 
    return $value; 
} 

/** 
* Sets the value for the parameter. 
* 
* @param mixed $v 
*/ 
public function setValue ($v) 
{ 
    $value = @serialize($v); 
    parent::setValue($value); 
} 

/** 
* Returns the name of the parameter. 
* 
* @return string 
*/ 
public function __toString() 
{ 
    return $this->getName(); 
} 

/** 
* Returns the condition object. 
* 
* @return gxSiteCondition 
*/ 
public function getCondition() 
{ 
    if (!isset($this->condition)) 
    { 
     // no condition is true always 
     $condition = new gxSiteCondition; 

     $cond = parent::getCond(); 
     if (!is_null($cond)) 
     { 
      // unserialize 
      $condition = gxSiteCondition::createFromJson($cond); 
     } 

     // store 
     $this->condition = $condition; 
    } 

    return $this->condition; 
} 

/** 
* Sets the condition. 
* 
* @param gxSiteCondition $c 
*/ 
public function setCondition ($c) 
{ 
    if (!($c instanceof gxSiteCondition)) throw new Exception ('parameter is not gxSiteCondition'); 

    // serialize 
    $cond = $c->toJson(); 

    // store 
    $this->condition = $c; 

    // store condition 
    parent::setCond($cond); 
} 

/** 
* Checks the condition in the provided context. 
* 
* @param sfContext $context 
*/ 
public function checkCondition (sfContext $context) 
{ 
    // get condition 
    $condition = $this->getCondition(); 

    // evaluate condition 
    return $condition ? $condition->evaluate($context) : true; 
} 

/** 
* Returns true if the provided condition is contained 
* in this object's condition. 
* 
* @param gxBasicCondition $c 
* @return boolean 
*/ 
public function containsCondition (gxSiteCondition $c) 
{ 
    // get condition 
    $condition = $this->getCondition(); 

    // check if contained condition 
    return $condition ? $condition->contains($c) : true; 
} 

/** 
* Set default value for condition if new and not set. 
* 
* @param PropelPDO $con 
* @return int 
*/ 
public function save (PropelPDO $con = null) 
{ 
    if ($this->isNew() && !$this->isColumnModified(PanelParameterPeer::COND)) 
    { 
     $this->setCondition(new gxSiteCondition); 
    } 

    return parent::save($con); 
} 

/** 
* Sets contents of passed object to values from current object. 
* 
* If desired, this method can also make copies of all associated (fkey referrers) 
* objects. 
* 
* @param  object $copyObj An object of PanelParameter (or compatible) type. 
* @param  boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. 
* @throws  PropelException 
*/ 
public function copyInto($copyObj, $deepCopy = false) 
{ 

    $copyObj->setName($this->name); 

    $copyObj->setSerializedValue($this->getSerializedValue()); 

    $copyObj->setCond($this->cond); 

    $copyObj->setPanelId($this->panel_id); 

    $copyObj->setNew(true); 

    $copyObj->setId(NULL); // this is a pkey column, so set to default value 

} 
} 
+0

愚かな質問ですが、symfony ccを実行しましたか?そして 'sitebuilder'とは何ですか?あなたのモデルファイルは、 'doctrine'ではなく' sitebuilder'フォルダ内にあります(またはpropelのモデルフォルダ内にあります)。 – j0k

+0

はい、私はsymfony ccと同じ結果を出しました。 Sitebuilderは、ゼロから動的にサイトを作成するために使用されます。私はそれを作成していない。私は** Symfony1.0 **から** Symfony1.4 **にいくつかのコードを移行しています。好奇心をそそるのは** dev.phpなしで**動作することです。私はpropelを使用しています – Kani

答えて

0

: これは/home/lola/hl/honey-lumpi/lib/model/sitebuilder/PanelParameter.phpのすべてのコードですこのツールから

しかし、モデルを再構築しようとしましたか? ./symfony propel:build --all-classes

sitebuilder/propelから生成されたクラスですか、それともsf1.0のインポートから生成されたクラスですか?

+0

こんにちは。私はその命令と同じことをした:/。それは輸入から来ます。誰かがコードを書いた(または、彼らが私に言ったことです)。私はそのファイルのすべてのコードで質問を更新します! – Kani

+0

これは 'sitebuilder'やアプリケーションの目的からは特定できますが、symfonyやpropelからのものではないと思います。そして、私は本当になぜそれが非devモードでwokringしているのかわかりません: – j0k

+0

まあ、私は 'line 22'でそれをしました: ' if(isset($ res)) { $ retval = stream_get_contents($ res);リワインド($ res); ; return $ retval; } else { return null; } ' それが問題を解決しました。よ! – Kani

関連する問題