midgardproject / midgard-php5

PHP5 API for Midgard persistent storage framework
http://www.midgard-project.org/api-docs/midgard/php/ratatoskr/
GNU Lesser General Public License v2.1
9 stars 2 forks source link

Segfault with midgard_datetime properties #30

Closed bergie closed 13 years ago

bergie commented 13 years ago

Using a database with some https://github.com/nemein/fi_openkeidas_diary/blob/master/models/challenge.xml entries populated:

<?php
// Open a connection
$filepath = ini_get("midgard.configuration_file");
$config = new midgard_config();
$config->read_file_at_path($filepath);

function connect($config) {
    $mgd = midgard_connection::get_instance();
    return $mgd->open_config($config);
}

if (!connect($config))
{
    die("Failed to connect\n");
}

$qb = new midgard_query_builder('fi_openkeidas_diary_challenge');
var_dump($qb->execute());

Results in:

array(1) {
  [0]=>
  object(fi_openkeidas_diary_challenge)#4 (12) {
    ["connection"]=>
    NULL
    ["guid"]=>
    string(36) "f7a8afc82a3f11e0adb23da3db894d424d42"
    ["metadata"]=>
    object(midgard_metadata)#5 (24) {
      ["connection"]=>
      NULL
      ["creator"]=>
      string(0) ""
      ["created"]=>
      object(midgard_datetime)#8 (5) {
        ["object":"midgard_datetime":private]=>
        *RECURSION*
        ["property":"midgard_datetime":private]=>
        string(7) "revised"
      }
      ["revisor"]=>
      string(0) ""
      ["revised"]=>
      *RECURSION*
      ["revision"]=>
      int(0)
      ["locker"]=>
      string(0) ""
      ["locked"]=>
      object(midgard_datetime)#9 (5) {
        ["object":"midgard_datetime":private]=>
        *RECURSION*
        ["property":"midgard_datetime":private]=>
        string(8) "approved"
      }
      ["approver"]=>
      string(0) ""
      ["approved"]=>
      *RECURSION*
      ["authors"]=>
      string(0) ""
      ["owner"]=>
      string(0) ""
      ["schedulestart"]=>
      object(midgard_datetime)#10 (5) {
        ["object":"midgard_datetime":private]=>
        *RECURSION*
        ["property":"midgard_datetime":private]=>
        string(11) "scheduleend"
      }
      ["scheduleend"]=>
      *RECURSION*
      ["hidden"]=>
      bool(false)
      ["navnoentry"]=>
      bool(false)
      ["size"]=>
      int(199)
      ["published"]=>
      object(midgard_datetime)#11 (5) {
        ["object":"midgard_datetime":private]=>
        *RECURSION*
        ["property":"midgard_datetime":private]=>
        string(8) "imported"
      }
      ["score"]=>
      int(0)
      ["imported"]=>
      *RECURSION*
      ["exported"]=>
      object(midgard_datetime)#12 (5) {
        ["object":"midgard_datetime":private]=>
        *RECURSION*
        ["property":"midgard_datetime":private]=>
        string(0) ""
        ["date"]=>
        Segmentation fault
indeyets commented 13 years ago

Segmentation fault happens because of recursive output of classes. object has reference to datetime, which has it's private member "object" pointing back to class, etc.

Fixing this would mean "hiding" object-pointer in midgard_datetime class

indeyets commented 13 years ago

do not reinit datetime objects in get_properties(). this helps to keep var_dump() happy. Closed by ac15ac160f46ac05f52c46a6cb1850392d64ca3d