2012-04-10 3 views
0

Ich habe ein Modul in Symfony 1.4 erstellt. Es funktioniert wie erwartet. Trotzdem, wenn ich in der dev.php Modus bin, bekomme ich eine Syntax Fehler.Symfony 1.4: Fehler im dev.php-Modus. Funktioniert in nicht-dev.php-Modus

Mal sehen:

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

ich:

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 

nun an der Linie der actions.class.php ich:

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 

Und in Linie von 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; 
} 

Ich fügte hinzu kommen Echos, und in der Tat ist null. Aber ich weiß nicht warum. Ich glaube, dass dieser Code automatisch von Symfony generiert wird. Ich weiß nicht, wie ich dieses Problem lösen soll. Auch hier funktioniert das Modul gut, aber in dev.php gibt mir diesen Fehler. Ich gelöscht Cache usw.

EDIT: Dies ist der gesamte Code des /home/lola/hl/honey-lumpi/lib/model/sitebuilder/PanelParameter.php:

<?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

Dumme Frage aber, haben Sie eine symfony cc durchgeführt? Und was ist 'Sitebuilder'? Ich sehe, dass Ihre Modelldateien sich im 'sitebuilder'-Ordner statt in' doctrine' befinden (oder im Modellordner für proprive). – j0k

+0

Ja, ich habe symfony cc, mit den gleichen Ergebnissen. Sitebuilder wird verwendet, um Websites dynamisch von Null zu erstellen. Ich habe es nicht erstellt. Ich migriere nur etwas Code von ** Symfony1.0 ** nach ** Symfony1.4 **. Was ich merkwürdig finde ist, dass es ** ohne ** dev.php funktioniert. Ich benutze Antrieb – Kani

Antwort

0

ich nicht Sitebuilder wusste symfony Website zu machen, ich weiß nicht, was erzeugt wird, von diesem Werkzeug.

Aber haben Sie versucht, Ihr Modell neu zu erstellen? ./symfony propel:build --all-classes

Ist es eine generierte Klasse von Sitebuilder/prop oder stammt sie aus dem sf1.0 Import?

+0

hallo. Ich habe den Befehl und das gleiche: /. Es kommt vom Import. Jemand hat den Code geschrieben (oder das haben sie mir gesagt). Ich werde die Frage mit dem ganzen Code dieser Datei aktualisieren! – Kani

+0

Ich denke, das ist ziemlich spezifisch von 'sitebuilder' oder vom Zweck der Anwendung, aber nicht von symfony oder proprive. Und btw wirklich verstehe ich nicht, warum es in nicht-dev Modus wokring ist: o – j0k

+0

Nun, habe ich, dass '22' Linie: ' if (isset ($ res)) { $ retval = stream_get_contents ($ res); Zurückspulen ($ res); Rückgabe $ retval; } sonst { Rückgabewert null; } ' Das löste das Problem. Meine Güte! – Kani

Verwandte Themen