1 2015-08-05 09:34:34

Topic: Successful Message flashes upon Unsuccessful Data Update

If the data file is put in the read-only file server ( ex. a public web storage which is mounted to a shared read-only file server ), Monstra flashes a successful-update message even though it is not really updating it, isn't it?

_save function defined in Class Table always returns 'true' if a reading operation (loadXML) is successful. It does not return the value of $dom->save().

    protected static function _save($table)
    {
        $dom = new DOMDocument('1.0', 'utf-8');
        $dom->preserveWhiteSpace = false;
        // Save new xml data to xml file only if loadXML successful.
        // Preventing the destruction of the database by unsafe data.
        // note: If loadXML !successful then _save() add&save empty record.
        //       This record cant be removed by delete[Where]() Problem solved by hand removing...
        //       Possible solution: modify delete[Where]() or prevent add&saving of such records.
        // the result now: database cant be destroyed :)
        if ($dom->loadXML($table['xml_object']->asXML())) {
            $dom->save($table['xml_filename']);
            return true;
        } else {
            return false;
            // report about errors...
        }
    }

Re: Successful Message flashes upon Unsuccessful Data Update

The fix should be like a following:

    protected static function _save($table)
    {
        $dom = new DOMDocument('1.0', 'utf-8');
        $dom->preserveWhiteSpace = false;
        // Save new xml data to xml file only if loadXML successful.
        // Preventing the destruction of the database by unsafe data.
        // note: If loadXML !successful then _save() add&save empty record.
        //       This record cant be removed by delete[Where]() Problem solved by hand removing...
        //       Possible solution: modify delete[Where]() or prevent add&saving of such records.
        // the result now: database cant be destroyed :)
        if ($dom->loadXML($table['xml_object']->asXML())) {
            if ($dom->save($table['xml_filename'])) {
                return true;
            }
            return false;
        } else {
            return false;
            // report about errors...
        }
    }
            if ($dom->save($table['xml_filename'])) {
              return true;
            }
            return false;