User tests: Successful: Unsuccessful:
As title.
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Using count()
would need a GROUP statetement as well. But it looks useless anyway to run count when we don't need to count the rows.
That is something which Falang should fix as the core code is perfectly fine.
Using 1 AS x
is another way to fix this issue, instead of COUNT(*)
.
I still think it's a bug in Falang which they need to fix.
I agree. Just saying, we won't be able to upgrade until either Falang or Joomla has changed. Or we make our own fork.
@olleharstedt can you please close this Issue if its not a Core Issue?
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-07-06 13:44:44 |
Closed_By | ⇒ | olleharstedt | |
Labels |
Added:
?
|
The following piece of code works differently in PHP 7 and PHP 5:
$mysqli = mysqli_connect("localhost", "root", "", "mydatabase");
$res = mysqli_query($mysqli, "select 1");
$row = mysqli_fetch_object($res);
var_dump($row);
In PHP 7 it will dump
object(stdClass)#3 (1) {
[1]=>
string(1) "1"
}
but in PHP 5
object(stdClass)#3 (0) {
}
Therefore I think the PR is motivated. Maybe it can be changed to select('id')
instead of select('COUNT(*)')
(only cosmetic change).
Status | Closed | ⇒ | New |
Closed_Date | 2017-07-06 13:44:44 | ⇒ | |
Closed_By | olleharstedt | ⇒ |
Status | New | ⇒ | Pending |
To complete this case.
Joomla don't see the problem because the loadResult work fine with select('1) but the loadObject don't work fine.
Falang use loadObject during the database override.
There are 2 file to change and replace for the check method
select('1')
by
libraries/joomla/table/asset.php line 109
->select($this->_db->quoteName('id'))
libraries/joomla/table/nested.php line 694
select($this->_db->quoteName($this->_tbl_key))
libraries/joomla/table/nested.php line 997
select($key)
did'nt experienced php 5 vs php 7 different behaviour
can you test with mysqli_fetch_row
instead of mysqli_fetch_object
in your posted #17003 (comment) test code ?
..despite i think should be fixed on falang side...
we simply should avoid SELECT COUNT(*)
when not needed
With mysqli_fetch_row it's work but in Joomla if you change in the assets.php check method
if ($this->_db->setQuery($query, 0, 1)->loadResult())
by
if ($this->_db->setQuery($query, 0, 1)->loadObject())
this will not work on php 5.5 , 5.6
Falang use loadobject for all it's why there are a problem since the last Joomla version.
the change of the query
libraries/joomla/table/asset.php line 109
->select($this->_db->quoteName('id'))
fix the problem on falang , it's not a Joomla bug because Joomla use loadResult.
Stéphane
NB: SELECT COUNT(*)
has no performance hit in this case, since it's always returning 0 or 1 row. SELECT id
would work just as well, too.
even if there are no performance issues, using count(*)
is wrong imho we are asking for existence and not asking how many items there are
Select (id) will work and it's a workaround for MySQL bug. no performance problem.
there is no MySQL bug nor Joomla bug
look at the @olleharstedt message and try this
with php 5.6 and php 7.0
$mysqli = mysqli_connect("localhost", "root", "", "mydatabase");
$res = mysqli_query($mysqli, "select 1");
$row = mysqli_fetch_object($res);
var_dump($row);
The result is not the same with an empty object for php 5
maybe this can help https://bugs.php.net/bug.php?id=72151
Title |
|
Title |
|
Title |
|
Title |
|
The change proposed by olleharstedt don't affect performance and fix the prolem on Falang with php 5.
No problem with php 7
I am closing this as not a Joomla core issue.
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-09-09 14:58:39 |
Closed_By | ⇒ | brianteeman |
I've notified Falang about this issue.