Ahh yes apologies, that's in tables/post.php
Just trying to get my head around the code flow. Been some years since I did any Joomla Dev work.
From what I can see, It instantiates a new instance using the table class...
// If this a new post, instantiate a new post table.
if (!$this->post) {
$this->post = EB::table('Post');
}
Where it calls table/table.php getInstance()
This passes the data to the Joomla getInstance() method in libraries/src/Table/Table.php > getInstance()
This checks if a database object has been passed and uses this to create a new instance of the table class which it returns to the post object
The next thing it does is to get the post data.... (also in post/post.php)
// Get post data
$data = $this->toPostData();
The full toPostData() method...
public function toPostData()
{
$data = new stdClass();
foreach (self::$enumerations as $prop => $enum) {
// If this is a linked property, skip.
// Linked property are not part of post table.
if ($enum['linked']) {
continue;
}
// Joomla 4 compatibility:
// To Ensure id column type is integer
if ($prop == 'isnew') {
$this->$prop = (int) $this->$prop;
}
// Joomla 4 compatibility:
// To Ensure state column should have a default value
if ($prop == 'state' && empty($this->$prop)) {
$this->$prop = EASYBLOG_POST_NORMAL;
}
if ($prop == 'locked' && empty($this->$prop)) {
$this->$prop = 0;
}
if ($prop == 'content' && empty($this->$prop)) {
$this->$prop = '';
}
if ($prop == 'intro' && empty($this->$prop)) {
$this->$prop = '';
}
$data->$prop = $this->$prop;
}
return $data;
}
Note that here it is initialising a bunch of properties under the guise of 'Joomla 4 compatibility'.
This seems like the opportune place to address this issue. IMHO.
If the status / value of the document column is the cause of the error, then we should be able to assign a default value here so that it then does not cause the failure of the later post->store method.
So I propose a small change as follows....
// J5.2.4 Update fix (J!User)
if ($prop == 'document' && empty($this->$prop)){
$this->$prop = '';
}
We can add the document column property to the list of J4 compatibility 'fixes'. Like this....
public function toPostData()
{
$data = new stdClass();
foreach (self::$enumerations as $prop => $enum) {
// If this is a linked property, skip.
// Linked property are not part of post table.
if ($enum['linked']) {
continue;
}
// Joomla 4 compatibility:
// To Ensure id column type is integer
if ($prop == 'isnew') {
$this->$prop = (int) $this->$prop;
}
// Joomla 4 compatibility:
// To Ensure state column should have a default value
if ($prop == 'state' && empty($this->$prop)) {
$this->$prop = EASYBLOG_POST_NORMAL;
}
if ($prop == 'locked' && empty($this->$prop)) {
$this->$prop = 0;
}
if ($prop == 'content' && empty($this->$prop)) {
$this->$prop = '';
}
if ($prop == 'intro' && empty($this->$prop)) {
$this->$prop = '';
}
// J5.2.4 Update fix (J!User)
if ($prop == 'document' && empty($this->$prop)){
$this->$prop = '';
}
$data->$prop = $this->$prop;
}
return $data;
}
Of course, I have no way to test this, and I am unsure if assigning an empty value will resolve the issue instead of changing it to 'NULL'. So we may need to play with it a little to get it to work.
If someone wants to test this out for me, would be keen to see if it is a viable fix