3

Any time I run bin/magento setup:upgrade I get Incorrect theme identification key

error

I understand the source is vendor/magento/framework/View/Design/Theme/FlyweightFactory.php so I had added echos to try and figure something out

enter image description here

I get

enter image description here

First pass 1, second pass NULL

Now, would be nice to understand where 1 and NULL come from

mysql> select theme_id, theme_path, area from theme;
+----------+-----------------+-----------+
| theme_id | theme_path      | area      |
+----------+-----------------+-----------+
|        1 | Magento/blank   | frontend  |
|        2 | Magento/backend | adminhtml |
|        3 | Magento/luma    | frontend  |
+----------+-----------------+-----------+
mysql> select * from core_config_data where path like '%theme%';
+-----------+----------+----------+-----------------------+-------+
| config_id | scope    | scope_id | path                  | value |
+-----------+----------+----------+-----------------------+-------+
|        34 | stores   |        1 | design/theme/theme_id | 3     |
|        58 | websites |        1 | design/theme/theme_id | 3     |
|        82 | default  |        0 | design/theme/theme_id | 3     |
+-----------+----------+----------+-----------------------+-------+

Only theme set is 3 (Luma), so I don't get how 1 gets passed. I don't know where the "crontab" area theme is set. Is there anywhere I can set that value so I won't get the error?

Any help is appreciated, happy to provide more info.

7 Answers 7

3
insert into theme VALUES (4, 1, 'Magento/luma', 'Magento Luma Cron', NULL, 0, 'crontab', 0, 'Magento/luma');

This is not recommended but, Try the above it fixed for me.

1
  • 1
    Thank you @Sharath, Unfortunately I can't test it because I can't replicate the issue. I must have made some changes that unintentionally/magically/unrevertably fixed the issue. I am going to accept your answer nonetheless because: a) is the only answer I got in over two months I posted and b) I see what you are doing there and it seems very reasonable. Commented Dec 18, 2019 at 15:23
7

I had this error when running a cron

php bin/magento cronmanager:runjob <cronjob_name>

I just deleted extends Action, Context $context, and parent::__construct($context);

Then:

Error > Incorrect theme identification key

My cron class was

namespace <Vendor>\<Module>\Cron;

use Magento\Backend\App\Action;
use Magento\Backend\App\Action\Context;
use Magento\Framework\Filesystem;

class HelloWorld extends Action
{
protected $_filesystem;

public function __construct(
    Context $context,
    Filesystem $_filesystem
) {
    parent::__construct($context);
    $this->_filesystem = $_filesystem;
}


public function execute()
{
//Some magic
}

Now:

No errors

My cron class is

namespace <Vendor>\<Module>\Cron;

use Magento\Framework\Filesystem;

class HelloWorld
{
protected $_filesystem;

public function __construct(
    Filesystem $_filesystem
) {
    $this->_filesystem = $_filesystem;
}

public function execute()
{
//Some magic
}
1
  • I think this answer should be the best one, it eliminates the issue from the root instead of adding arbitrary patches. at least it's my case and it helps so much. thank you
    – AboElnouR
    Commented Nov 10, 2021 at 11:26
3

Although I have no idea what the core issue is (and probably, as stated by @undefinederror, this is just a symptom of a misconfiguration somewhere else, because the crontab area needing a theme makes little sense to me), I will add that in addition to the new record within the theme table, I also had to override the DI preferences for Magento\Theme\Model\View\Design like so:

    <type name="Magento\Theme\Model\View\Design">
        <arguments>
            <argument name="themes" xsi:type="array">
                <item name="frontend" xsi:type="string">Magento/luma</item>
                <item name="adminhtml" xsi:type="string">Magento/backend</item>
                <!-- fix "Incorrect theme identification key" -->
                <item name="crontab" xsi:type="string">Magento/luma</item>
            </argument>
        </arguments>
    </type>
2
  • Where this should be placed?
    – Kirby
    Commented Sep 24, 2020 at 18:03
  • magento/module-theme/etc/di.xml
    – ioan
    Commented Oct 16, 2020 at 11:11
1

I have come across this issue on vanilla Magento 2.3.4-p2 with Smile ElasticSuite. The tldr is here https://github.com/Smile-SA/magento2-module-elasticsuite-cms-search/issues/30#issuecomment-601791232

And the patch/fix is here https://github.com/Smile-SA/magento2-module-elasticsuite-cms-search/commit/cd07d0d1b021dfecb79eff62c210a2b8416e82e8

1
  • Now that I think of it I too had the elasticsuite module installed Commented Oct 17, 2020 at 12:09
0

I too came across this issue but the description of the error isn't entirely helpful. I had these errors in my cron_schedule table for cron jobs I had built into a controller class. Looks like Magento 2.4.2 doesn't like you doing that so I moved the code to be in its own class (not extending from anything) and voila errors gone.

0

This is exactly the solution on Magento 2.4.X, the problem is linked to a Cron job class which extends another or not placed in the Cron folder but rather in another folder like Controller/ or Helper/ ... in short , we must remember here is that we must respect the good development practices in Magento if we want to avoid this type of problem. For me, I have the same issue, solution of @brjupo and @Marting Peasly fix my problem.

0

I got the same error, my issue was not in the cron itself, one part of my cron execution, it excuted a method that the class extends \Magento\Backend\App\Action... Probably it happens because cron has a crontab set area, and I needed a adminhtml area.

Which is sad because I wanted to get the current User to set on a grid. If someone knows how to troubleshot this, I would appreciate.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.