[pmwiki-users] Fix blogit for use with PHP 5.5

Tiger!P pmwiki-tigerp at tigerp.net
Thu Oct 30 12:58:42 CDT 2014


On Thu, Oct 30, 2014 at 02:17:58PM +1300, John Rankin wrote:
> 
> > On Mon, Oct 27, 2014 at 10:22:17AM +1300, John Rankin wrote:
> >
> > Hello John,
> >

[cut how to fix the Markup('blogit' line]

> > This does not result in the error message, but when I go to the new blog
> > page (/Site/BlogIt-Admin?action=bi_ne ) some blogit codes are displayed
> > on the page. I don't know if this was the case before PHP5.5, but don't
> > think so.
> >
> > Blog Title: (:blogit list "$:entrytype":)bi_PageType/Type:
> > (:blogitend:)(:blogit list "$:blogid":)bi_BlogList/BlogID: (:blogitend:)
> > Tags: (:blogit list "$:entrystatus":)bi_StatusType/Status:
> > (:blogitend:)(:blogit list "$:entrycomments":)bi_CommentType/Comments:
> > (:blogitend:)

This problem still exists.
And now the /Blog/Main page does not have any blog posts anymore. Also
the list of recently written is empty.
But the Categories contains a list of tags and when I select a tag, I
see a link to the blogpost which has that tag.

So I think something is not quite right yet.

Hopefully DaveG can give some advice.

> > When I save the new blog entry, I get still some deprecated messages:
> > PHP Deprecated:  preg_replace(): The /e modifier is deprecated, use
> > preg_replace_callback instead in
> > /home/tigerp/www/pmwiki-2.2.62/pmwiki.php on line 471
> >
> > So I think a little bit more needs to be done.
> 
> It looks like there are a number of instances of the /e modifier which
> need to be changed.
> 
> In $bi_MakePageNamePatterns, it needs to remove the e, then use and
> PCCF("return utf8toupper(\$m[1]);") and PCCF("return strtoupper(\$m[1]);")

This solved the issue of the deprecated warnings in the log :-)
Thank you for that.

> Then all 3 calls to Markup need to be updated, in the same way as the
> 'blogit' rule.

I already did that before.

Attached is a patch for blogit.php with the changes I made sofar.

Tiger!P
-- 
A random quote:
Een theemuts is niet alleen goed voor de theepot.
-------------- next part --------------
--- blogit.php.orig.20141002	2014-10-02 17:04:04.951513050 +0200
+++ blogit.php	2014-10-30 18:56:39.137676955 +0100
@@ -79,8 +79,8 @@
 	"/[^". $PageNameChars. "]+/" => $bi_TitleSeparator,  #convert everything else to hyphen
 	"/(^\\" .$bi_TitleSeparator ."+)|(\\" .$bi_TitleSeparator ."+\$)/" => '',  #trim hyphens front and back
 	"/\\" .$bi_TitleSeparator ."{2,}/" => $bi_TitleSeparator,  #trim duplicate hyphens
-	($Charset=='UTF-8' ?"/^([\\xc0-\\xdf].)/e" :'//') => ($Charset=='UTF-8' ?"utf8toupper('$1')" :''),  #uppercase first letter
-	"/^([a-z])/e" => "strtoupper('$1')"
+	($Charset=='UTF-8' ?"/^([\\xc0-\\xdf].)/" :'//') => ($Charset=='UTF-8' ? PCCF("return utf8toupper(\$m[1]);") :''),  #uppercase first letter
+	"/^([a-z])/" => PCCF("return strtoupper(\$m[1]);")
 ));
 SDVA($bi_FixPageTitlePatterns, array(
 	'/[.\\/#]/' => ''	#remove dots, forward and backslashes in page titles as MakePageName returns '' when these characters are present
@@ -140,7 +140,7 @@
 $bi_OriginalFn['AuthFunction']=$AuthFunction;  #must occur before calling bi_Auth()
 $AuthFunction = 'bi_BlogItAuth';  #TODO: Use $AuthUserFunctions instead?
 # Need to save entrybody in an alternate format to prevent (:...:) markup confusing the end of the variable definition.
-$PageTextVarPatterns['[[#anchor]]'] = '/(\[\[#blogit_(\w[_-\w]*)\]\](?: *\n)?)(.*?)(\[\[#blogit_\2end\]\])/s';  #[1]
+$PageTextVarPatterns['[[#anchor]]'] = '/(\[\[#blogit_(\w[_\w-]*)\]\](?: *\n)?)(.*?)(\[\[#blogit_\2end\]\])/s';  #[1]
 $bi_Pagename = ResolvePageName($pagename);  #undo clean urls (replace / with .) to make pagename checks easier
 
 if ($bi_Pagename == $bi_Pages['blog_list'])	$FmtPV['$bi_BlogId']='"' .bi_Clean('word', $_GET['blogid']) .'"';
@@ -236,14 +236,20 @@
 
 # ----------------------------------------
 # - Markup
-Markup('blogit', 'fulltext', '/\(:blogit (list|cleantext)\s?(.*?):\)(.*?)\(:blogitend:\)/esi',
-	"blogitMU_$1(PSS('$2'), PSS('$3'))");
-Markup('blogit-skin', 'fulltext', '/\(:blogit-skin '.
+Markup('blogit', 'fulltext', '/\(:blogit
+ (list|cleantext)\s?(.*?):\)(.*?)\(:blogitend:\)/si',
+        function ($m) {
+            $func = 'blogitMU_'.$m[1];
+            return $func($m[2], $m[3]);
+        }                                                                       
+  );
+
+Markup_e('blogit-skin', 'fulltext', '/\(:blogit-skin '.
 	'(date|intro|author|tags|edit|newentry|delete|commentcount|date|commentauthor|commentapprove|commentdelete|commentedit|commentreply|commentblock|commenttext|commentid)'.
-	'\s?(.*?):\)(.*?)\(:blogit-skinend:\)/esi',
-	"blogitSkinMU('$1', PSS('$2'), PSS('$3'))");
-Markup('includesection', '>if', '/\(:includesection\s+(\S.*?):\)/ei',
-	"PRR(bi_includeSection(\$GLOBALS['bi_Pagename'], PSS('$1 '.\$GLOBALS['bi_TemplateList'])))");
+	'\s?(.*?):\)(.*?)\(:blogit-skinend:\)/si',
+	"blogitSkinMU(\$m[1], PSS(\$m[2]), PSS(\$m[3]))");
+Markup_e('includesection', '>if', '/\(:includesection\s+(\S.*?):\)/i',
+	"PRR(bi_includeSection(\$GLOBALS['bi_Pagename'], PSS(\$m[1].' '.\$GLOBALS['bi_TemplateList'])))");
 $SaveAttrPatterns['/\\(:includesection\\s.*?:\\)/i'] = ' ';  #prevents include sections becoming part of page targets list
 if (IsEnabled($EnableGUIButtons) && $FmtPV['$bi_Mode']!='ajax'){
 	if ($action=='bi_be' || $action=='bi_ne' || ($action=='pmform' && $_REQUEST['target']=='blogit-entry'))


More information about the pmwiki-users mailing list