Create a model for your component (extends JModelList)
In the function getListQuery, return a query that is a union, eg:
$query1 = $db->getQuery(true)->select(...);
$query2 = $db->getQuery(true)->select(...);
return $query1->union($query2);
In the view.html.php, retrieve the pagination object:
$pagination = $this->get('Pagination');
Error is displayed
Is this issue reproducable also with a core extension?
Tested with com_content, same problem occurs.
Go to file /administrator/components/com_content/Model/ArticlesModel.php
line 188 (in the function getListQuery
) and insert:
$query = $db->getQuery(true)->select('id')->from($db->quoteName('#__content'));
$query2 = $db->getQuery(true)->select('id')->from($db->quoteName('#__content'));
return $query->union($query2);
You can use any 2 random queries, as long as you use a union, the error will be thrown.
Try this fix.
Go to libraries/vendor/joomla/database
and patch below files. You can use patch -p1 < diff.patch
diff --git a/src/DatabaseQuery.php b/src/DatabaseQuery.php
index 2c02fcc..de694a6 100644
--- a/src/DatabaseQuery.php
+++ b/src/DatabaseQuery.php
@@ -1737,9 +1737,19 @@ abstract class DatabaseQuery implements QueryInterface
continue;
}
- if (\is_object($v) || \is_array($v))
+ if (\is_object($v))
{
- $this->{$k} = unserialize(serialize($v));
+ $this->{$k} = clone $v;
+ }
+ elseif (\is_array($v))
+ {
+ foreach ($v as $i => $element)
+ {
+ if (\is_object($element))
+ {
+ $this->{$k}[$i] = clone $element;
+ }
+ }
}
}
}
diff --git a/src/Query/QueryElement.php b/src/Query/QueryElement.php
index 271fb94..4ddd061 100644
--- a/src/Query/QueryElement.php
+++ b/src/Query/QueryElement.php
@@ -137,9 +137,19 @@ class QueryElement
{
foreach ($this as $k => $v)
{
- if (\is_object($v) || \is_array($v))
+ if (\is_object($v))
{
- $this->{$k} = unserialize(serialize($v));
+ $this->{$k} = clone $v;
+ }
+ elseif (\is_array($v))
+ {
+ foreach ($v as $i => $element)
+ {
+ if (\is_object($element))
+ {
+ $this->{$k}[$i] = clone $element;
+ }
+ }
}
}
}
It replaces serialize/unserialize
by simple cloning.
It works, thank you!
Labels |
Added:
J4 Issue
|
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-14 02:28:44 |
Closed_By | ⇒ | Quy |
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2018-12-14 02:28:44 |
Closed_By | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @Quy by The JTracker Application at issues.joomla.org/joomla-cms/22685
#22777