I notice there are far more files and directories for kcfinder ./vendor/civicrm/civicrm-packages/kcfinder/ compared to ./web/libraries/civicrm/packages/kcfinder. For example the browse.php file is not present in libraries path, which explains why the functionality to find and upload images in CiviMail or CiviEvent does not work and produces a 'page not found' error in the logs
/libraries/civicrm/packages/kcfinder/browse.php?cms=civicrm&type=images&CKEditor=crmUiId_1&CKEditorFuncNum=0&langCode=en-ca.
Copying the kcfinder contents from /vendor path to the /libraries path does not help, so there is more to this.
BTW, test case summary is:
#installed with
composer create-project drupal/recommended-project <path> composer require civicrm/civicrm-asset-plugin civicrm/civicrm-drupal-8 civicrm/civicrm-packages
Also occurs with
composer create-project roundearth/drupal-civicrm-project:8.x-dev www-cmnty-drupal --no-interaction
#set permissions (Cpanel machine) run with root
cd ./web chown -R user:nobody . find . -type d -exec chmod u=rwx,g=rx,o= '{}' \; find . -type f -exec chmod u=rw,g=r,o= '{}' \; cd /sites find . -type d -name files -exec chmod ug=rwx,o= '{}' \; for d in ./*/files do find $d -type d -exec chmod ug=rwx,o= '{}' \; find $d -type f -exec chmod ug=rw,o= '{}' \; done
@karunadev what exactly is broken in your civicrm installation? And what version are you on and what cms?
Did you also chekc whether this is still broken on https://dmaster.demo.civicrm.org?
At this moment, this problem currently does NOT appear on https://dmaster.demo.civicrm.org/. Is anyone here aware of a code change that would have fixed this issue? I hesitate to close this without at least having evidence that it was intentionally (or durably) fixed.
Please ignore this comment, as it refers to dmaster, not d8-master.
I'm seeing this same issue in a test upgrade of a D8/Civi site. Site is based on the old Roundearth D8 project template, but the new asset-plugin is in use. Target upgrade versions: Drupal v8.9.11, Civi v5.32.1.
Manually copying over the kcfinder files from the vendor folder seems to get the browser working, but I'm unsure what else might be broken at this point. It's obvious, however, that the asset plugin isn't copying over the right files to make things functional.
The asset plugin doesn't copy php files, just typical front-end assets like jpgs and js files (see default-config.json), because otherwise it would be insecurely making all the php files available. But kcfinder requires its php files to be web-accessible for this popup to work.
I haven't tested this but if you edit default-config.json to add something like this to the "include" section (not sure of the right syntax) then run composer civicrm:publish, it might work:
**kcfinder/**
If it does maybe we could add that to the default-config.json permanently.
Thanks for adding the tips, everyone. I found that this simple addition to the composer.json extra section does the trick for my site upgrade, at least when it comes to kcfinder:
I have no idea what else might be broken at this point. But kcfinder is a typical issue. Note that Apache2 still requires a .htaccess file addition to the kcfinder folder (and the the civicrm/extern folder as well), to allow it to work. I wonder if there's a way to get the plugin to add those, as well.
With all due respect to those working hard on this excellent tool, if this is the standard installation experience, then pushing it as an upgrade to the roundearth composer plugin, which appears to do the job properly, is probably not a wise thing until this bug is corrected. Requiring an undocumented composer.json fix just to get Civi to fully install isn't going to inspire confidence.
It appears I may have been working with old information. Not sure how I missed this. It looks like my current installation works without the .htaccess files being needed!
I notice that the extern folder's php files aren't even being used at this point but an alternative router path is being used (great job folks!) Don't know how kcfinder's browse.php is working, but it is.
Are we able to resolve this by adding the relevant "extra" section to a composer.json in either civcirm-drupal-8 or something similar? Or does this need to be added at the root level?
This still doesn't work in D9 environments. I see from debugging, that the KCFinder configuration (disabled=false etc.) ist stored into the $_SESSION object directly, but Drupal starts its own session, initiated here - that's when the $_SESSION variable is overwritten, discarding previously set values.
According to this change record, relying on session IDs, as is done in the KCFinder CiviCRM integration, is not correct, so the code here will either have to be adjusted for using a Drupal/CiviCRM session for storing KCFinder configuration, or the ID of the session to store KCFinder configuration in can not be identified using CiviCRM/Drupal code.
Is anyone successfully using KCFinder with CiviCRM on Drupal 9? And what's the plan for this issue currently?
Your PR resolves the session issue () but we still need to adapt things ...
In the civicrm.config.php file in civicrm_conf_init() we need to add ../../../../sites/default as a candidate directory for finding the site directory, as this code runs from path/to/doc_root/web/libraries/civicrm/packages/kcfinder, which is one level deeper. So this would require another PR, this time to https://github.com/civicrm/civicrm-drupal-8
We'll have to just chdir($civicrm_root) before and chdir($current_cwd) after the require_once "{$civicrm_root}/civicrm.config.php"; in web/libraries/civicrm/packages/kcfinder/integration/civicrm.php for the civicrm.config.php to include the settings file.
In the global .htaccess file, all the PHP scripts inside /libraries/civicrm/packages/kcfinder need to be explicitly excluded from denying access with RewriteCond rules.
Can you confirm this is what you also have adjusted?
Yes, I did exactly those steps (I copied civicrm.config.php to web/libraries/civicrm/civicrm.config.php and adjusted $candidates so it finds civicrm.settings.php), along with adding
In a D9 install we came across the same issue.
We installed ckeditor5 and updated the display settings under administer.
We can now upload the images using the traditional Template.
So this is a good work around in our situation.
Though functionally it is working, it looks quite different from the previous one. When you create a new template, the body of the template is shown as a small box only. The icons are relatively big.
All not a big deal, since it is working, but the previous editor looked as if it was part of CiviCRM, and this one looks indeed as 'added functionality'.
Still an issue:
Uploading images when creating a name badge still does not work in D9. I get the message 'The requested page could not be found'. It is looking for this path: *yourwebsite/libraries/civicrm/packages/kcfinder/browse.php?cms=civicrm&type=images
Apparently not, there's still https://github.com/civicrm/civicrm-packages/pull/343 for making the civicrm.config.php discoverable, and there's still the need for adjusting the composer.json as described above. Seems this won't make it completely before CKEditor 4 will be EOL.
following since we observed this on d9 Master and on our new d10 sites. Have switched one site to https://lab.civicrm.org/extensions/summernote but while it works it fails the test (thus far) of providing the same features.
Also experiencing this bug with a brand-new Drupal 10 & CiviCRM site configured directly via plain Composer config. In case it helps anyone, the .htaccess changes mentioned by @jensschuppe above were specifically changing web/.htaccess lines from:
# Copy and adapt this rule to directly execute PHP files in contributed or # custom modules or to run another PHP application in the same directory. RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics\.php$
to:
# Copy and adapt this rule to directly execute PHP files in contributed or # custom modules or to run another PHP application in the same directory. RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/browse\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/index\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/js_localize\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/upload\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/css/index\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/themes/default/css\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/js/index\.php$ RewriteCond %{REQUEST_URI} !/libraries/civicrm/packages/kcfinder/themes/default/js\.php$
Also, the described steps for fixing kcfinder/integration/civicrm.php didn't work for me, possibly the configuration files have moved in recent versions of CiviCRM? I had to change this file from:
KCFinder browse.php not accessible after upgrade to Drupal 10 and CiviCRM 6.1 (multisite + composer)
I’ve recently completed an upgrade from Drupal 7 + CiviCRM (non-composer setup) to a Drupal 10 + CiviCRM 6.1 multisite setup, using Composer. The CiviCRM database remains separate from the site databases (same as in the old D7 setup). Everiting ok
I'm now facing a problem with KCFinder not working properly when trying to insert or browse images in rich text editors like CKEditor. Specifically, accessing:
/libraries/civicrm/packages/kcfinder/browse.php?cms=civicrm&type=images
…results in a 404 error or broken link and if I copy inside folder not change (permission error appear)
In my project is structured with not inside web/ (standard but for future multisite necessity (one of sites I will use open social, but this is in influent another argument). :
drupal-10/
├── composer.json
├── libraries/
│ └── civicrm/
│ └── packages/
├── vendor/
│ └── civicrm/
│ └── civicrm-packages/
└── sites/
└── sportforma.it/
└── (multisite site config and settings)
In my root composer.json, I have this configuration:
I tried
"extra": {
"civicrm-asset": {
"path": "libraries/civicrm",
"url": "/libraries/civicrm"
}
}
but I think not necessary n new versions.
I run the command:
composer civicrm:publish
Which outputs:
Publishing CiviCRM assets to libraries/civicrm
Generating CiviCRM asset map
However, not all assets are actually copied. The packages/ folder appears, but many subfolders are incomplete — for instance, kcfinder/ is missing the critical browse.php and other PHP files.
This results in editor integrations breaking (like when trying to insert an image via CiviMail or CKEditor).
I tried Temporary workaround by manually copying:
cp -r vendor/civicrm/civicrm-packages/* libraries/civicrm/packages/
but not fix... just another different errors, so I step back .