All Astronauts Posted December 27, 2020 Posted December 27, 2020 (edited) tldr; You can create and name the extension anything you like, just like any other extension. But if you want the extension to actually work, that name can only, exclusively, be "Main". If you name your file anything else for this extension, the extensions.json file will not have the entry added, and even if you add the entry manually to the json file, this will kick out Whoops class not found error as it is apparently not correctly set in the Application object or wherever. If you DO set your class name to Main when creating this extension, everything works as intended. - Add extension for 3rd party app via dev center - Give it a class name of Whatever (so Whatever.php in my app's extension dir) - Edit file - Class name in the auto-gen extension file is _Main, not _Whatever - doesn't matter what you enter, this will always auto-gen to _Main - If you run the extension via the ACP - Members - Member View - download personal data button, nothing occurs, even when you correctly name the function to what you set it as in the dev center - That's because the extensions.json data file entry for this extension is never added when you add this extension via the dev center when you name the class something other than Main - If you manually enter your extension into the json file, clear caches to be safe, and then try again to use the extension via the ACP - Members - Member View - download personal data button... Class 'IPS\core\extensions\core\MemberExportPersonalInformation\Whatever' not found So the json file is correctly being read to engage the extension but elsewhere it does not exist - perhaps/probably in the application obj itself. If I DELETE the extension in the dev center, that DOES remove my-manually-added entry in the json file AND the extension PHP file itself - these would be my not-named Main entry and file. I'd also note you have zero documentation on this extension in the Developers Documentation. Solution: perk up this method so it correctly takes in the set-by-the-developer class name, or, if you are locking this down to just Main, note in dev documentation (once you create some...), though that would mean only a single one of these extensions per-application and I'm not sure if that's the best thing (just my two cents) Edited December 27, 2020 by All Astronauts DawPi and CoffeeCake 2
Solution bfarber Posted December 28, 2020 Solution Posted December 28, 2020 I've raised this internally for consideration.
bfarber Posted December 29, 2020 Posted December 29, 2020 When this was raised internally it was pointed out that the extension for Commerce is named "Customer" and works. Do you have any further information as to why your custom name isn't working?
All Astronauts Posted December 29, 2020 Author Posted December 29, 2020 (edited) I can make a vid if you like, but this is as straight-forward as it seems. Create new extension, name it something, nothing appears in json, doesn't work (obvs) Deleted. Tried again, this time with Main, worked. Did I try again a third time with a non-Main name or an entire new app after I deleted the original and tried again with Main? No. My luck this was a one-off Dev mode hitch... I'll poke it some more EDIT: No need for vid, you can replicate this yourself - this is still broken. I used an app that just had some widgets in it (testing app), and added a new memberExportwhatever extension not named Main ("Workdamnyou"). Added fine, json did NOT build out, the PHP file class is as stated before, _Main and not _Workdamnyou Ok, that's expected, so I added another one. It wanted nothing to do with it at all. In fact, it seemed to think the name I provided ("Jake") was actually Main, and since the previous created extension here got the name _Main, naturally that's a crash: Tis' bugged Edited December 29, 2020 by All Astronauts
Adriano Faria Posted December 29, 2020 Posted December 29, 2020 12 minutes ago, All Astronauts said: Tried again, this time with Main, worked. That’s because it is hardcoded in the template (txt). I reported same issue in another extension in 4.4.0 beta.
All Astronauts Posted December 29, 2020 Author Posted December 29, 2020 2 minutes ago, Adriano Faria said: That’s because it is hardcoded in the template (txt) 🥺 but at least an easy fix
Adriano Faria Posted December 29, 2020 Posted December 29, 2020 applications/core/data/defaults/extension/MemberExportPersonalInformation.txt <?php /** * @brief ACP Export Personal Information * @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a> * @copyright (c) Invision Power Services, Inc. * @license https://www.invisioncommunity.com/legal/standards/ * @package Invision Community {subpackage} * @since {date} */ namespace IPS\{app}\extensions\core\MemberExportPersonalInformation; /* To prevent PHP errors (extending class does not exist) revealing path */ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) ) { header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' ); exit; } /** * @brief ACP Export Personal Information */ class _Main It should be: class _{class} CoffeeCake 1
All Astronauts Posted December 29, 2020 Author Posted December 29, 2020 Quick sweep of that directory shows this file is the only one not using {class}
bfarber Posted December 30, 2020 Posted December 30, 2020 Thanks, I've updated the internal discussion with the extra info.
All Astronauts Posted July 22, 2022 Author Posted July 22, 2022 <gentle prod> I mean, its not the end of the world, I can just change the extension class name to what it should be and add the entry manually to the extensions.json file. Just weird still hitting this.
Adriano Faria Posted July 22, 2022 Posted July 22, 2022 6 hours ago, All Astronauts said: <gentle prod> I mean, its not the end of the world, I can just change the extension class name to what it should be and add the entry manually to the extensions.json file. Just weird still hitting this. Not fixed yet?
Daniel F Posted July 22, 2022 Posted July 22, 2022 Thx, I have fixed the class name in the skeleton file. Adriano Faria, SeNioR- and All Astronauts 2 1
Recommended Posts