• Resolved olliemm

    (@olliemm)


    I may struggle to phrase this right, but my Amelia plugin is giving us an error that’s causing us to not be able to access or edit pages from the dashboard, and causes a critical error on the site’s scheduling pages. I deactivated the plugin for now so that we can continue to work on other pages, but I’m trying to get this worked out today so we can schedule appointments again.
    The error message I received says

    An error of type E_COMPILE_ERROR was caused in line 146 of the file /home4/cuiypbmy/public_html/noblessausa/wp-content/plugins/ameliabooking/vendor/slim/slim/Slim/Container.php. Error message: Declaration of Slim\Container::has($id) must be compatible with Psr\Container\ContainerInterface::has(string $id): bool

    I’m in our cPanel file manager and I’ve got (I think) the correct Container.php and ContainerInterface.php files pulled up. I’m not sure what I’m meant to be changing, or in which file.

    This is the Container.php file

    
    <?php
    /**
     * Slim Framework (https://slimframework.com)
     *
     * @license https://github.com/slimphp/Slim/blob/3.x/LICENSE.md (MIT License)
     */
    
    namespace Slim;
    
    use ArrayAccess;
    use Psr\Container\ContainerInterface;
    use Psr\Container\ContainerExceptionInterface;
    use InvalidArgumentException;
    use Pimple\Container as PimpleContainer;
    use Slim\Exception\ContainerException as SlimContainerException;
    use Slim\Exception\ContainerValueNotFoundException;
    
    /**
     * Slim's default DI container is Pimple.
     *
     * Slim\App expects a container that implements Psr\Container\ContainerInterface
     * with these service keys configured and ready for use:
     *
     *  <code>settings</code>          an array or instance of \ArrayAccess
     *  <code>environment</code>       an instance of \Slim\Http\Environment
     *  <code>request</code>           an instance of \Psr\Http\Message\ServerRequestInterface
     *  <code>response</code>          an instance of \Psr\Http\Message\ResponseInterface
     *  <code>router</code>            an instance of \Slim\Interfaces\RouterInterface
     *  <code>foundHandler</code>      an instance of \Slim\Interfaces\InvocationStrategyInterface
     *  <code>errorHandler</code>      a callable with the signature: function($request, $response, $exception)
     *  <code>notFoundHandler</code>   a callable with the signature: function($request, $response)
     *  <code>notAllowedHandler</code> a callable with the signature: function($request, $response, $allowedHttpMethods)
     *  <code>callableResolver</code>  an instance of \Slim\Interfaces\CallableResolverInterface
     */
    class Container extends PimpleContainer implements ContainerInterface
    {
        /**
         * Default settings
         *
         * @var array
         */
        private $defaultSettings = [
            'httpVersion' => '1.1',
            'responseChunkSize' => 4096,
            'outputBuffering' => 'append',
            'determineRouteBeforeAppMiddleware' => false,
            'displayErrorDetails' => false,
            'addContentLengthHeader' => true,
            'routerCacheFile' => false,
        ];
    
        /**
         * @param array $values The parameters or objects.
         */
        public function __construct(array $values = [])
        {
            parent::__construct($values);
    
            $userSettings = isset($values['settings']) ? $values['settings'] : [];
            $this->registerDefaultServices($userSettings);
        }
    
        /**
         * This function registers the default services that Slim needs to work.
         *
         * All services are shared, they are registered such that the
         * same instance is returned on subsequent calls.
         *
         * @param array $userSettings Associative array of application settings
         *
         * @return void
         */
        private function registerDefaultServices($userSettings)
        {
            $defaultSettings = $this->defaultSettings;
    
            /**
             * This service MUST return an array or an instance of ArrayAccess.
             *
             * @return array|ArrayAccess
             */
            $this['settings'] = function () use ($userSettings, $defaultSettings) {
                return new Collection(array_merge($defaultSettings, $userSettings));
            };
    
            $defaultProvider = new DefaultServicesProvider();
            $defaultProvider->register($this);
        }
    
        /**
         * Finds an entry of the container by its identifier and returns it.
         *
         * @param string $id Identifier of the entry to look for.
         *
         * @return mixed
         *
         * @throws InvalidArgumentException         Thrown when an offset cannot be found in the Pimple container
         * @throws SlimContainerException           Thrown when an exception is
         *         not an instance of ContainerExceptionInterface
         * @throws ContainerValueNotFoundException  No entry was found for this identifier.
         * @throws ContainerExceptionInterface      Error while retrieving the entry.
         */
        public function get($id)
        {
            if (!$this->offsetExists($id)) {
                throw new ContainerValueNotFoundException(sprintf('Identifier "%s" is not defined.', $id));
            }
            try {
                return $this->offsetGet($id);
            } catch (InvalidArgumentException $exception) {
                if ($this->exceptionThrownByContainer($exception)) {
                    throw new SlimContainerException(
                        sprintf('Container error while retrieving "%s"', $id),
                        null,
                        $exception
                    );
                } else {
                    throw $exception;
                }
            }
        }
    
        /**
         * Tests whether an exception needs to be recast for compliance with psr/container.  This will be if the
         * exception was thrown by Pimple.
         *
         * @param InvalidArgumentException $exception
         *
         * @return bool
         */
        private function exceptionThrownByContainer(InvalidArgumentException $exception)
        {
            $trace = $exception->getTrace()[0];
    
            return $trace['class'] === PimpleContainer::class && $trace['function'] === 'offsetGet';
        }
    
        /**
         * Returns true if the container can return an entry for the given identifier.
         * Returns false otherwise.
         *
         * @param string $id Identifier of the entry to look for.
         *
         * @return boolean
         */
        public function has($id)
        {
            return $this->offsetExists($id);
        }
    
        /**
         * @param string $name
         *
         * @return mixed
         *
         * @throws InvalidArgumentException         Thrown when an offset cannot be found in the Pimple container
         * @throws SlimContainerException           Thrown when an exception is not
         *         an instance of ContainerExceptionInterface
         * @throws ContainerValueNotFoundException  No entry was found for this identifier.
         * @throws ContainerExceptionInterface      Error while retrieving the entry.
         */
        public function __get($name)
        {
            return $this->get($name);
        }
    
        /**
         * @param string $name
         * @return bool
         */
        public function __isset($name)
        {
            return $this->has($name);
        }
    }
    

    This is the ContainerInterface.php file

    <?php
    /**
     * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
     */
    
    namespace Psr\Container;
    
    /**
     * Describes the interface of a container that exposes methods to read its entries.
     */
    interface ContainerInterface
    {
        /**
         * Finds an entry of the container by its identifier and returns it.
         *
         * @param string $id Identifier of the entry to look for.
         *
         * @throws NotFoundExceptionInterface  No entry was found for **this** identifier.
         * @throws ContainerExceptionInterface Error while retrieving the entry.
         *
         * @return mixed Entry.
         */
        public function get($id);
    
        /**
         * Returns true if the container can return an entry for the given identifier.
         * Returns false otherwise.
         *
         * <code>has($id)</code> returning true does not mean that <code>get($id)</code> will not throw an exception.
         * It does however mean that <code>get($id)</code> will not throw a <code>NotFoundExceptionInterface</code>.
         *
         * @param string $id Identifier of the entry to look for.
         *
         * @return bool
         */
        public function has($id);
    }
    

    I haven’t edited either of these files, that’s how it looks straight from the download, and things were working fine last week so I’m not sure what happened. Thanks so much for any help!

Viewing 1 replies (of 1 total)
  • Plugin Author ameliabooking

    (@ameliabooking)

    Hello there and sorry for the late response!

    We suppose you’re using Bluehost as a hosting provider? If that’s the case, there’s been a recent update of their plugin which caused a conflict with Amelia.

    Our development team was able to fix the issue and we’ll roll out a new update today which will fix the problem on all sites, so all you have to do is update the plugin to the new version once it’s released.

    Also, make sure to purge the cache on your site (server) when you update the plugin, and please let us know if it fixes the issue on your site.

Viewing 1 replies (of 1 total)

The topic ‘E_COMPILE_ERROR Breaking Site’ is closed to new replies.