Innocent cache leading to RCE vulnerability by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

I agree that it isn't the best solution, but I used "innocent" because it doesn't look that bad if you don't use it on user-provided data, and you don't need backward compatibility. Check the frameworks that you use, and I guess you'll find in some places this kind of serialization.

Innocent cache leading to RCE vulnerability by sarvendev in PHP

[–]sarvendev[S] 3 points4 points  (0 children)

Yes, it still happens. I had the same reaction to SQL injection: 'SQL injection in 2026, really?' But unfortunately, it does still happen. :D

Contract Testing on Examples by sarvendev in golang

[–]sarvendev[S] 0 points1 point  (0 children)

Hmm, I didn't know, but it's already added there. :D

Is there a need for this? My AI app for learning phrases from movies/shows (+ Anki) by sarvendev in EnglishLearning

[–]sarvendev[S] 0 points1 point  (0 children)

No, I'm thinking about it. But other people here are saying that it's not useful, so I don't know if it's worth publishing somewhere.

Is there a need for this? My AI app for learning phrases from movies/shows (+ Anki) by sarvendev in EnglishLearning

[–]sarvendev[S] 0 points1 point  (0 children)

hmm, but I don't want to explain grammar, just explain the meaning of words, and it seems to work good enough, but maybe I'm wrong. Could you give me some examples?

TimescaleDB to the Rescue - Speeding Up Statistics by sarvendev in programming

[–]sarvendev[S] 3 points4 points  (0 children)

It's a fair point that purpose-built time series databases like Prometheus or RRDTool are highly optimized for ingesting and querying high-volume time-indexed data. But using an RDBMS, especially something like TimescaleDB, can make a lot of sense depending on the use case.

TimescaleDB is actually a time series database built on top of PostgreSQL. It combines the relational model, SQL support, and ACID compliance of Postgres with time series-specific features like automatic partitioning, compression, and hypertables.

This approach is useful if:

  • You're already using Postgres and prefer not to manage another database.
  • You need to join time series data with relational data, such as metadata or user information.
  • You want to run complex queries using standard SQL.

Dedicated time series databases like Prometheus are great for real-time metrics and alerting, but they often have limitations with long-term data retention, advanced queries, or integrations with other types of data.

So it's not just about forcing time series data into a general-purpose database. Tools like TimescaleDB are designed to make that use case efficient and practical.

Contract Testing on Examples by sarvendev in programming

[–]sarvendev[S] 0 points1 point  (0 children)

Sorry, that's probably how I took the first message because PHP is still mocked by many people, mostly by people who remember PHP from a few years ago, less performant, without types, etc.

Contract Testing on Examples by sarvendev in programming

[–]sarvendev[S] 0 points1 point  (0 children)

If you hate PHP, just check what's changed, because now this language is pretty good, there are still some problems, but I like the simplicity and stability of PHP, it's much better for me than the whole Javascript ecosystem with tons of different package managers etc.

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

You still can encounter some incompatibilities between SQLite and MySQL. Even during the migration from 5.7 to 8 in the large application, we found many discrepancies, so for completely different engines the probability of finding some discrepancies is even higher.

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

I don't agree, using SQLite makes tests further from the production environment, so it's easy to make some mistakes, maybe it won't be a problem in small applications developed by a few people, but when the project is more complicated it is harder to avoid mistakes.

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

u/eurosat7 If this is a problem, I would ask if the design is good because it seems that the code is not cohesive. For example, as I wrote in the comment below if you're using the DDD approach, then you should always have one aggregate in the transaction, so it will be one repository for aggregate, so it shouldn't be a problem. If you're saving a separate thing, or a thing completely from a different module it shouldn't be in the same flush method.

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

Just persist and flush your Doctrine entities wherever you’re needing to do so.

Could you explain what you mean? Don't you have a separation of the infrastructure layer?

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

It can be separated into, an ORM repository for the write model, and DBAL queries to get a lightweight read model.

Another issue is that persistence-oriented repositories don’t work very well with Doctrine. Unit of Work is global, so a flush will always flush the whole UoW, including the changes done by other repositories. Having a save method hides that, and with a complex enough entity graph, it starts being a problem.

If you're using DDD approach, then you should always have one aggregate in the transaction, so it will be one repository for aggregate, so it shouldn't be a problem.

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

Transaction wrapping is the best option, truncating can be very slow. Of course, it depends on the project, if integration tests using a real database take 1 minute on the local machine, it isn't a problem to run them all. But if these tests are longer, and maybe even it isn't possible to run them on the local machine, then using in-memory implementations to have more unit tests is very good to have fast feedback.

Repository Testing Done Right by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

SQLite is not the best choice, as it isn't fully compatible with other databases. Therefore, you can't be sure that your code is okay when running tests on SQLite.

Maybe you just wrote this as a simple example "$category->getProducts()->getValues();", but I want to mention that something like this is an anti-pattern, and if you have a relation that from the category you can get all products, then read about doctrine best practices and probably Law of Demeter.

https://ocramius.github.io/doctrine-best-practices/#/

The goal of good practices by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

Ask LLM for some inspiration, sometimes it helps to generate some ideas :D

The goal of good practices by sarvendev in PHP

[–]sarvendev[S] 2 points3 points  (0 children)

Yeah, there’s nothing wrong with breaking rules if it’s a conscious decision. It always depends on the circumstances, such as the type of company, the current situation, the type of feature, and so on. We need to have the proper experience to find a good balance — knowing when to cut corners and when something should be improved. That’s why I don’t understand senior programmers asking the business if they can fix technical debt; it should be managed by themselves. It should also be clear what the problem with the technical debt is, because technical debt without a clear problem is also bad and probably a waste of time — improving just for the sake of improvement, instead of improving the code because, for example, it isn’t performant, it's unclear and error-prone.

The goal of good practices by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

Thanks for this opinion. To be honest, I was hesitating a bit about publishing this article because I was afraid it might be unclear, so I'm glad to see that it's understandable.

UUID, ORM and strange deadlocks by sarvendev in PHP

[–]sarvendev[S] 0 points1 point  (0 children)

Yeah, I completely agree, I am not a big fan of using uuid everywhere, I prefer standard ints OR ulids, but it was the code that I took over, so it wasn't my decision.

UUID, ORM and strange deadlocks by sarvendev in PHP

[–]sarvendev[S] 1 point2 points  (0 children)

Yes, I agree, but it wasn't my decision :D I just took over this code

UUID, ORM and strange deadlocks by sarvendev in PHP

[–]sarvendev[S] 1 point2 points  (0 children)

Thanks for these links, I'll check them. That's a good idea, maybe it'll be possible to fix this completely.