Hi everyone,
Recently I faced with issue Deprecated function: Methods with the same name as their class will not be constructors in a future version of PHP; GeSHi has a deprecated constructor in function require_once() (line 837 in file /sites/all/modules/contrib/libraries/libraries.module).
This error is related to PHP version 7 and higher and appears when user visits the page with code snippets handled by geshi filter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

e.bogatyrev created an issue. See original summary.

e.bogatyrev’s picture

Here is the patch from me.

e.bogatyrev’s picture

Status: Active » Needs review
yukare’s picture

I had this too, but we can not fix it, because it is in geshi library, not in the drupal module, which is still compatible with php 4. The better thing we can do is create a path from same dir as geshi(it can be in other places, so we can not use a path from drupal root as it will not work for everyone) and add a note in the readme and the project page to this issue, but we can not fix it.

I see now while looking for the issue. Geshi library has a new version 1.0.9, please use this version, it fixes this issue. I will put a note on project page.

e.bogatyrev’s picture

Hi yukare,
Thanks for your answer. I agree with you, but may be better to add the version verification in hook_requirements. Anyway I have created another patch for hook_requirements() and updated the library version for geshifilter.make. Please take a look and let me know what do you think.

hugronaphor’s picture

Version: 7.x-1.2 » 8.x-1.x-dev
Status: Needs review » Needs work

Updating the GeSHi library to 1.0.9.0 now gives me the: "Undefined index: LANG_NAME in GeSHi->get_language_name()" in Drupal 8

Seems like there are some API changes which has to be addressed, like:
$geshi->set_language_path($dir); is deprecated now.

yukare’s picture

@hugronaphor please go to /admin/config/content/formats/geshifilter and click on "Flush geshi language definition cache", if this does not fiz the error please provide the full error message, with file/line number. We do not have this error in a new instalation, so maybe it is something that is on cache.

hugronaphor’s picture

I'm afraid it's still the same:

Notice: Undefined index: LANG_NAME in GeSHi->get_language_name() (line 614 of libraries/geshi/geshi.php).
GeSHi->get_language_name() (Line: 179)
Drupal\geshifilter\GeshiFilter::getAvailableLanguages() (Line: 207)
Drupal\geshifilter\GeshiFilter::getEnabledLanguages() (Line: 109)
Drupal\geshifilter\Form\GeshiFilterSettingsForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('geshifilter_admin_settings', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm('geshifilter_admin_settings', Object) (Line: 74)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 582)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 151)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 664)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

I use PHP 7.0.28

geerlingguy’s picture

Same here, but using 7.x, and running PHP 7.1.x.