heiseonline / shariff-backend-php

đŸ‘® PHP backend for Shariff. Shariff enables website users to share their favorite content without compromising their privacy.
http://ct.de/-2467514
134 stars 44 forks source link

Handle missing or deleted services #135

Closed richard67 closed 6 years ago

richard67 commented 6 years ago

As discussed with pull request (PR) #132 , the backend crashes with fatal PHP error in case if the php source for a service is missing, e.g. if the service has been removed from the backend like Twitter and GooglePlus, and so the PHP files have been removed, but the services are still configured to be used in index.php.

This PR here adds handling for this case in 2 ways:

  1. Have a list of removed services' names and don't use that service if the service name is in that list.
  2. Don' use a service if the php source file for that service doesn't exist.

How to test:

  1. By code review. If you think that variable $deletedServices in file ServiceFactory.php should better be a const, just let me know, and I'll change that.
  2. Check that all implemented services still work.
  3. Have some deleted service like "Twitter" or "GooglePlus" configured in your index.php and have the php file for that service in your backend from older backend versions, and check that for these services no counters are returned, but all other implemented services work.
  4. Have some nonsense service like "Gaga" or "Blabla" configured in your index.php for which no php file exists, and check that all implemented services work.

I have tested this on a Linux & Apache environment. It would be good if someone could test that on a Windows & IIS environment, too, just to make sure that the file_exists works there like it should.

richard67 commented 6 years ago

@compeak @liayn Please check this PR here.

richard67 commented 6 years ago

@compeak @liayn Any idea what to do to make codeclimate happy? It still claims complexity being too high.

richard67 commented 6 years ago

Closing in favour of PR #136 .