Closed Alek2012 closed 3 years ago
@Alek2012 Whoops! I'll check this out. Can I ask what version of Craft, MySQL, PHP and Composer your running?
This was a fix I pushed to make it work for Composer 2, but looks like it's breaking!
@bymayo yes, I have checked this for Craft versions (Craft Pro 3.4.30 and Craft Pro 3.5.14), MYSQL version is (MySQL 5.6.39 and MySQL 5.7.30), Composer version is (Composer version 1.6.3 and Composer version 2.0.3)
@Alek2012 Can I double check you've updated to 1.0.3 of this plugin?
I can't replicate your issue, but I can see why it's happening. It's due to the case sensitivity of the PdfTransformAsset
file. But this was changed recently and I can see in the repo it's correct.
I've also just released 1.0.4 with a few uppercase/lowercase fixes. Can you try this.
Hi, @bymayo I rolled back to 1.0.2 and it works there. I will check version 1.0.4 shortly. Thanks for your work
@Alek2012 Yeah it must be a case sensitivity issue. Try the latest version. If that doesn't work I'd probably suggest removing it via composer and installing it again via the plugin store. As it looks like composer doesn't recognise the file name changes.
Hi, @bymayo I updated the plugin to version 1.0.4 using the composer.json file, and now I'm getting an error:
`Invalid Argument – yii\base\InvalidArgumentException The file or directory to be published does not exist: /app/vendor/bymayo/pdf-transform/src/assetbundles/pdftransform/dist
1. in /app/vendor/yiisoft/yii2/web/AssetManager.php at line 455
446447448449450451452453454455456457458459460461462463464
public function publish($path, $options = [])
{
$path = Yii::getAlias($path);
if (isset($this->_published[$path])) {
return $this->_published[$path];
}
if (!is_string($path) || ($src = realpath($path)) === false) {
throw new InvalidArgumentException("The file or directory to be published does not exist: $path");
}
if (!is_writable($this->basePath)) {
throw new InvalidConfigException("The directory is not writable by the Web process: {$this->basePath}");
}
if (is_file($src)) {
return $this->_published[$path] = $this->publishFile($src);
}
2. in /app/vendor/yiisoft/yii2/web/AssetBundle.php at line 185 – yii\web\AssetManager::publish('/app/vendor/bymayo/pdf-transform...', [])
3. in /app/vendor/yiisoft/yii2/web/AssetManager.php at line 266 – yii\web\AssetBundle::publish(craft\web\AssetManager)
4. in /app/vendor/yiisoft/yii2/web/AssetManager.php at line 237 – yii\web\AssetManager::loadBundle('bymayo\pdftransform\assetbundles...', ['class' => 'bymayo\pdftransform\assetbundles...'], true)
5. in /app/vendor/yiisoft/yii2/web/View.php at line 287 – yii\web\AssetManager::getBundle('bymayo\pdftransform\assetbundles...')
6. in /app/vendor/twig/twig/src/Extension/CoreExtension.php at line 1499 – yii\web\View::registerAssetBundle('bymayo\pdftransform\assetbundles...')
7. in /app/vendor/craftcms/cms/src/helpers/Template.php at line 92 – twig_get_attribute(craft\web\twig\Environment, Twig\Source, craft\web\View, 'registerAssetBundle', ...)
86878889909192939495969798
// Add deprecated support for the old DateTime methods
if ($object instanceof \DateTime && ($value = self::_dateTimeAttribute($object, $item, $type)) !== false) {
return $value;
}
try {
return \twig_get_attribute($env, $source, $object, $item, $arguments, $type, $isDefinedTest, $ignoreStrictCheck);
} catch (UnknownMethodException $e) {
// Copy twig_get_attribute()'s BadMethodCallException handling
if ($ignoreStrictCheck || !$env->isStrictVariables()) {
return null;
}
throw new RuntimeError($e->getMessage(), -1, $source);
8. in /app/vendor/bymayo/pdf-transform/src/templates/settings.twig at line 3 – craft\helpers\Template::attribute(craft\web\twig\Environment, Twig\Source, craft\web\View, 'registerAssetBundle', ...)
123456789
{% import "_includes/forms" as forms %}
{% do view.registerAssetBundle("bymayo\\pdftransform\\assetbundles\\PdfTransform\\PdfTransformAsset") %}
{{ forms.textField({
label: 'Page Number',
instructions: 'The page number to render.',
id: 'page',
name: 'page',
9. in /app/vendor/twig/twig/src/Template.php at line 405 – __TwigTemplate_b21aa0129102acf0ef7784674b9d47c32fedf6be5e6c901db140ae2628604f92::doDisplay(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']], 'view' => craft\web\View, 'devMode' => true, ...], [])
10. in /app/vendor/twig/twig/src/Template.php at line 378 – Twig\Template::displayWithErrorHandling(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']], 'view' => craft\web\View, 'devMode' => true, ...], [])
11. in /app/vendor/twig/twig/src/Template.php at line 390 – Twig\Template::display(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
12. in /app/vendor/twig/twig/src/TemplateWrapper.php at line 45 – Twig\Template::render(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]], [])
13. in /app/vendor/twig/twig/src/Environment.php at line 318 – Twig\TemplateWrapper::render(['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
14. in /app/vendor/craftcms/cms/src/web/View.php at line 392 – Twig\Environment::render('pdf-transform/settings', ['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
386387388389390391392393394395396397398
// Render and return
$renderingTemplate = $this->_renderingTemplate;
$this->_renderingTemplate = $template;
$e = null;
try {
$output = $this->getTwig()->render($template, $variables);
} catch (\Throwable $e) {
// throw it later
}
$this->_renderingTemplate = $renderingTemplate;
$this->setTemplateMode($oldTemplateMode);
15. in /app/vendor/bymayo/pdf-transform/src/PdfTransform.php at line 144 – craft\web\View::renderTemplate('pdf-transform/settings', ['settings' => bymayo\pdftransform\models\Settings, 'volumes' => [['label' => 'Uploads', 'value' => '1'], ['label' => 'User Photos', 'value' => '2'], ['label' => 'Content images', 'value' => '3']]])
138139140141142143144145146147148149
{
return Craft::$app->view->renderTemplate(
'pdf-transform/settings',
[
'settings' => $this->getSettings(),
'volumes' => PdfTransform::$plugin->pdfTransformService->getVolumeOptions()
]
);
}
}
16. in /app/vendor/craftcms/cms/src/base/Plugin.php at line 217 – bymayo\pdftransform\PdfTransform::settingsHtml()
211212213214215216217218219220221222223
*/
public function getSettingsResponse()
{
$view = Craft::$app->getView();
$namespace = $view->getNamespace();
$view->setNamespace('settings');
$settingsHtml = $this->settingsHtml();
$view->setNamespace($namespace);
/** @var Controller $controller */
$controller = Craft::$app->controller;
return $controller->renderTemplate('settings/plugins/_settings', [
17. in /app/vendor/craftcms/cms/src/controllers/PluginsController.php at line 114 – craft\base\Plugin::getSettingsResponse()
108109110111112113114115116117118119120
$plugin === null &&
($plugin = Craft::$app->getPlugins()->getPlugin($handle)) === null
) {
throw new NotFoundHttpException('Plugin not found');
}
return $plugin->getSettingsResponse();
}
/**
* Enables a plugin.
*
* @return Response
18. craft\controllers\PluginsController::actionEditPluginSettings('pdf-transform', bymayo\pdftransform\PdfTransform)
19. in /app/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([craft\controllers\PluginsController, 'actionEditPluginSettings'], ['pdf-transform', null])
20. in /app/vendor/yiisoft/yii2/base/Controller.php at line 180 – yii\base\InlineAction::runWithParams(['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
21. in /app/vendor/craftcms/cms/src/web/Controller.php at line 190 – yii\base\Controller::runAction('edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
184185186187188189190191192193194195196
/**
* @inheritdoc
*/
public function runAction($id, $params = [])
{
try {
return parent::runAction($id, $params);
} catch (\Throwable $e) {
if ($this->request->getAcceptsJson()) {
Craft::$app->getErrorHandler()->logException($e);
if (!YII_DEBUG && !$e instanceof UserException) {
$message = Craft::t('app', 'A server error occurred.');
} else {
22. in /app/vendor/yiisoft/yii2/base/Module.php at line 528 – craft\web\Controller::runAction('edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
23. in /app/vendor/craftcms/cms/src/web/Application.php at line 274 – yii\base\Module::runAction('plugins/edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
268269270271272273274275276277278279280
* @param string $route
* @param array $params
* @return Response|null The result of the action, normalized into a Response object
*/
public function runAction($route, $params = [])
{
$result = parent::runAction($route, $params);
if ($result !== null) {
if ($result instanceof Response) {
return $result;
}
24. in /app/vendor/yiisoft/yii2/web/Application.php at line 103 – craft\web\Application::runAction('plugins/edit-plugin-settings', ['handle' => 'pdf-transform', 'p' => 'admin/settings/plugins/pdf-trans...'])
25. in /app/vendor/craftcms/cms/src/web/Application.php at line 259 – yii\web\Application::handleRequest(craft\web\Request)
253254255256257258259260261262263264265
if (($response = $this->_processActionRequest($request)) !== null) {
return $response;
}
// If we're still here, finally let Yii do it's thing.
try {
return parent::handleRequest($request);
} catch (\Throwable $e) {
$this->_unregisterDebugModule();
throw $e;
}
}
26. in /app/vendor/yiisoft/yii2/base/Application.php at line 386 – craft\web\Application::handleRequest(craft\web\Request)
27. in /app/web/index.php at line 23 – yii\base\Application::run()
17181920212223
(new Dotenv\Dotenv(CRAFT_BASE_PATH))->load();
}
// Load and run Craft
define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production');
$app = require CRAFT_VENDOR_PATH.'/craftcms/cms/bootstrap/web.php';
$app->run();
`
@Alek2012 You're definitely hitting the case errors. For example:
The file or directory to be published does not exist: /app/vendor/bymayo/pdf-transform/src/assetbundles/pdftransform/dist
As this folder does exist as pdftransform
it now exists as PdfTransform
:
https://github.com/bymayo/craft-pdf-transform/tree/master/src/assetbundles/PdfTransform/dist
I'm going have to speak to Craft about this, as this was their recommendation to fix it for upcoming Composer 2 changes in future Craft versions.
But I imagine if you uninstall the plugin, then reinstall it, it should work. A clean install for me works fine.
@bymayo I think you just need to change this line after your update when init Asset in the PdfTransformAsset.php file
$ this-> sourcePath = "@ bymayo/pdftransform/assetbundles/PdfTransform/dist";
@Alek2012 Argh. Sorry, I had actually fixed that in my dev build but not committed it. Hence why I didn't get the issue!
Pushed this now and added it as version 1.0.15
Can you try again.
@bymayo composer.json requires bymayo/pdf-transform 1.0.15, found bymayo/pdf-transform[dev-master, 1.0.0, ..., 1.0.4] but it does not match the constraint. I think you need to update the version to 1.0.15 instead of 1.0.5 https://github.com/bymayo/craft-pdf-transform/commit/b5cbef98164b8ad40c637f993cf4854a1cd43c00
@Alek2012 Not my day! 😂 Try again.
@bymayo Thanks, it works!
@Alek2012 Amazing, sorry it took so long. I'll need to go through my other plugins now to update this same issue! Thanks.
After installing the plugin, I get an error when trying to go to plugin settings "admin/settings/plugins/pdf-transform"
`
$_GET = [ 'p' => 'admin/settings/plugins/pdf-transform', ];`