If your site is running on php 5.5 you will receive this error message.
Deprecated function: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in _bible_blsaddLink() (line 2974 of /mnt/www/html/ucg7dev/docroot/sites/all/modules/bible/bible.module).

There is a simple fix, it is suggested to instead use preg_replace_callback(), which I'm told is more performant and will work on PHP 5 and above.

I was going to provide a patch, but this module doesn't provide a public working git repo of the latest DEV or version to work from.

Below is the changes I made to fix the issue. Starting on line 3014 of bible.module (version 7.x-1.5-alpha4).

function _bible_blsaddLink($text = '') {
  global $book_list, $book_namelist;
  $book_regex = $book_list .'|'. str_replace(';', '|', $book_namelist);
  $pattern_regex = '/('. $book_regex .')[:. ]+(\d{1,3}):(\d{1,3}(?:-\d{1,3})?)([#\^]\w+)?([\&]\w+)?(\s?)/';
  $replacement_regex = '_bible_blsdivhtml';
  $text = preg_replace_callback($pattern_regex, $replacement_regex, $text);
  return $text;
}


function _bible_blsdivhtml($m) {
  $script= $m[0];
  $book  = $m[1];
  $chap  = $m[2];
  $verse = $m[3];
  $para  = $m[4];
  $func  = $m[5];
  $tail  = $m[6];

Comments

travelertt’s picture

Issue summary: View changes
travelertt’s picture

Issue summary: View changes
joebest’s picture

The suggested code renders my site in blank. My environment is MAMP 3.0 PHP 5.5.10

travelertt’s picture

You're not including the tags right?

What do your error logs say?

joebest’s picture

Thanks for your reply.

Not including tags <?php ?>

No logs error messages are registered. The new code just renders the site as a blank page.

joebest’s picture

hello travlertt,
Just to let you know that I finally placed the code how I think it should be and it resolved the Deprecated function: preg_replace(). Yahoo :)

However I'm getting a whole set of other issues:

Warning: Missing argument 2 for _bible_blsdivhtml() in _bible_blsdivhtml() (line 3023 of /Library/Server/Web/Data/Sites/frutodelavid.org/sites/all/modules/bible/bible.module).
Warning: Missing argument 3 for _bible_blsdivhtml() in _bible_blsdivhtml() (line 3023 of /Library/Server/Web/Data/Sites/frutodelavid.org/sites/all/modules/bible/bible.module).
Warning: Missing argument 4 for _bible_blsdivhtml() in _bible_blsdivhtml() (line 3023 of /Library/Server/Web/Data/Sites/frutodelavid.org/sites/all/modules/bible/bible.module).
Warning: Missing argument 5 for _bible_blsdivhtml() in _bible_blsdivhtml() (line 3023 of /Library/Server/Web/Data/Sites/frutodelavid.org/sites/all/modules/bible/bible.module).
Warning: Missing argument 6 for _bible_blsdivhtml() in _bible_blsdivhtml() (line 3023 of /Library/Server/Web/Data/Sites/frutodelavid.org/sites/all/modules/bible/bible.module).
Warning: Missing argument 7 for _bible_blsdivhtml() in _bible_blsdivhtml() (line 3023 of /Library/Server/Web/Data/Sites/frutodelavid.org/sites/all/modules/bible/bible.module).

I pasted the code by replacing the function _bible_blsaddLink( and adding the m$ variable to function _bible_blsdivhtml as follows. Note: line 3023 is the beginning of function _bible_blsdivhtml:

function _bible_blsaddLink($text = '') {
  global $book_list, $book_namelist;
  $book_regex = $book_list .'|'. str_replace(';', '|', $book_namelist);
  $pattern_regex = '/('. $book_regex .')[:. ]+(\d{1,3}):(\d{1,3}(?:-\d{1,3})?)([#\^]\w+)?([\&]\w+)?(\s?)/';
  $replacement_regex = '_bible_blsdivhtml';
  $text = preg_replace_callback($pattern_regex, $replacement_regex, $text);
  return $text;
}

function _bible_blsdivhtml($m, $book, $chap, $verse, $para, $func, $tail) {
  $script= $m[0];
  $book  = $m[1];
  $chap  = $m[2];
  $verse = $m[3];
  $para  = $m[4];
  $func  = $m[5];
  $tail  = $m[6];

	if ($para != "") {
	...the rest of the code...
joebest’s picture

After further debugging, I did the following and it works without errors.

function _bible_blsaddLink($text = '') {
  global $book_list, $book_namelist;
  $book_regex = $book_list .'|'. str_replace(';', '|', $book_namelist);
  $pattern_regex = '/('. $book_regex .')[:. ]+(\d{1,3}):(\d{1,3}(?:-\d{1,3})?)([#\^]\w+)?([\&]\w+)?(\s?)/';
  $replacement_regex = '_bible_blsdivhtml';
  $text = preg_replace_callback($pattern_regex, $replacement_regex, $text);
  return $text;
}

function _bible_blsdivhtml($m) {
  $script= $m[0];
  $book  = $m[1];
  $chap  = $m[2];
  $verse = $m[3];
  $para  = $m[4];
  $func  = $m[5];
  $tail  = $m[6];
  ...the rest of code...

If this was the intended correction, then this issue can be closed. Please note my PHP skills are rusty. Perhaps a patch would have been handy or bible 7.x-1.5-alpha5 with the corrections. With that said, thanks for the corrections and all efforts are highly appreciated. This module is VERY important and I'm look forward to further enhancements.

Kind regards,
Jose

joebest’s picture

My bad, you did comment about the patch issue:

I was going to provide a patch, but this module doesn't provide a public working git repo of the latest DEV or version to work from.

I hope this gets corrected.

travelertt’s picture

Yes that is the intended correction, (#7). Thank you.

rhuffstedtler’s picture

joebest/travelertt - You should now be able to pull the latest release and patch against it. I haven't started a new dev branch yet, but I should have one up in the next few days as soon as I have another commit to add.

joebest’s picture

rhuffstedtler - using the new update returns the original error
Deprecated function: preg_replace()

rhuffstedtler’s picture

joebest - That would be my expectation. What I was suggesting was that you or travelertt produce a patch with the above changes against the latest release, and I will apply it and start the new dev branch.

berenddeboer’s picture

Status: Active » Needs work
apaderno’s picture

Version: 7.x-1.5-alpha4 » 7.x-1.x-dev
dieuwe’s picture

Status: Needs work » Closed (outdated)