Developed built extension doesn't show in prod

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rehida1750
    Junior Member
    • Mar 2025
    • 5

    Developed built extension doesn't show in prod

    I have built an extension that adds 2 bool filters to leads using the ext-template. It works fine in the dev env. When I build it `npm run extension` and upload the zip to prod, the extension is correctly uploaded and installed, and I can see on the prod server the files are there. However, the filters do not show on the prod site at all (they show on the dev site though).

    Cleared cache and even restarted PHP. Also ran the rebuild command. Logs are empty. What else should I try?
  • rehida1750
    Junior Member
    • Mar 2025
    • 5

    #2
    Here's what I've noted so far:

    The AfterInstall script does run when the extension is installed,
    PHP Code:
    $this->container->get('dataManager')->clearCache(); 
    because we can see the cache being cleared and updated. In the metadata.php and objMetadata.php, the boolFilterClassNameMap is correctly added:
    PHP Code:
    'ReceivedEmailFrom' => 'Espo\\Modules\\CustomCRMExtension\\Select\\Lead\\BoolFilters\\ReceivedEmailFrom',
    'NotReceivedEmailFrom' => 'Espo\\Modules\\CustomCRMExtension\\Select\\Lead\\BoolFilters\\NotReceivedEmailFrom'
    .

    What seems NOT to be in the cache though, is the `boolFilterList` - I think it should have added entries like
    PHP Code:
    => ['name' => 'ReceivedEmailFrom'], 
    , but it does not. It does seem to be added in the DEV env though. Manually adding those entries in prod (just for testing) doesn't seem to do anything either.

    Still investigating. Any pointers would be very helpful. Anyone face this before?
    Last edited by rehida1750; 03-07-2025, 10:59 AM. Reason: Desc

    Comment

    • rehida1750
      Junior Member
      • Mar 2025
      • 5

      #3
      Okay, I think I've found a bug:

      When I have code in custom/Espo/Custom, and a module in custom/Espo/Modules/{modulename} - it seems that the former overrides the latter. When I removed the former, the latter was correctly shown and added to the boolFilterList and works as expected now...

      Comment

      • rehida1750
        Junior Member
        • Mar 2025
        • 5

        #4
        Is it expected that you can't mix Custom code and extensions?

        Comment

        • yuri
          Member
          • Mar 2014
          • 8792

          #5
          > I think I've found a bug

          No bug here. Sigh...



          Metadata is merged. custom/Espo/Custom/Resources/metadata/ is applied the last.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment


          • rehida1750
            rehida1750 commented
            Editing a comment
            I expected it to merge, as you say, but it was overwritten instead, even though the keys and values were completely different and unrelated.

          • rehida1750
            rehida1750 commented
            Editing a comment
            Specifically, the clientDefs were overwritten and not present in the final metadata cache, whereas the selectDefs for example were correctly merged. What am I missing?
        • yuri
          Member
          • Mar 2014
          • 8792

          #6
          Merged and overwritten by design. The custom has the highest priority. We have this logic for 10+ years, many extensions where written and many work in production relying on this logic

          Keys are not supposed to be erased upon merging. Arrays are overridden, but it's documented how to merge arrays.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment


          • rehida1750
            rehida1750 commented
            Editing a comment
            So to keep them from being erased, I need in my custom clientDefs/Lead (custom/Espo/Custom/Resources/metadata/):

            {
            "boolFilterList": [
            "__APPEND__",
            {
            "name": "CustomFoo"
            },
            {
            "name": "CustomBar"
            }
            ]
            }

            Is this correct?

          • rabii
            rabii commented
            Editing a comment
            If those are new filters that don't exist you can just append them in your extension and they should be added.
        • rehida1750
          Junior Member
          • Mar 2025
          • 5

          #7
          rabii yeah thats the issue, I expected them to be "added", instead they were overwritten. It seems to ONLY have happened with the clientDefs - the rest of the metadata was correctly added/appended as expected. Strange no?

          Comment

          Working...