On a server with PHP 7.0.8 this module gives the following error:

mod_fcgid: stderr: PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; MarkdownExtra_Parser has a deprecated constructor in /home/username/public_html/sites/all/modules/markdown/markdown.php on line 1696

The line 1696 looks like:

class MarkdownExtra_Parser extends Markdown_Parser {

and little bit further down there is a function with similar name:

function MarkdownExtra_Parser() {

The http://php.net/manual/en/migration70.deprecated.php says:

PHP 4 style constructors (methods that have the same name as the class they are defined in) are deprecated, and will be removed in the future. PHP 7 will emit E_DEPRECATED if a PHP 4 constructor is the only constructor defined within a class. Classes that implement a __construct() method are unaffected

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

nickonom created an issue. See original summary.

frjo’s picture

Assigned: Unassigned » frjo
Status: Active » Needs review
FileSize
98.11 KB

Please try this patch that replaces the old PHP Markdown with the new PHP Markdown Lib, see https://michelf.ca/projects/php-markdown/. The Drupal 8 version already uses the PHP Markdown Lib.

Hopefully the lib version works with PHP 7. Please report back any issues. When it works as it should I will make a new release for Drupal 7.

nickonom’s picture

Issue summary: View changes

Thanks. Will try soon.

nickonom’s picture

I have applied the patch and now see bunch of new files on the modules directory. What looks not nice is that there are now two files with the same name, but with first letters of different registers:

-rwxr-xr-x 1 username username  94819 May 15  2013 markdown.php
-rw-r--r-- 1 username   username    45003 Jul 15 00:24 Markdown.php

Should I just delete the old one? Is it ok all the new files have capital letters in their names?

nickonom’s picture

The patch is breaking the website giving:

Error: Class 'Michelf\MarkdownExtra' not found in _filter_markdown() (line 117 of /home/username/public_html/sites/all/modules/markdown/markdown.module).

so unfortunately it is not ready for Drupal 7.

frjo’s picture

A new patch that deletes the old markdown.php file. The new files (Markdown*) should all be in an subfolder named "includes". This should happen automatically when you apply the patch.

Reinstall the markdown filter module and run this command:

wget --quiet --output-document=- https://www.drupal.org/files/issues/markdown_php_lib_2766143_2.patch | patch -p1

iamdroid’s picture

Patch #6 works for me.
Thank You.

frjo’s picture

Title: MarkdownExtra_Parser has a deprecated constructor in ../modules/markdown/markdown.php on line 1696 » Upgrade to the latest PHP Markdown Lib for PHP 7 compatibility
nickonom’s picture

I also do not see the errors anymore. Thanks!

  • frjo committed 580276d on 7.x-1.x
    Issue #2766143 by frjo: Upgrade to the latest PHP Markdown Lib for PHP 7...
frjo’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.