Coder Social home page Coder Social logo

craft's People

Contributors

angrybrad avatar augustmiller avatar benjamindavid avatar brandonkelly avatar carlcs avatar cromwellryan avatar geenious avatar jasonmccallister avatar khalwat avatar leevigraham avatar mildlygeeky avatar olivierbon avatar saboteur777 avatar tam avatar timkelty avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

craft's Issues

config.platform.php overrides system PHP version

Composer's config.platform.php is set to 7.0 by default. This overrides the system's PHP Version, and prevents dependencies that requires newer versions of PHP from being installed.

Why is it set at all?

Template not found: dashboard

Hello,

I followed all instructions on the documentation to install craft.

Everything worked until I do: ./craft serve/index and then go to the specified URL. I get "Template not found: dashboard"

The templates directory only has an index.html file in it. Is this the problem?

Any ideas?

Use alias for site url based on root url defined as env var?

Hi,

I was wondering if the following setup is a good practice.

In my .env file I defined a single rootUrl var which contains the site root url like this:

ROOT_URL="https://www.mydomain.test"

In the general.php config file i've created an alias (@rootUrl) that contains the ROOT_URL env var value:

'aliases' => [ '@rootUrl' => getenv('ROOT_URL'), ],

Then I define my craft sites as following (multilingual site), each site BASE URL is constructed with the rootUrl and a language:

Schermafbeelding 2019-03-22 om 08 39 32

Advantages

  • You don't have to define every site (language) in the code, languages are managed through the cms (in case of multisite setup, you should define a ROOT_URL for every site).
  • the @rootUrl alias can be used as part of the resource path in the templates.

Disadvantages

Does this logic makes sense or is it generally a bad idea to use aliases for the site BASE URL setting?

Thanks in advance,
Thomas

[Suggestion] Add type declaration for (extra)AllowedFileExtensions etc

When you add a file extension to the allowed uploads/assets but output {{ file.type }} it can return 'undefined'. I propose that the config setting for allowedFileExtensions and extraAllowedFileExtensions be in the format ['extension'=>'type', … ] where type is optional or make it an array of tuples [['ext'.'type'],['ext,'type']], whatever implementation you like for backwards compatibility.

for example…

'extraAllowedFileExtensions' => [
    'pub' => 'publisher', 
    'bz'  => 'compressed'
]

// tuple-style
'extraAllowedFileExtensions' => [
    ['pub', 'publisher'], 
    ['bz', 'compressed'],
]

perhaps this can be extended to include mimetypes too to add to Yii's getMimeTypeByExtension helper that it looks like Craft uses.

CraftConnector getEmails

Hi,

I'm trying to setup acceptante tests using Codeception and email part of craft\test\Craft module.

However, when using the seeEmailIsSent assertion, the following Exeception is thrown:
[TypeError] Return value of craft\test\CraftConnector::getEmails() must be of the type array, null returned

For some reason, the return statement doesn't seem to return the expected array.

I've tried various mailer configurations with no success.

HTTP 503 – ServiceUnavailableHttpException

I'm trying to install CraftCMS (with composer create-project method) for the first time, and appear to have gone through all the steps on the installation guide - https://docs.craftcms.com/v3/installation.html#step-1-download-craft - yet I'm getting an Exception.

HTTP 503 – Service Unavailable – craft\web\ServiceUnavailableHttpException

Here is the line (509 in /var/www/craft/vendor/craftcms/cms/src/web/Application.php) that's throwing the exception:

// Should they be accessing the installer?
if (!$isInstalled) {
    if (!$isCpRequest) {
        throw new ServiceUnavailableHttpException();
    }

Below is the call stack:

craft\web\ServiceUnavailableHttpException in /var/www/craft/vendor/craftcms/cms/src/web/Application.php:509
Stack trace:
#0 /var/www/craft/vendor/craftcms/cms/src/web/Application.php(184): craft\web\Application->_processInstallRequest(Object(craft\web\Request))
#1 /var/www/craft/vendor/yiisoft/yii2/base/Application.php(386): craft\web\Application->handleRequest(Object(craft\web\Request))
#2 /var/www/craft/web/index.php(21): yii\base\Application->run()
#3 {main}

I'm using v3.0.24 as far as I can see:

- Installing craftcms/cms (3.0.24): Downloading (100%)

As I haven't even got started with the CMS, I don't really know what more info to give - or where to go from here. The .env file has been copied, there really is no more instruction to do anything. Any ideas?

Consider renaming craftcms/craft

After working with Craft 3 for a while and contributing to craftcms/cms a bit recently, I know the difference between craftcms/craft and craftcms/cms.

However, for newcomers to Craft 3 and to composer in general, the very similar package naming can be confusing. If the name of the package would reflect the purpose it would help. Here are my suggestions:

  • craftcms/skeleton
  • craftcms/project
  • craftcms/starter

Installation error on 1.0.43.2

Running composer create-project craftcms/craft [directory] currently throws a DbConnectException.

setup/welcome is trying to access the DB, which of course wouldn't be available yet. Here's the full error + stack trace, after composer finishes autoload generation.

Package Version: 1.0.43.2
OS X 10.13.6

.env file is required in any environment

This call (new Dotenv\Dotenv($root))->load() fails when no .env file is present. Here is the exception:

Uncaught Dotenv\Exception\InvalidPathException: Unable to read the environment file

It's used in web/index.php and in the craft binary. There are two workarounds I can think of:

  1. Catch the Exception, like Lumen does
  2. Load the .env file only under specific condition, like getenv('CRAFT_ENV') != 'production'

Consider adding configuration for Docker?

This is not really an issue, more of a discussion.

Would adding a Dockerfile or docker-compose.yml be an option/pull request that would be considered? Meaning that if a docker-compose.yml file, that contained an official PHP, MySQL and Postgres configuration, were to be added to this repository - would this be worth it to anyone?

Even if the end result is that the developer/project/installer decides not to use Docker, it would be a painless addition and take a minimal amount of effort to remove from their installation.

A quick example, not tested at all, would be a docker-compose.yml file that looks something like this:

version: '2'
services:

    craftcms:
        image: php/7.0-apache
        ports:
            - "80:80"
        depends_on:
            - mysql-server
        links:
            - mysql-server
        volumes:
            - ".:/var/www"
        env_file: .env

    mysql-server:
        image: mysql/5.7
        ports:
            - "3306:3306"
        volumes:
            - "./storage/database:/var/lib/mysql"
        environment:
            MYSQL_ROOT_PASSWORD: SuperLongPassword!
            MYSQL_DATABASE: dev_craftcms
            MYSQL_PASSWORD: Password1!
            MYSQL_USER: craftcms
            MYSQL_ALLOW_EMPTY_PASSWORD: "no"

Physically removed asset breaks assets loading and any content page which includes it

Description

Getting error message "craft\services\Assets::getThumbUrl(): Return value must be of type string, null returned" when trying to open a cp page which should have access to an asset with broken index if the rendered preview is not present

Steps to reproduce

  1. move or delete an asset from the indexed path
  2. remove preview folders (not sure how those should be referred to, attaching a screenshot of them below)
  3. try to access asset index, or element (including global) containing a field with the asset

Additional info

  • Craft version: 4.0.1
  • PHP version: 8.0.13|8.0.18
  • Database driver & version: Ver 8.0.27-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))|Ver 8.0.29-0ubuntu0.20.04.3 for Linux on x86_64 ((Ubuntu))
  • Plugins & versions: verbb/navigation 2.0.0, spicywebau/craft-neo 3.x-dev, craftcms/redactor 3.0.x-dev, nystudio107/craft-seomatic 4.0.0-beta.8

image

What are the Craft 3 `craft/storage` gitignore recommendations?

What are the gitignore recommendations for Craft 3? I'm especially wondering about craft/storage/userphotos and craft/storage/logo

https://craftcms.com/support/craft-storage-gitignore recommends ignoring craft/storage/backups/, craft/storage/runtime/, and craft/storage/userphotos/, and keeping craft/storage/rebrand/ — so,

/craft/storage/*
!/craft/storage/rebrand

But the latest craft/storage/.gitignore has

backups
logs
runtime

which keeps craft/storage/userphotos.

Meanwhile various sources (notably https://github.com/github/gitignore/blob/master/CraftCMS.gitignore, citing what I guess must be an old version of the documentation linked above) recommend keeping craft/storage/logo and ignoring craft/storage/rebrand with

/craft/storage/*
!/craft/storage/logo/*

Can't switch sites in Globals on 4.5.X

Description

Site-switcher doesn't switch for Globals in 4.5.X

Steps to reproduce

  1. Update to 4.5.X and a multisite installation
  2. Try to switch sites

Additional info

  • Craft version: 4.5.X
  • PHP version: 8.1
  • Database driver & version:
  • Plugins & versions:

How fix this

After open some in admin area

Invalid Configuration – yii\base\InvalidConfigException
Unsupported DB driver value:

allow_admin_changes=false blocks settings for tables

When disabling allow_admin_changes in general.php and syncing settings with project.yaml the window for moving/adding/removing columns in tables are empty and the text "An unknown error occurred" appears at the top of the screen.

selection_031

Pressing the gear wheel results in an empty box:

selection_032

allowAdminChanges => false and other "better" defaults for production settings in general.php

I'd like to suggest the following change for the default general.php file that ships with Craft CMS:

Current

    // Production environment settings
    'production' => [
        // Set this to `false` to prevent administrative changes from being made on production
        'allowAdminChanges' => true,
    ]

Suggest change

return [
    'production' => [
        'devMode'           => false,
        'allowAdminChanges' => false,
        'allowUpdates'      => false,
    ],
]

Why?

The suggested change is making sure that best practices are set by default.

allowAdminChanges

The Craft documentation states:

Disable the allowAdminChanges config setting on all non-development environments, to avoid losing changes unexpectedly going forward.

devMode

As far as I understand devMode, this should also be set to false in production, as it might leak information on the system outside, like printing debugging information instead of a nicely designed error.

allowUpdates

Last not least, I think the same applies for the updates. To make sure updates work as expected and that the local environment is sync with production, updates should best first be run locally. And for sure by a developer and not the client (I know there are permissions as well but better make sure).

Why not?

I don't know. I tried to think about some cases … I can imagine that maybe less experienced developers who do not have an advanced setup including multiple environments could potentially get locked out of getting updates. But having multiple environments is optional. It's not required to set up something for production. It's just when there is something like production, let's set some good defaults right away.

Why am I asking this?

Shameless plug: We at fortrabbit pre-populate ENVIRONMENT=production with the ENV vars on our Apps. Now having "better" (<- our opinion) defaults would help us with some issues we are facing in support. Not all clients are following our guides and so they end up making different changes in productions and locally and that can turn into a hustle.

It would great if there are no changes that need to be made in general.php for a good setup.

Can't run craft command with modules enabled

Related to issue #9

Craft version: 3.1.6.1

When you have one or more modules defined in config/app.php, the ./craft command throws an error:

Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @modules/controllers'

in .../vendor/yiisoft/yii2/BaseYii.php:154

It doesn't matter if the module has logic or not.
It's reproducable by just following the instructions to create a module.

https://docs.craftcms.com/v3/extend/module-guide.html#update-the-application-config

Security Key isn’t optional

It would be nice if there was a note in the .env and config/general.php files that setting a security isn’t optional.

Security key variable removed from config/general.php

Description

Hi there,

In this commit:
34e84a1

You have removed the var:
'securityKey' => App::env('CRAFT_SECURITY_KEY'),

And I can't find any documentation to explain why this change has been made. I understand that you've renamed all the .env vars that are created to have a CRAFT_ prefix, but where is the security key now referenced? Is it just an assumed global type thing?

Servd (the hosting company) currently inject a SECURITY_KEY variable into a dynamic .env file, so I've let them know it should have a CRAFT_ prefix, as I was getting this deprecation warning on their servers:

"The auto-generated validation key stored at /var/www/html/storage/runtime/validation.key has been deprecated. Copy its value to the securityKey config setting in config/general.php."

Additional info

  • Craft version: 4.0.4
  • PHP version: 8.0.17

Best practices for `license.key` in terms of `.gitignore`?

According to More Information than You Require About Craft License Keys:

Don’t give anyone access to the license.key file that you don’t trust or owe money to! Remember that everyone that has access to the license key can easily transfer it to a new domain.

That being the case, what's the best practices in terms of checking license.key into your git repository?

Obviously public would be a bad idea, but private seems on par with checking in your passwords or access tokens?

The .gitignore file for this starter repo doesn't specifically exclude license.key so I figured I'd ask...

License Issue

Running the latest 3.0.0-RC16.1

Originally I had another site' license implemented on a new site. I then wiped it out to get rid of the persistent warning. Since then my client purchased the license on staging. But now I'm getting You’re running Craft Pro with a Craft Personal license. Resolve. Upon clicking resolve the license warning goes away only to keep coming back at random times. I click Resolve then it show Pro has been purchased and Installed.

screen shot 2018-03-26 at 10 17 54 am
screen shot 2018-03-26 at 10 18 01 am

What can be done to resolve this?

Trouble populating Plugin Field (Neo) while running through Codeception

Description

I'm running into an issue where neo fields don't seem to populate while trying to run through Codeception. I've dug into this but haven't nailed down the exact issue; any ideas or help would be most appreciated.

Steps to reproduce

There's an example repo you should be able to use to replicate the issue here: https://github.com/khamer/craftdemo-custom-fields-with-codeception

You should be able to configure that to run locally based on your development environments. If all is well, you should be able to run the codeception functional test ExampleCest and see "Test redactor in matrix" work but "Test redactor in neo" fail.

Having dug into this for a while, I believe the value isn't even being populated into the Entry even before it's saved. I think that's happening because it looks like for that to work, the generated tests/craft/storage/runtime/compiled_classes/CustomFieldBehavior***********.php file would need to have a reference to the relevant neo field - in this case, neoContent - but I only see bodyContent in the generated file. I think at the time of generating this file, for whatever reason the neo fields aren't within the fields table yet; and that's as far I've gotten.

It doesn't seem to be an issue for Matrix fields or the craftcms/redactor plugin's fields. I'll ask the spicyweb guys too, but I'd love to get this solved because this blocks us being able to do automated testing on sites using Neo, and I'm not sure if they're using Neo with codeception anywhere yet.

Additional info

  • Craft version: 3.7.30.1
  • PHP version: 8.0
  • Database driver & version: mariadb 15.1
  • Neo plugin version: 2.12.4

Allow existing environment variables to be overridden

Description

It's pretty common to have a setup like Docker which will inject environment variables into the containers... with Craft's default craftcms/craft boilerplate, the phpdotenv package is called thusly:

// Load dotenv?
if (class_exists('Dotenv\Dotenv')) {
    Dotenv\Dotenv::createUnsafeImmutable(CRAFT_BASE_PATH)->safeLoad();
}

Unfortunately, this means if I want to edit an .env variable at runtime to test something, I need to spin the containers down, and then restart them, because createUnsafeImmutable() causes it to be unable to overwrite existing environment variables

I may be missing a use-case, but I'd think it'd be pretty common/desirable that what is in your .env can override environment variables that are already injected. The proposed change would be:

// Load dotenv?
if (class_exists('Dotenv\Dotenv')) {
    Dotenv\Dotenv::createUnsafeMutable(CRAFT_BASE_PATH)->safeLoad();
}

The default, btw, if you use ::create() is to use the mutable method... which makes me think there might be a specific reason why immutable was used?

I didn't create a PR, because it's relatively trivial, and also I'm guessing there are strong opinions backing up the current way of doing it?

Steps to reproduce

  1. Have an environment variable already set via Docker or Nginx or whatever
  2. Try to override that environment variable by changing the same variable in your .env file
  3. Cry

Additional info

  • Craft version: n/a
  • PHP version: n/a
  • Database driver & version: n/a
  • Plugins & versions: n/a

Saving an Entry with a dynamic title that gets too long will throw only a general warning

I have an entry type where the title field is set to the value of the copy field ({copy}). When I try to save an entry that has quite a bit of copy text, Craft will just get back to me with a general error "Couldn’t save entry", but without any hint why.

It’s an easy fix by having {copy|slice(0,20)} as the title value, but I’d expect Craft to give me a more informative message like "title is too long" or something alike.

Craft 3 RC3

What are the Craft 3.5 craft/config/project gitignore recommendations?

On upgrading from Craft 3.4 to 3.5 I've got many folders and yaml's (alongside the craft/config/project/project.yaml).
Can they be put to .gitignore or what are the recommendations for updating .gitignore on upgrade?
(F.ex. I manually upgraded the craft/storage .gitignore file on the 3.5 upgrade.)

500 error on saving an edited asset

On saving an edited asset (admin/actions/assets/save-image), I get a 500 error, with the following message:

Call to undefined method Imagine\Gd\Image::getImagick()

bootstrap'ing modules causes Yii Debug Toolbar to not load

If you implement a module as per the example:

    // All environments
    '*' => [
        'modules' => [
            'my-module' => modules\Module::class,
        ],
        'bootstrap' => ['my-module'],
    ],

This will cause the Yii Debug toolbar to no longer load, presumably because the 'bootstrap' gets stomped on.

CP Trigger Path Returns 404

Description

When using a custom cpTrigger path and having the CMS in headless mode the cpTrigger path returns a 404. It does not redirect to /login or /dashboard like it did previously.

Steps to reproduce

  1. Setup the CMS with a custom cpTrigger path.
  2. Put the CMS in headless mode.
  3. Go to the cpTrigger path.
  4. It displays a JSON 404 response.

Additional info

  • Craft version: 3.5.11.1
  • PHP version: 7.2
  • Database driver & version: MySQL 5.7

Defaults for command line install

Hey folks, I don't know if this belongs here or in the cms repo, but here's an FR for the command line installer:

Could it be possible to create defaults for Site Name and Site URL based on the existence of those settings in the .env file? Just like the Database seems to pull from the DB settings in .env, it would be great to be able to bypass those by having {siteName} and {siteUrl} populated by default.

Even better, for the sake of easier automation, it would be great to be able to run ./craft setup with all of the questions answered through command line arguments. For example, you could run ./craft setup --site_url="{siteUrl}" --site_name="{siteName}" etc... to bypass all of the questions altogether.

install-bg.png image 404 on fresh install

Description

On a fresh install of Craft, I'm getting a 404 error trying to load install-bg-1920.png on the default index page. I see a file installer-bg.png in my cpresources directory, so perhaps just a file name didn't get updated from "install" to "installer"?

Steps to reproduce

  1. Install Craft via Composer using the instructions in the Craft 3 documentation
  2. Load index page in a browser.

Additional info

  • Craft version: 3.4.8
  • PHP version: 7.3.8
  • Database driver & version: MySQL 5.7.26
  • Plugins & versions: N/A

Exception 'yii\base\InvalidParamException' with message 'Invalid path alias: @modules/controllers'

When trying to use the ./craft command I get the this error on a freshly installed RC1 system.

Exception 'yii\base\InvalidParamException' with message 'Invalid path alias: @modules/controllers'

in /home/user/source/vendor/yiisoft/yii2/BaseYii.php:154

Stack trace:
#0 /home/user/source/vendor/yiisoft/yii2/base/Module.php(257): yii\BaseYii::getAlias('@modules/contro...')
#1 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(250): yii\base\Module->getControllerPath()
#2 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(245): yii\console\controllers\HelpController->getModuleCommands(Object(modules\Module))
#3 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(179): yii\console\controllers\HelpController->getModuleCommands(Object(craft\console\Application))
#4 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(191): yii\console\controllers\HelpController->getCommands()
#5 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(286): yii\console\controllers\HelpController->getCommandDescriptions()
#6 /home/user/source/vendor/yiisoft/yii2/console/controllers/HelpController.php(67): yii\console\controllers\HelpController->getDefaultHelp()
#7 [internal function]: yii\console\controllers\HelpController->actionIndex(NULL)
#8 /home/user/source/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#9 /home/user/source/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
#10 /home/user/source/vendor/yiisoft/yii2/console/Controller.php(135): yii\base\Controller->runAction('', Array)
#11 /home/user/source/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('', Array)
#12 /home/user/source/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('', Array)
#13 /home/user/source/vendor/yiisoft/yii2/console/Application.php(147): yii\console\Application->runAction('', Array)
#14 /home/user/source/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
#15 /home/user/source/craft(22): yii\base\Application->run()
#16 {main}

If i return an empty array in config/app.php instead of the default it seems to work

return [];

Instead of:

return [
    'modules' => [
        'my-module' => \modules\Module::class,
    ],
    //'bootstrap' => ['my-module'],
];

Add "RewriteBase /" to .htaccess file

On one of the servers i installed Craft, subpages didnt opened (only index.php) unless I added RewriteBase / to .htaccess file.

Maybe this should be added to default Craft .htaccess file?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.