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

Herd Pro not compatible with Kirby because of dump() helper #6250

Closed
lukasbestle opened this issue Feb 9, 2024 · 8 comments · Fixed by #6314
Closed

Herd Pro not compatible with Kirby because of dump() helper #6250

lukasbestle opened this issue Feb 9, 2024 · 8 comments · Fixed by #6314
Labels
type: enhancement ✨ Suggests an enhancement; improves Kirby
Milestone

Comments

@lukasbestle
Copy link
Member

I'll bring that up again because Kirby doesn't work with Herd Pro (or it doesn't if you want to use the Dump feature, which is a main argument to use the Pro version) and since there is an official video on how to use Herd with Kirby, that sounds like a reason to discuss the issue again.

https://www.youtube.com/watch?v=Mb_-bo77IPc

Originally posted by @sschlein in #4462 (comment)

@lukasbestle
Copy link
Member Author

What we could do is to detect if the existing dump() function was defined within a file in the Herd folder. Then we can reliably say that the user intends to use Herd's dump feature and disable our function even without defining the constant.

@lukasbestle lukasbestle added type: enhancement ✨ Suggests an enhancement; improves Kirby needs: decision 🗳 Requires a decision to proceed labels Feb 9, 2024
@bastianallgeier
Copy link
Member

@lukasbestle I like that idea.

@andielliott
Copy link

I'd actually raised this with Beyond Code first, and they replied with:

It seems like Kirby does not properly check if a global function is already declared.
Our custom dump-loader defines this function and therefore it should overload Kirby's function.

This line should have a if (!function_exists('dump')) around it...

function dump(mixed $variable, bool $echo = true): string

@lukasbestle
Copy link
Member Author

So far we didn’t do that on purpose because it causes unexpected behavior. For most cases this would still be true, but with Herd and other server setups that externally define the helper, it is expected that the external helper is used.

@distantnative
Copy link
Member

Maybe let's take a news perspective her: We always didn't what to do if (!function_exists()) as it could lead to unwanted consequences with global helpers like e.g. go() if any other than the Kirby one is used unknowingly.

But since dump() is solely used for debugging.... maybe that is a special one where we could change our policy?

@bastianallgeier
Copy link
Member

@distantnative I thought along those lines as well. Other helpers could indeed be super destructive, but I've never seen a dump method used for anything else than dumping. I think it's a pretty universal standard in PHP land. So I would say that we could really make an exception here.

@sschlein
Copy link

sschlein commented Feb 9, 2024

While I have absolutely no idea how Kirby works and have only used it for testing Herd, Herd Pro and Tinkerwell and run into the dump problem with these tools, I'd agree with that.

Most major frameworks and systems are using the function_exists for dump() so that it can be set differently and they seem to do well. I absoutely agree with things that are relevant to the application itself and that shouldn't be overwritten easily.

@lukasbestle
Copy link
Member Author

I agree. So far we only ever had this issue with dump(). We added the disable constants to all helpers and I think they can still make sense e.g. if someone wants to customize/replace the helpers in a plugin. But for dump() it is indeed OK if Kirby accepts an externally defined function by default. So here we could have a check that accepts either the constant or function_exists().

@lukasbestle lukasbestle removed the needs: decision 🗳 Requires a decision to proceed label Feb 24, 2024
@bastianallgeier bastianallgeier added this to the 4.1.2 milestone Feb 29, 2024
@bastianallgeier bastianallgeier linked a pull request Feb 29, 2024 that will close this issue
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement ✨ Suggests an enhancement; improves Kirby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants