0
votes

I created a module in Symfony 1.4. It works as expected. Nevertheless, when I'm in the dev.php mode, I get a syntax error.

Let's see:

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

I get:

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

Now, at line 66 of the actions.class.php I get:

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

And in line 22 of 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;
} 

I added come echoes, and, in fact, is null. But I don't know why. I believe that that code is auto-generated by Symfony. I don't know how to solve that problem. Again, the module works fine, but in dev.php gives me that error. I cleared cache, etc.

EDIT: This is all the code of the /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

}
}
1
Stupid question but, did you perform a symfony cc ? And what is sitebuilder ? I see your model files are inside sitebuilder folder instead of doctrine (or in the model folder for propel).j0k
Yes, i did symfony cc, with the same results. Sitebuilder is used to create sites dynamically, from zero. I didn't created it. I'm just migrating some code from Symfony1.0 to Symfony1.4 . What I find curious is that it works without the dev.php. I'm using propelKani

1 Answers

0
votes

I didn't know sitebuilder to make symfony website, I don't know what is generated from this tool.

But did you try to rebuild your model ? ./symfony propel:build --all-classes

Is it a generated class from sitebuilder/propel or does it come from the sf1.0 import?