Fatal error: Cannot redeclare DNH function
-
Hi, just tried your plugin for the first time, and immediately after the activation this error was shown. It seems your plugin and the wps-hide-login plugin both use the same function name “DNH” without putting them into classes.
Could you fix it? Until then deactivating..
Fatal error: Cannot redeclare DNH() (previously declared in ../wp-content/plugins/wps-hide-login/vendor/NicolasKulka/wp-dismissible-notices-handler/handler.php:629) in …/wp-content/plugins/advanced-responsive-video-embedder/php/Admin/vendor/julien731/wp-dismissible-notices-handler/includes/helper-functions.php on line 34
-
You need to go to
https://nextgenthemes.com/support to ask a question. he asked not to use this forum.@tokyoprogressive , thanks.
It seems the fault lies with the wps-hide-login plugin using an outdated library, other plugins are affected as well. The plugin developer is on it, I assume a solution is coming.
@tokyoprogressive Thanks.
@tezalsec Correct. Hopefully not many other plugins use an outdated version, the check should have been in there from the beginning as it was intended to be used by multiple plugins/themes.
@nico23 , the other plugin developer just updated his library, but the issue remains. I still have the fatal error.
Shouldnt you both just put the DNH() inside a class so it does not clash with other plugin’s use of the function?
@nico23 , sorry to keep approaching you about this this way, hope you will pick it up.
The other developer points me to you. He has updated his library, but it seems it wasn’t about not being uptodate, just that the DNH function is declared twice.
It now looks like it is your plugin that loads the DNH function as: 1. outside of a class, and 2. without checking if it already exists.
The other developer says: “I have a function that checks if the function exists, if it already exists, I do not go to the rest of the file”.
@nico23 , I checked both your code in helper-functions.php, and my assumption is that you are both still at fault. It has nothing to do with libraries being uptodate.
The DNH function should be either in a class or have a unique function name, like “ARVE_DNH”. The check for double occurrence of functions happens by php itself before processing logic, so an if then statement at the start of the include file does not sufficiently solve this.
Please consider renaming the DNH function to a unique variant.
-
This reply was modified 5 years, 3 months ago by
tezalsec.
sorry to keep approaching you about this this way, hope you will pick it up.
OH really are you? Why you people keep ignoring the support site. What is so hard to register and post there?
It’s not my code you looked at but the code of the dev who wrote that library. But I guess this is what you meant.
Holy fuck I included that library because like 3 people had issue with admin messages and I thought I included some code from someone else because WP in 2021 stick lacks a basic API for something as basic as admin messages.
And turns out that lib fucking sucks.
The DNH function should be either in a class or have a unique function name, like “ARVE_DNH”. The check for double occurrence of functions happens by php itself before processing logic, so an if then statement at the start of the include file does not sufficiently solve this.
I think you are on the right track but you not really got it. Its just that the library needs to wrap ALL functions with
if ( function_exists( 'EVERY_FUNCTION_IN_THAT_FILE' ) ) {There should be no need at all to rename anything. I do not know what you are talking about runtime … I know for a fact that wrapping functions with
if ( function_existsworks and I it and have seen lot of uses of this.I still a bit confused about why exactly, but I fixed it, tried this file with the wps-hide-login. After confirming the issue I applied this.
https://github.com/julien731/WP-Dismissible-Notices-Handler/pull/14/files
So not sure what you go on about renaming and putting it into a class, but THIS is how you do it.
The problem with this is every other plugin dev needs to update this flawed code. And the wps-hide-login dev actually uses a forked version of the library from another dev …
What a mess just by using one tiny lib … I will completely rename everything in that lib I guess …
both still at fault
Well, not really. I guess for using a “library” assuming it can actually be used as one but if you want to blame someone blame the person who wrote it. Mistakes happen, but it’s strange that this it not even fixed in the latest versions of this lib (even in different forks)
-
This reply was modified 5 years, 3 months ago by
Nico.
Even while applying your solution on wps-hide-login in the vendors, I cannot activate your plugin which makes a fatal error: /
You need to also apply it to ARVE in
libsI tested it and it for sure works!Will fix this soon with a renamed version of that class without the helpers altogether.
Hi @nico23 ,
thanks for addressing it. And you are right, of course, by wrapping the whole function it should be solved. 🙂
FYI, I have never once used your plugin, I was about to try it, but never got beyond the fatal error. And I don’t like creating accounts on sites even before having tried the product even once.
I never meant any disrespect, I just meant to be helpful and keep the issue alive, as the subject didn’t seem to get any further because everyone was just pointing at each others plugins, and talking about updating libraries. And you are right of course, the fault is primary with the library maker.
Hope we are moving in the right direction with the library now. Cheers.
-
This reply was modified 5 years, 3 months ago by
The topic ‘Fatal error: Cannot redeclare DNH function’ is closed to new replies.