Update to 3.7.3 - load() undefined

Hello! :slight_smile:
Due to my host deactivating PHP 7.4 soon, I need to update my Kirby 3.4.3 to at least 3.5. But the website has a custom built plugin. When updating, I get an error Call to undefined function load() on this plugin. However, the load() function is still mentioned in the 3.7.3 docs and it’s not mentioned in the deprecated warnings for 3.5, so I guess the error message is not correct.

Does anyone know what to fix in my selfmade plugin to get it running in 3.5/upwards?

Greetings,

Jonas

Please post the exact error message with stack trace.

Replaced some parts of the path with"xxxxxx" - not part of the Stacktrace of course.

Error thrown with message “Call to undefined function load()”

Stacktrace:
#6 Error in /is/htdocs/xxxxxx/www/site/plugins/orderonline/index.php:7
#5 include_once in /is/htdocs/xxxxxx/www/kirby/src/Filesystem/F.php:453
#4 Kirby\Filesystem\F:loadOnce in /is/htdocs/xxxxxx/www/kirby/src/Cms/AppPlugins.php:899
#3 Kirby\Cms\App:pluginsLoader in /is/htdocs/xxxxxx/www/kirby/src/Cms/AppPlugins.php:866
#2 Kirby\Cms\App:plugins in /is/htdocs/xxxxxx/www/kirby/src/Cms/AppPlugins.php:743
#1 Kirby\Cms\App:extensionsFromPlugins in /is/htdocs/xxxxxx/www/kirby/src/Cms/App.php:138
#0 Kirby\Cms\App:__construct in /is/htdocs/xxxxxx/www/index.php:5

Hm, could you also please code that causes the error? And which exact kirby version are you using?

Right now it is 3.4.3 as mentioned above and I need to switch to at least 3.5.

Here is the index.php of my plugin:

<?php

/**
 * See composer.json for meta info.
 */

 load([
     'webdev\\orderonline\\processor' => '/src/Processor.php',
     'webdev\\orderonline\\spamProtector' => '/src/SpamProtector.php',
     'webdev\\orderonline\\dbConnector' => '/src/DbConnector.php',
     'webdev\\orderonline\\mailer' => '/src/Mailer.php'
 ], __DIR__);

 Kirby::plugin('webdev/orderonline', [
  'snippets' => [
   'orderonline/form' => __DIR__ . '/snippets/form.php'
  ],
  'templates' => [
      'emails/order.html' => __DIR__. '/templates/emails/order.html.php',
      'emails/order.text' => __DIR__. '/templates/emails/order.text.php'
   ],
  'routes' => [
    [
      'pattern' => '(?:(:any)//?)?order',
      'action'  => function() { return Webdev\Orderonline\Processor::recipeOrder(); },
      'method' => 'POST'
    ],
    [
      'pattern' => '(?:(:any)//?)?archivieren',
      'action'  => function() { 
        if (kirby()->user()) {
          Db::update('orderonline', ['archiv' => '1'], ['id' => get('archive_id')]); go('/panel/site#order');
        }
    },
      'method' => 'GET'
    ],
    [
      'pattern' => '(?:(:any)//?)?archiviere_alles',
      'action'  => function() { 
        if (kirby()->user()) {
          Db::delete('orderonline'); go('/panel/site#order');
        }
    },
      'method' => 'GET'
    ]
  ],
  'fields' => [
          'orderview' => [
            'props' => [
              'data' => function () {
                return Db::first('orderonline', '*', 'archiv like "0"');
              },
              'data_archived' => function () {
                return (string) Db::count('orderonline', 'archiv LIKE "1"');
              }
            ]
          ]
      ],
  'translations' => [
    'de' => [
      'onlineorder.vorname' => 'Vorname',
      'onlineorder.nachname' => 'Nachname',
      'onlineorder.geburtsdatum' => 'Geburtsdatum',
      'onlineorder.tag' => 'Tag',
      'onlineorder.monat' => 'Monat',
      'onlineorder.jahr' => 'Jahr',
      'onlineorder.mailadresse' => 'Mail-Adresse',
      'onlineorder.telefon' => 'Telefon',
      'onlineorder.max_anzahl_erreicht' => 'Maximale Anzahl erreicht',
      'onlineorder.weitere_informationen' => 'weitere Informationen',
      'onlineorder.pruefcode' => 'Prüfcode Spamschutz',
      'onlineorder.bestellung_absenden' => 'Bestellung absenden'
    ],
    'en' => [
      'onlineorder.vorname' => 'Firstname',
      'onlineorder.nachname' => 'Lastname',
      'onlineorder.geburtsdatum' => 'Birthday',
      'onlineorder.tag' => 'Day',
      'onlineorder.monat' => 'Month',
      'onlineorder.jahr' => 'Year',
      'onlineorder.mailadresse' => 'Mail-address',
      'onlineorder.telefon' => 'Phone',
      'onlineorder.max_anzahl_erreicht' => 'Maximum reached',
      'onlineorder.weitere_informationen' => 'more information',
      'onlineorder.pruefcode' => 'Spam checkcode',
      'onlineorder.bestellung_absenden' => 'Send Order'
    ]
  ]
]);

Yes, but I need to know the Kirby version that throws the error, according to the stack trace, you are not testing on 3.5.x but a later version.

Ah, you are right. I thought i downloaded 3.5 since I hoped this will not break too many things on my installation but it redirected me to 3.7.3, so that’s what I moved to the server.

@texnixe: Ich weiß, ihr hattet einen größeren Fix vor euch und habe deshalb etwas gewartet, aber hättest du zu diesem Problem eventuell noch eine Idee? :innocent:

The load() method was not removed. One change was that those methods were moved into the Helpers class (so in the future, you would call the method with Helpers::load()`), but using the method like before is still valid.

So again, you are using 3.7.3 with which PHP version?

what other plugins do you have installed?

This problem must be caused by something else. Have you made sure that all files have been properly uploaded to the server, the media folder and all caches emptied? Have you tested the site locally before putting everything on the server?

It seems that some composer packages where missing. It works now, thanks!