doctrine / KeyValueStore

Abstraction for Key-Value to Plain Old PHP Object mapping
http://www.doctrine-project.org
MIT License
200 stars 59 forks source link

Unexpected NotFoundException when stored value is seen as FALSE by PHP #90

Closed nuxwin closed 6 years ago

nuxwin commented 6 years ago

@Ocramius

In the DBAL storage (find method), a check is made on SQL query result as follow:

        if (!$data) {
            throw new NotFoundException();
        }

That check is totally wrong... Why? If we have a stored value that PHP considere FALSE, a NotFoundException will be raised each time... Best would be to check for true FALSE value (strict check):

        if ($data === FALSE) {
            throw new NotFoundException();
        }

For our use case, we have the following storage:

MariaDB [imscp_new]> show columns from imscp_config;
+-------------+--------------+------+-----+---------+-------+
| Field       | Type         | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+-------+
| configName  | varchar(255) | NO   | PRI | NULL    |       |
| configValue | longtext     | NO   |     | NULL    |       |
+-------------+--------------+------+-----+---------+-------+
2 rows in set (0.00 sec)

MariaDB [imscp_new]> select * from imscp_config\G
*************************** 1. row ***************************
 configName: DATABASE_REVISION
configValue: 0
*************************** 2. row ***************************
 configName: PORT_DNS
configValue: 53;tcp;DNS;1;0.0.0.0
*************************** 3. row ***************************
 configName: PORT_FTP
configValue: 21;tcp;FTP;1;0.0.0.0
*************************** 4. row ***************************
 configName: PORT_HTTP
configValue: 80;tcp;HTTP;1;0.0.0.0
*************************** 5. row ***************************
 configName: PORT_HTTPS
configValue: 443;tcp;HTTPS;0;0.0.0.0
*************************** 6. row ***************************
 configName: PORT_IMAP
configValue: 143;tcp;IMAP;1;0.0.0.0
*************************** 7. row ***************************
 configName: PORT_IMAP-SSL
configValue: 993;tcp;IMAP-SSL;0;0.0.0.0
*************************** 8. row ***************************
 configName: PORT_IMSCP_DAEMON
configValue: 9876;tcp;i-MSCP-Daemon;1;127.0.0.1
*************************** 9. row ***************************
 configName: PORT_POP3
configValue: 110;tcp;POP3;1;0.0.0.0
*************************** 10. row ***************************
 configName: PORT_POP3-SSL
configValue: 995;tcp;POP3-SSL;0;0.0.0.0
*************************** 11. row ***************************
 configName: PORT_SMTP
configValue: 25;tcp;SMTP;1;0.0.0.0
*************************** 12. row ***************************
 configName: PORT_SMTP-SSL
configValue: 465;tcp;SMTP-SSL;0;0.0.0.0
*************************** 13. row ***************************
 configName: PORT_SSH
configValue: 22;tcp;SSH;1;0.0.0.0
*************************** 14. row ***************************
 configName: PORT_TELNET
configValue: 23;tcp;TELNET;1;0.0.0.0
nuxwin commented 6 years ago

Issue is irrelevant.. Full object is stored, not only value...