-
Posts
80 -
Joined
-
Last visited
About pmichaelis
- Birthday 05/23/1978
Profile Information
-
Gender
Male
Recent Profile Visitors
4,168 profile views
pmichaelis's Achievements
-
pmichaelis started following Page Hit Counter – Simple Page View Tracking , Animated GIF resize issue , SeoMaestro and 3 others
-
Hi everyone, I encountered the same issues with the ImageSizerEngineAnimatedGif and PHP 8 compatibility. The issues that prevented animated GIFs from being processed correctly. The module works fine under PHP 7 but fails under PHP 8 due to changes in how GD handles image resources. Issues Encountered GD Resource vs GdImage Object: PHP 8 changed GD image handling from resources to GdImage objects Array access on null values: Stricter type checking in PHP 8 caused "trying to access array offset on null" warnings File handling: Issues with fopen/fwrite combinations Complete Fix Applied Here are the changes to make the module PHP 8 compatible Add new helper method (after line 42) <?php /** * Helper method to check if a variable is a valid GD image resource/object * Compatible with both PHP 7 (resource) and PHP 8 (GdImage object) * * @param mixed $image * @return bool */ protected function isGdImage($image) { // PHP 8.0+ uses GdImage objects instead of resources if (class_exists('GdImage') && $image instanceof \GdImage) { return true; } // PHP 7.x uses resources return is_resource($image) && get_resource_type($image) === 'gd'; } Update module version (line 26) <?php 'version' => 2, // Increased for PHP 8 compatibility Replace all GD resource checks Line 176: if(!is_resource($frame)) → if(!$this->isGdImage($frame)) Line 178: if(!is_resource($bg)) → if(!$this->isGdImage($bg)) Line 205: if(!is_resource($nf)) → if(!$this->isGdImage($nf)) Line 234: if(isset($bg) && is_resource($bg)) → if(isset($bg) && $this->isGdImage($bg)) Line 235: if(isset($frame) && is_resource($frame)) → if(isset($frame) && $this->isGdImage($frame)) Line 236: if(isset($newimg) && is_resource($newimg)) → if(isset($newimg) && $this->isGdImage($newimg)) Line 271: if(!is_resource($frame)) → if(!$this->isGdImage($frame)) Line 275: if(is_resource($bg)) → if($this->isGdImage($bg)) Line 287: if(!is_resource($bg)) → if(!$this->isGdImage($bg)) Line 302: if(!is_resource($frame)) → if(!$this->isGdImage($frame)) Line 306: if(is_resource($bg)) → if($this->isGdImage($bg)) Line 318: if(!is_resource($bg)) → if(!$this->isGdImage($bg)) Line 335: if(!is_resource($nf)) → if(!$this->isGdImage($nf)) (This was the critical fix!) Line 361: if(isset($bg) && is_resource($bg)) → if(isset($bg) && $this->isGdImage($bg)) Line 362: if(isset($frame) && is_resource($frame)) → if(isset($frame) && $this->isGdImage($frame)) Line 363: if(isset($newimg) && is_resource($newimg)) → if(isset($newimg) && $this->isGdImage($newimg)) Improve file handling (lines 223-225 and 348-350) Replace: <?php $result = false === fwrite(fopen($srcFilename, 'wb'), $gifmerge->GetAnimation()) ? false : true; width: <?php $handle = fopen($srcFilename, 'wb'); $result = $handle && fwrite($handle, $gifmerge->GetAnimation()) !== false; if($handle) fclose($handle); frame validation (around line 340): <?php if(count($frames) > 0) { $gifmerge = new ISEAG_GIFEncoder( // ... existing code ); // ... file writing code } else { $result = false; } The main issue was on line 335 where if(!is_resource($nf)) prevented PHP 8's GdImage objects from being recognized as valid frames. An empty frame arrays was passed to the GIF encoder, causing the errors in gif_encoder.php. Hope this helps others who might encounter the same issues!
- 28 replies
-
- 2
-
-
-
Hey, there is a deprecation notice when running php 8.3 🥸 Deprecated: Calling get_class() without arguments is deprecated in .../cache/FileCompiler/site/modules/InputfieldAceExtended/InputfieldAceExtended.module on line 499 The error "Deprecated: Calling get_class() without arguments is deprecated" occurs when using PHP 8.3 or later to call the get_class() function without providing an argument. This is because the function's arguments are now required. Call get_called_class(), which works similarly to get_class() but doesn't require arguments. public static function getStatic($name) { $class = get_called_class(); return isset($class::$$name) ? $class::$$name : array(); }
-
Hey, I have made an adjustment to the output of the hreflang tags in getCommonMetatags() On news pages with pagination, only the url of the page is currently output as hreflang. As I understand it, the url segment of the pagination should also be appended to the hreflang tags so that the correct translation pages are referenced. The attached change works for me. Is my assumption correct? If so, what is the correct procedure here? Should I make a pull request? /** * Build common metatags not configured via fieldtype. * * @return array */ private function getCommonMetatags() { $baseUrl = $this->seoMaestro->get('baseUrl'); $defaultLang = $this->seoMaestro->get('defaultLanguage') ?: 'en'; $hasLanguageSupportPageNames = $this->wire('modules')->isInstalled('LanguageSupportPageNames'); $tags = ['meta_generator' => '<meta name="generator" content="ProcessWire">']; if ($hasLanguageSupportPageNames) { # page number & prefixes $pageNum = $this->wire('input')->pageNum(); $prefixes = $this->config->pageNumUrlPrefixes; foreach ($this->wire('languages') ?: [] as $language) { if (!$this->page->viewable($language)) { continue; } $code = $language->isDefault() ? $defaultLang : $language->name; $url = $baseUrl ? $baseUrl . $this->page->localUrl($language) : $this->page->localHttpUrl($language); # add pagination segment if ($pageNum > 1) { $prefix = isset($prefixes[$code]) ? $prefixes[$code] : $prefixes['default']; $pageSegment = $prefix . $pageNum; $url = rtrim($url, '/') . '/' . $pageSegment . '/'; } $tags["link_rel_{$code}"] = sprintf('<link rel="alternate" href="%s" hreflang="%s">', $url, $code); if ($language->isDefault()) { $tags['link_rel_default'] = sprintf('<link rel="alternate" href="%s" hreflang="x-default">', $url); } } } return $tags; } Kind regards & many thanks
-
I could have just used that. Thanks for the information.
-
Hey, is this feature already in the master branch? Thanks for help
-
In a multilingual environment I get the following error, wehen sorting menu-items TypeError method_exists(): Argument #1 ($object_or_class) must be of type object|string, null given File: .../modules/MarkupMenuBuilder/ProcessMenuBuilder.module:2602 2602: if($language != null && method_exists($pages->get($itemID)->title, 'getLanguageValue')) $itemTitle = $pages->get($itemID)->title->getLanguageValue($language);// title of each PW page in this array This works for me: // multilingual environments if($language != null && $itemID && method_exists($pages->get($itemID)->title, 'getLanguageValue')) $itemTitle = $pages->get($itemID)->title->getLanguageValue($language);// title of each PW page in this array
-
Hello @torf, I pushed an update a minute ago. Please have a look, if the issue is resolved. Happy new year.
-
Page Hit Counter – Simple Page View Tracking
pmichaelis replied to David Karich's topic in Modules/Plugins
hej, is it possible to hook into pageViewTracked from ready.php? I tried the following, but since I am not so familiar with hooks, it is not working out. wire()->addHookAfter('PageHitCounter::pageViewTracked', function($pageID) { $page = wire('pages')->get($pageID); ... } Thanks for any help.- 111 replies
-
- hitcounter
- tracking
- (and 4 more)
-
Hey Bernhard, Weird! thanks for bug-reporting. I'll update the repository!
-
Hey everybody, I just uploaded a small textformatter module for wrapping tables with a div container in order to display responsive HTML tables in the frontend. TextformatterWrapTable Processwire wrap table module is a textformatter module for processwire CMS/CMF. It is wrapping markup tables with a div container. wrapping tables with div container simplifies the process of displaying responsive tables in the frontend. The css classes for the wrapper and the table are configurable. .table-responsive / .table by default the module produces the following markup: <div class="table-responsive"> <table class="table"> ... </table> </div> Link to Repository https://github.com/pmichaelis/TextformatterWrapTable
- 5 replies
-
- 10
-
-
-
StaticWire - Covert pages to static HTML
pmichaelis replied to christophengelmayer's topic in Modules/Plugins
Hi, i wanted to test the module. Is there still a namespacing issue? Error: Class 'ProcessWire\HtmlExporter' not found in /home/vagrant/web/pw-static/web/site/modules/StaticWire/StaticWire.module.php on line 41 thanks for help