Phalanger Model data bug (very weird and serious)
2 posts
• Page 1 of 1
Phalanger Model data bug (very weird and serious)
In my php file i have:
$vdr = new PhpViewEngineNew\Models\ViewDataRecords;
$vdr = $model;
$ai = new PhpViewEngineNew\Models\AuthInfo;
$ai = $vdr["AuthInfo"];
$AdData = new PhpViewEngineNew\Models\AdData;
$AdData = $vdr["AdData"];
$Iad = new PhpViewEngineNew\Models\Ad;
$Iad=$AdData->ad;
i basically have the model as a dictionary of classes derived from
a base class
public class ViewDataObjects
{
}
public class AuthInfo : ViewDataObjects
{
public String username = "";
}
public class DebugInfo : ViewDataObjects
{
public bool debug;
}
public class AdCampData : ViewDataObjects
{
public List<AdCamp> adList = new List<AdCamp>();
// public bool edit;
}
public class AdCamp
{
public long AdId;
public bool allowDelete;
public String endDate;
public String name;
public String startDate;
public String viewCreateCamp;
public String notes;
public long campId;
}
public class AdData : ViewDataObjects
{
public Ad ad = new Ad();
public bool edit;
}
public class Ad
{
public long adId;
public String adName;
public String adNotes;
public String adBackgroundColor;
public String adBackPlane1;
public String adFont;
public String adLinkColor;
public String adTagLine;
public String adTextColor;
}
and in the controller
// i assign this way.
var vdrs = new ViewDataRecords();
HttpContext.Items["ViewDataList"] = vdrs;
var ad = new AdData { edit = editAd };
vdrs["AdData"] = ad;
Now what is happening in the PHP is
in a reference to
$Iad->[field]
you can reference a field from another class/object!!
and if you have the same field names in to classes,
and you reference, you get a "can't assign one type to another" error.
So Phalanger appears to be assigning in php fields/props as field/prop
as a union of all objects, not caring what object it is actually from.
In order to work around this, i have to make sure all field names in all classes used in the model data sent to phalanger have unique names.
This is a very odd bug!!
Perhaps the variable store (of all objects) introduced to the php
compiled object, a hash is used to reference fields, but the fields are just a big union of all fields without keeping reference to the objects they are actually from?
And again, the work around is, if you pass multiple objects into phalanger
(php compilation), all fields across all class/objects , the names have to be unique.
-tl
$vdr = new PhpViewEngineNew\Models\ViewDataRecords;
$vdr = $model;
$ai = new PhpViewEngineNew\Models\AuthInfo;
$ai = $vdr["AuthInfo"];
$AdData = new PhpViewEngineNew\Models\AdData;
$AdData = $vdr["AdData"];
$Iad = new PhpViewEngineNew\Models\Ad;
$Iad=$AdData->ad;
i basically have the model as a dictionary of classes derived from
a base class
public class ViewDataObjects
{
}
public class AuthInfo : ViewDataObjects
{
public String username = "";
}
public class DebugInfo : ViewDataObjects
{
public bool debug;
}
public class AdCampData : ViewDataObjects
{
public List<AdCamp> adList = new List<AdCamp>();
// public bool edit;
}
public class AdCamp
{
public long AdId;
public bool allowDelete;
public String endDate;
public String name;
public String startDate;
public String viewCreateCamp;
public String notes;
public long campId;
}
public class AdData : ViewDataObjects
{
public Ad ad = new Ad();
public bool edit;
}
public class Ad
{
public long adId;
public String adName;
public String adNotes;
public String adBackgroundColor;
public String adBackPlane1;
public String adFont;
public String adLinkColor;
public String adTagLine;
public String adTextColor;
}
and in the controller
// i assign this way.
var vdrs = new ViewDataRecords();
HttpContext.Items["ViewDataList"] = vdrs;
var ad = new AdData { edit = editAd };
vdrs["AdData"] = ad;
Now what is happening in the PHP is
in a reference to
$Iad->[field]
you can reference a field from another class/object!!
and if you have the same field names in to classes,
and you reference, you get a "can't assign one type to another" error.
So Phalanger appears to be assigning in php fields/props as field/prop
as a union of all objects, not caring what object it is actually from.
In order to work around this, i have to make sure all field names in all classes used in the model data sent to phalanger have unique names.
This is a very odd bug!!
Perhaps the variable store (of all objects) introduced to the php
compiled object, a hash is used to reference fields, but the fields are just a big union of all fields without keeping reference to the objects they are actually from?
And again, the work around is, if you pass multiple objects into phalanger
(php compilation), all fields across all class/objects , the names have to be unique.
-tl
- tleslie
- Posts: 32
- Joined: August 3rd, 2012, 4:42 am
Re: Phalanger Model data bug (very weird and serious)
This is very unusual, maybe it refers to a bug that was fixed few days ago (https://github.com/DEVSENSE/Phalanger/c ... 3668aaf6b8)
We have prepared release package (https://github.com/DEVSENSE/Phalanger/downloads), so I would recommend to try it if you didn't compile PhpNetCore from sources already. There was really a bug treating all CLR objects as one.
We have prepared release package (https://github.com/DEVSENSE/Phalanger/downloads), so I would recommend to try it if you didn't compile PhpNetCore from sources already. There was really a bug treating all CLR objects as one.
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 26 guests