Problem/Motivation
You can into a situation where the PHP module is uninstallable.
Steps to reproduce:
- Install the PHP module
- Go to admin/config/content/formats/manage/php_code and untick the php filter plugin checkbox
- Uninstall the PHP module
- Try to reinstall the PHP module
- For extra kicks disable the PHP filter format on admin/config/content/formats/manage and you can even see it :)
Another interesting scenario:
- Install the PHP module
- Go to admin/config/content/formats/manage and disable the PHP filter format
- Uninstall the PHP module
- Reinstall the PHP module - it works!
Filter formats have a special place in Drupal because of their relationship to security. This is why they can't be deleted. I think the only way forward is to move the filter to config/optional so that existing sites can take advantage of the PHP filter plugin even have they have a disabled PHP filter format. The second scenario is tricky though because the whole point is that you're not supposed to be able to delete filter formats.
Proposed resolution
Make dependencies correct in default config and move it to optional so that even if a site has a disabled format (or an enabled format) called filter.format.php_code the module can be installed.
Remaining tasks
Decide whether this approach is correct.
User interface changes
None
API changes
None
Data model changes
Original report
When I try to install the PHP module (on Drupal 8), I get this message:
Unable to install PHP Filter, filter.format.php_code already exists in active configuration.
Since PHP filter is currently not working on my site, I cannot understand where it is seeing this file. Please help.
Thanks,
John
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 2639336.16.patch | 757 bytes | alexpott |
Comments
Comment #2
hass commentedWhat other modules are you running? Have you uninstalled the module and try to reinstall ?
Comment #3
jnimchuk commentedYes, I uninstalled the module, deleted the files, and tried installing again.
I believe now that the issue has to do with upgrading from Drupal 6. Maybe something carried over related to PHP filter.
Thoughts?
jdn
Comment #4
hass commentedNo idea. You need to debug for us...
Comment #5
jnimchuk commentedBut where is your install looking for:
filter.format.php_code ???
Comment #6
jnimchuk commentedOK, FYI.
There were a couple of references hanging in the database (copied over from DR6). I deleted these records and Voila!
Comment #7
hass commentedCan you share a patch, so this does not happen again to other users. Maybe it is a core issue, but I have no idea how to reproduce.
Comment #8
quindio commentedI am playing with D6 to D8 migration and I added the php module and I am getting the errros
Unable to install PHP Filter, filter.format.php_code already exists in active configuration.
Can some one tell me how to fix the problem!!!
Thanks
Comment #9
quindio commentedmy D6 migration brought PHP_FILTER and this does not allow me load the PHP module
I still get the error "Unable to install PHP Filter, filter.format.php_code already exists in active configuration."
I remove php_code reference from the DB table migrate_map_d6_filter_format and the
PHP_FILTER does not show in the nodes as a format choice but I am still not able to load the the PHP module.
Any advice???
Thanks,
Comment #10
ryrye commentedIn reply to a couple of people above who had problems trying to fix this when upgrading D6 -> D8, here's what I did to fix it:
There were a couple of rows in the database with refs to php_code that I changed:
I'll probably delete these now that the module is successfully enabled.
Comment #11
quindio commented#10 is correct. I was able to do the same things, these are the tables that
I found 'php_code':
After clearing these tables I installed and enabled the php module
everything looks good except that you will get the following in your logs:
"Missing filter plugin: filter_null."
I proceed to set the filter to php_code on a block but the page that uses that
block crashes then I disable the php module via the GUI('extends') and my
page is back.
After this you can not enable the php filter using the GUI because once disable
the filter disappears.
This is great if you are not using php filter in your site but if you need php you
still end up without a solution.
After all of these I am still not able to use the php filter
HELP!!!
Comment #12
quindio commentedryrye, where you able to use PHP on your Drupal 8 site?
Maybe, I cleared to many tables. I Will try just clearing the
migrate_map_d6_filter_format and config
Someone told me that you can remove the all of the
migrate_?? tables
Comment #13
alexpottThis is because filter.format.php_code is missing a dependency on the php module - how was it generated?
Comment #14
alexpottHmmm but actually the install process will add the missing dependency still the default config should have it.
Comment #15
alexpottSo this is a fun issue! It is caused by the magic of filter formats and the fact they aren't deleteable through the UI. Added steps to reproduce to the issue summary.
Comment #16
alexpottHere's a solution that will allow people to re-install and at least get the use of the filter again.
Comment #18
hass commentedMany thanks for your help.
Comment #20
hass commentedComment #22
numerabilis commentedCould you teach me how to apply this patch? I don´t know how to apply PATCHes... I need to know how to do that! I migrated D6 to D8 and I am having this php filter issue, no content are showing, my site is full of links pointing to blank pages.
Comment #23
nelslynn commentedWas this patch applied to the dev version? I still get this error with both dev (2016-Apr-28) and 8.x-1.0-beta2 versions.
Comment #24
BartNijs commentedThe patch wasn't applied to the beta version, but all you have to do is move one file in the module's folder:
from config/install/filter.format.php_code.yml to config/optional/filter.format.php_code.yml
Comment #25
kundu commented#24 solved it. Thank you.
I wonder why it did it.
Comment #26
mxr10 commentedthis work for me:
move one file in the module's folder:
from config/install/filter.format.php_code.yml to config/optional/filter.format.php_code.yml
like @BartNijs said thank you
Comment #27
ecosty commentedI think the best option is to remove the current configuration first:
Comment #28
mandymeng commented#27 fixed my problem. Thank you @ecosty.
drush cdel filter.format.php_code
drush en php
drush cache-rebuild