-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compatibility layer for PHP installations without PDO support #808
Conversation
Hello, thank you for creating this pull request. I have automatically opened an issue http://www.doctrine-project.org/jira/browse/DBAL-1157 We use Jira to track the state of pull requests and the versions they got |
@@ -20,7 +20,7 @@ | |||
namespace Doctrine\DBAL\Cache; | |||
|
|||
use Doctrine\DBAL\Driver\ResultStatement; | |||
use PDO; | |||
use Doctrine\DBAL\PDOCompat; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not simply providing a PDO
class via something like following? Much simpler, much better compatibility:
{
"autoload": {
"classmap": [
"path/to/PDO.php"
]
}
}
I updated this pull request to match your suggestion |
* @link http://php.net/manual/en/pdo.constants.php | ||
* @package Doctrine\DBAL | ||
*/ | ||
class PDO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
defining this class with only the constants is a very bad idea IMO. It means that any project detecting the availability of PDO through a class_exists check will now think that PDO is available while it is not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof I think that's not a big problem for us.
While I agree with you on the risks, it is still for the little percentage of projects that want to use Doctrine DBAL without PDO, so the crowd being affected is actually pretty small.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it means that DBAL is now saying F*** you
to any library trying to detect whether PDO is available to choose their implementation, thus forbidding users to use such library and DBAL together in a project. This seems a bad idea IMO, because the responsible for this incompatibility will be us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stof the risk seems to be acceptable, tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@deeky666 looking again at this, I think it isn't worth supporting this approach anymore: we should just make ext-pdo
a hard dependency and call it "done".
While removing the dependency is a nice-to-have, PDO
is probably the ugliest API we can polyfill, riddled with poor design decisions, strange method signatures and behaviors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating this thing to only throw an exception is pretty much the same as the hard dependency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating such class could break any other library checking the existing of the PDO
class and then trying to use something else than a constant from it when it exists. So I'm -1 on adding it.
Why? Doctrine doesn't use anything from PDO besides constants and even this dependency can be eliminated by getting rid of usage of
Why is it needed to polyfill anything else then constants from PDO? This shim works perfectly, but just getting rid of their usage will be the right fix IMO. |
Given the discussion above, can we add ext-pdo to composer.json in this
patch instead?
…On 2 May 2017 17:12, "Christophe Coevoet" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In lib/Doctrine/DBAL/Compat/PDO.php
<#808 (comment)>:
> + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software consists of voluntary contributions made by many individuals
+ * and is licensed under the MIT license. For more information, see
+ * <http://www.doctrine-project.org>.
+ */
+
+/**
+ * PDO shim to keep DBAL compatible with non-PDO PHP installations.
+ *
+ * @link http://php.net/manual/en/pdo.constants.php
+ * @Package Doctrine\DBAL
+ */
+class PDO
Creating such class could break any other library checking the existing of
the PDO class and then trying to use something else than a constant from
it when it exists. So I'm -1 on adding it.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#808 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAJakJxxUgoz3RLEosq_wvdgiNZR430jks5r10fegaJpZM4DnfUd>
.
|
Closing: moving to #2709 |
…dd-pdo-as-hard-dependency Adding PDO as hard dependency as per discussion in #808
Even though DBAL currently offers non-PDO drivers, it depends on a number of PDO constants which renders it unusable if PHP was explicitly compiled without PDO. This PR is an attempt to shim PDO constants as stated in ticket DBAL-1156 (http://www.doctrine-project.org/jira/browse/DBAL-1156)