Skip to content
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

[ticket/14463] Add Doctrine DBAL as a driver #5841

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

CHItA
Copy link
Member

@CHItA CHItA commented Jan 26, 2020

This probably breaks all db tools etc, so it is mostly opened to gather feedback.

Checklist:

  • Correct branch: master for new features; 3.3.x & 3.2.x for fixes
  • Tests pass
  • Code follows coding guidelines: master, 3.3.x and 3.2.x
  • Commit follows commit message format

Tracker ticket (set the ticket ID to your ticket ID):

https://tracker.phpbb.com/browse/PHPBB3-14463

@CHItA CHItA added WIP 🚧 4.0 (Triton) 🔮 dependencies Pull requests that update a dependency file labels Jan 26, 2020
@CHItA CHItA added this to the 4.0.0-a1 milestone Jan 26, 2020
@CHItA CHItA requested review from marc1706 and Derky January 26, 2020 14:49
@ghost
Copy link

ghost commented Jan 26, 2020

I have played with this a few months back aswell.
In case you’re interested: https://github.com/mrgoldy/phpbb/tree/ticket/14463

*
* @return void
*/
private function iterate_backward()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As of now, this method is just horse shit mixed with snake oil, as fetch_all() doesn't fetch all but all remaining rows from the current cursor position. The problem here is saving all rows (which is one option to actually support going backwards) would add some overhead on all queries. I'm not sure if breaking BC here would make more sense, as I guess this might be some functionality that is not used at all by anyone (certainly not by the core).

@marc1706 @Derky @Nicofuma thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO if there is no good way to achieve this then don't. Especially if it's not even used in the core. We should however make sure to properly document this BC break, e.g. in the documentation. I can prepare a page for this (similar to how symfony is documenting those changes: https://github.com/symfony/symfony/blob/master/UPGRADE-5.0.md).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only solution I see is to store all fetched rows in the iterator. I doubt that there would be any other solution to this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we could reexecute the query as well when backward iteration is called for, thus only having any overhead when it is absolutely required.

Copy link

@ghost ghost Jan 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not possible to save queries that are made per page in a protected property? This will also allow extensions to access SQL queries that are already made by the core, without having to rerun them if they're not cached.
For example saving the SQL queries in $queries and all the SQL results in $results.

protected $queries = [
    0 => 'SELECT * FROM `phpbb_forums`',
];

protected $results = [
    0 => [
        0 => ['forum_id => 1', '...' => '...'],
    ],
];

So you can iterate over them and check before querying to see if it already exists.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we would want to add any new features to this, as the goal here is to keep BC as much as possible. Also, if you re-execute a query, chances are it comes from the cache which should be much faster. Thirdly, extensions should not really execute the same queries as that data probably is accessible to them from somewhere.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that's not completely true as a lot of queries in the core are not cached and not accessible for extensions, if not in tedious ways. But it was just an idea.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extension authors can add events if they want to.

@ghost
Copy link

ghost commented Jan 28, 2020

What I not fully understand, is that the idea was to 'nuke dbal' and to eventually get rid of the phpBB part all together. Wouldn't it then make more sense to nuke it completely. Namely, replacing phpBB DBAL with Doctrine DBAL and implementing a phpBB wrapper class (for BC) that can eventually be deprecated and removed, rather than keeping the phpBB DBAL and adding a Doctrine driver?

@CHItA
Copy link
Member Author

CHItA commented Jan 28, 2020

What I not fully understand, is that the idea was to 'nuke dbal' and to eventually get rid of the phpBB part all together. Wouldn't it then make more sense to nuke it completely. Namely, replacing phpBB DBAL with Doctrine DBAL and implementing a phpBB wrapper class (for BC) that can eventually be deprecated and removed, rather than keeping the phpBB DBAL and adding a Doctrine driver?

That is exactly what this PR does. See the @depreceted annotation on doctrine. I'm not really sure if this was your question.

@ghost
Copy link

ghost commented Jan 28, 2020

Ah, I kind of misinterpreted this PR. As you are indeed doing it.
However, in a different fashion that I had imagined. I would of thought of adding a wrapperClass rather than using a factory. Both work I suppose and with this you keep the class \phpbb\db\driver\driver_interface alive. Okay I get it I think.

@CHItA CHItA force-pushed the ticket/14463 branch 4 times, most recently from c22cbba to 4fbc3a8 Compare February 2, 2020 13:13
@CHItA CHItA force-pushed the ticket/14463 branch 11 times, most recently from a82e441 to 6d1eb2d Compare February 6, 2020 17:22
@CHItA CHItA force-pushed the ticket/14463 branch 10 times, most recently from 7f63b9a to 411b952 Compare August 9, 2020 17:58
@rubencm
Copy link
Member

rubencm commented Sep 15, 2020

@CHItA CHItA mentioned this pull request Feb 1, 2021
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0 (Triton) 🔮 dependencies Pull requests that update a dependency file WIP 🚧
Projects
None yet
4 participants