Author Topic: 2.10.0 Methods with the same name as their class will not be constructors in a f  (Read 1749 times)

Offline Hans

  • Posts: 912
  • Gender: Male
Hello,

In found this in PHP_error log:
Quote
2017-04-03T09:23:26+00:00 [E_DEPRECATED] /admin/media/resize_img.php:[29] from /admin/media/upload.php:[21] include_once "Methods with the same name as their class will not be constructors in a future version of PHP; RESIZEIMAGE has a deprecated constructor"

I suppose it's only a warning message but would like to know what it means and how it could eventually have impact on a site (eg if in future PHP would be upgraded (now 7.0))
(How) can I get rid of it?

Thank you!
Hans - Nijmegen - The Netherlands

Offline jacobi22

  • Posts: 5891
  • Gender: Male
  • Support also via PM or EMail
    • Jacobi22
confirmed   (Y)

we work on it
i've no solution at the moment, but the message in the error-log is not displayed, if you use a error-level in wb-advanced options (not E_NONE)

Wer nicht will, findet Gründe, wer will, findet Wege.

Offline DarkViper

  • Forum administrator
  • *****
  • Posts: 3028
  • Gender: Female
its easy to fix:

simply exchange Line 47 of /admin/media/resize_img.php

function RESIZEIMAGE($imgFile="")
with
public function __construct($imgFile "")

(its one of the old PHP-4 classes... where the constructor had the same name like the class)
« Last Edit: April 04, 2017, 01:05:49 PM by DarkViper »
Der blaue Planet - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen

"You have to take the men as they are… but you can not leave them like that !" :-P
Das tägliche Stoßgebet: Oh Herr, wirf Hirn vom Himmel !

Offline Hans

  • Posts: 912
  • Gender: Male
Thanks both of you  (Y)
Hans - Nijmegen - The Netherlands

Offline dbs

  • Betatester
  • **
  • Posts: 8076
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Code: [Select]
public function __construct(...)Thanks for this. I was able with this to fix something in wblib and LibraryAdmin.  (Y)

Offline dbs

  • Betatester
  • **
  • Posts: 8076
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Nachfrage. (WB2.10.1, PHP7.0.20)
Im Modul Feedback in class.feedback.php Zeile 1093 ff
Code: [Select]
class feedback_view_dlg extends sql_feedback {

  var $page_id;
  var $section_id;
  var $options;
  var $remark;

  /**
   * Constructor
   *
   * @param INT $page_id
   * @param INT $section_id
   * @return feedback_view_dlg
   */
  function feedback_view_dlg($page_id, $section_id) {
    $this->remark = '';
    $this->page_id = $page_id;
    $this->section_id = $section_id;
    $this->sql_feedback();
    ...

Wenn man hier also daraus macht:
Code: [Select]
class feedback_view_dlg extends sql_feedback {

  var $page_id;
  var $section_id;
  var $options;
  var $remark;

  /**
   * Constructor
   *
   * @param INT $page_id
   * @param INT $section_id
   * @return feedback_view_dlg
   */
  public function __construct($page_id, $section_id) {
    $this->remark = '';
    $this->page_id = $page_id;
    $this->section_id = $section_id;
    $this->sql_feedback();
    ...

Führt das im Frontend zu
Code: [Select]
There was an uncatched exception
Call to undefined method feedback_view_dlg::sql_feedback()
in line (1109) of (/modules/feedback/class.feedback.php):
1109 = $this->page_id = $page_id;
Was wäre hier zu tun? :)

Backend das Gleiche, nur andere Zeilennummer (665) und geht um $this->section_id = $section_id;.
« Last Edit: June 18, 2017, 08:44:56 AM by dbs »

Offline dbs

  • Betatester
  • **
  • Posts: 8076
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Lösung, dank Manu.

Wenn die Klasse so aussieht, also mit extends drin:
Code: [Select]
class aaaa extends bbbb {dann unter der bereits ersetzten Zeile public function __construct( noch hinzufügen:
Code: [Select]
parent::__construct(); // den constructor der elternklasse aufrufenund etwas tiefer, die Zeile wo die erweiterte/extends Klasse aufgerufen wird, entfernen:
Code: [Select]
$this->bbbb();
konkretes Beispiel aus feedback
Code: [Select]
class feedback_view_dlg extends sql_feedback {

  var $page_id;
  var $section_id;
  var $options;
  var $remark;

  /**
   * Constructor
   *
   * @param INT $page_id
   * @param INT $section_id
   * @return feedback_view_dlg
   */
  public function __construct($page_id, $section_id) {    <<<<<<<<<<<<<<<<<<<< geändert
    parent::__construct(); // den constructor der elternklasse aufrufen <<<<<<<<<<  neu
    $this->remark = '';
    $this->page_id = $page_id;
    $this->section_id = $section_id;
// $this->sql_feedback();     <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< weg damit
    $this->record = array();
    $this->record['page_id'] = $page_id;
    $this->record['section_id'] = $section_id;

Das schreib ich wohl mehr für mich zum später reinschauen so auf :-)