Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed array_keys(null) and call to undefined method in Mage_Eav_Model_Config #4036

Merged
merged 5 commits into from
Jun 29, 2024

Conversation

F1Red5
Copy link
Contributor

@F1Red5 F1Red5 commented Jun 9, 2024

Description (*)

Issue 1: array_keys(null) fixed arround line 573.

Issue 2: undifiened method getDefaultAttributes() for invoice, creditmemo, ... fixed arround line 372

Related Pull Requests

  1. See EAV Config Cache #2993

Fixed Issues (if relevant)

  1. See N98-magerun tests fails since #2993 #4034

Manual testing scenarios (*)

  1. install n98/magerun:dev-develop (v3.0.0)
  2. add custom attributes to all entity types
Test script
<?php

require_once('app/Mage.php');
umask(0);
Mage::app();

class Test4034
{
  public function prepare()
  {
      $attributeCode = 'crazyCoolAttribute';
      $data = ['type'  => 'text', 'input' => 'text', 'label' => 'Test Attribute'];

      foreach (self::entityTypeProvider() as $entityType) {
          $this->createAttribute(array_values($entityType)[0], $attributeCode, $data);
      }
  }

  /**
   * From N98-magerun unit test
   */
  public static function entityTypeProvider()
  {
      return [['catalog_category'], ['catalog_product'], ['creditmemo'], ['customer'], ['customer_address'], ['invoice'], ['order'], ['shipment']];
  }

  /**
   * From N98-magerun unit test
   *
   * @param string $entityType
   * @param string $attributeCode
   * @param array $data
   */
  protected function createAttribute($entityType, $attributeCode, $data)
  {
      $setup = Mage::getModel('eav/entity_setup', 'core_setup');
      $setup->addAttribute($entityType, $attributeCode, $data);
  }
}

$test = new Test4034();
$test->prepare();
  1. test eav:attribute:view creditmemo crazyCoolAttribute and eav:attribute:remove creditmemo crazyCoolAttribute

Questions or comments

After adding/removing EAV cache has to be cleaned, but this should be done in N98-magerun. (???) Not sure if it fixes all errors in unit tests, but these two issues should be easy to reproduce.

Todo: add Mage::app()->getCacheInstance()->cleanType('eav');

@github-actions github-actions bot added Component: Eav Relates to Mage_Eav phpstan labels Jun 9, 2024
@F1Red5 F1Red5 changed the title Updated Mage_Eav_Model_Config Fixes array_keys(null) and call to indefined method in Mage_Eav_Model_Config Jun 10, 2024
@fballiano fballiano changed the title Fixes array_keys(null) and call to indefined method in Mage_Eav_Model_Config Fixed array_keys(null) and call to undefined method in Mage_Eav_Model_Config Jun 26, 2024
@kiatng
Copy link
Contributor

kiatng commented Jun 28, 2024

I don't get this:

test eav:attribute:view creditmemo crazyCoolAttribute and eav:attribute:remove creditmemo crazyCoolAttribute

How to test the above?

@fballiano
Copy link
Contributor

I guess it's n98-magerun eav:attribute:view creditmemo crazyCoolAttribute

@fballiano
Copy link
Contributor

magerun build doesn't work on mac and I can't find any doc, I'll blindly review this PR

Copy link
Contributor

@fballiano fballiano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see any problem in merging these minor changes so I'll do

@fballiano fballiano merged commit 1d4fe88 into OpenMage:main Jun 29, 2024
13 checks passed
@sreichel sreichel deleted the update-eav-config branch June 29, 2024 12:28
@sreichel sreichel restored the update-eav-config branch June 29, 2024 12:34
@sreichel sreichel deleted the update-eav-config branch July 1, 2024 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Eav Relates to Mage_Eav phpstan
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants