[OJS 3.1.0.1] Error in php log customBlockManager

Hi to all! I saw that in my PHP log file there is this message:

[18-Dec-2017 15:47:32 Europe/Berlin] PHP Strict Standards: Declaration of CustomBlockPlugin::getContents() should be compatible with BlockPlugin::getContents($templateMgr, $request = NULL) in /Applications/MAMP/htdocs/agro/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 134

How can i fix it?

Thanks a lot.

Bye
Tiziano

Hi @Tiziano,

This is a cosmetic issue and can be ignored. If you want to get rid of it, you can apply this patch.

Regards,
Alec Smecher
Public Knowledge Project Team

2 Likes

Hi @asmecher, thanks, works, can you help me to get rid even the follow errors?

[19-Dec-2017 09:36:31 Europe/Berlin] PHP Strict Standards: Declaration of CustomBlockPlugin::getSeq() should be compatible with BlockPlugin::getSeq($contextId = NULL) in /Applications/MAMP/htdocs/agro/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 140
[19-Dec-2017 09:36:31 Europe/Berlin] PHP Strict Standards: Declaration of CustomBlockPlugin::getBlockContext() should be compatible with BlockPlugin::getBlockContext($contextId = NULL) in /Applications/MAMP/htdocs/agro/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 140
[19-Dec-2017 09:36:31 Europe/Berlin] PHP Strict Standards: Declaration of CustomBlockPlugin::getEnabled() should be compatible with BlockPlugin::getEnabled($contextId = NULL) in /Applications/MAMP/htdocs/agro/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 140
[19-Dec-2017 09:36:32 Europe/Berlin] PHP Strict Standards: Declaration of SubmissionFileDAO::fromRow() should be compatible with PKPSubmissionFileDAO::fromRow($row, $fileImplementation) in /Applications/MAMP/htdocs/agro/classes/article/SubmissionFileDAO.inc.php on line 23

Best!
Tiziano

Hi @Tiziano,

In plugins/generic/customBlockManager, you can apply Resolve strict standards warning · pkp/customBlockManager@c564d60 · GitHub (this should resolve warnings about BlockPlugin::getEnabled). I’ll see if I can find a similarly quick resolution for the DAOSubmissionFile::fromRow warning. However, note that these are cosmetic and you’ll run into them from time to time – we’ll be working to gradually clean them up in following releases.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher!
First, thanks for you help, second, with your suggest i did able to fix also following errors:

PHP Strict Standards: Declaration of CustomBlockPlugin::getBlockContext() 

with this patch:

function getBlockContext($contextId = null) {
	if (!Config::getVar('general', 'installed')) return BLOCK_CONTEXT_SIDEBAR;
	return parent::getBlockContext($contextId);
}

then,

PHP Strict Standards: Declaration of CustomBlockPlugin::getEnabled() 

with this patch:

function getEnabled($contextId = null) {
	if (!Config::getVar('general', 'installed')) return true;
	return parent::getEnabled($contextId);
}

and then at last,

PHP Strict Standards: Declaration of SubmissionFileDAO::fromRow() 

with this patch into two files:

classes/article/SubmissionFileDAO.inc.php

function fromRow($row, $fileImplementation) {

and classes/submission/PKPSubmissionFileDAO.inc.php

$submissionFiles[$idAndRevision] = $this->fromRow($row, $fileImplementation);

Now no more errors in php logs.

Thanks, bye!
Tiziano

Hi @Tiziano,

What did you change in the last two files?

Regards,
Alec Smecher
Public Knowledge Project Team

Hi @asmecher, so, for the first two:

from

function getBlockContext() {
	if (!Config::getVar('general', 'installed')) return BLOCK_CONTEXT_SIDEBAR;
	return parent::getBlockContext();
}

to

function getBlockContext($contextId = null) {
	if (!Config::getVar('general', 'installed')) return BLOCK_CONTEXT_SIDEBAR;
	return parent::getBlockContext($contextId);
}

and from

function getEnabled() {
	if (!Config::getVar('general', 'installed')) return true;
	return parent::getEnabled();
}

to

function getEnabled($contextId = null) {
	if (!Config::getVar('general', 'installed')) return true;
	return parent::getEnabled($contextId);
}

instead, for the last one, PHP Strict Standards: Declaration of SubmissionFileDAO::fromRow() i checked the result after applyed patch, but for the front-end site no errors in php log, but, in back-end site showed me new errors, so i returned to original code.

copy the errors, after my modify:

[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:54 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:55 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:56 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:56 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:56 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889
[21-Dec-2017 09:53:56 Europe/Berlin] PHP Notice: Undefined variable: fileImplementation in /Applications/MAMP/htdocs/agro/lib/pkp/classes/submission/PKPSubmissionFileDAO.inc.php on line 889

Bye!
Tiziano

Hi @Tiziano,

I’d suggest reverting your change for that last one – it’s not a trivial fix like the first two, and your change is likely to cause problems. The warnings you were originally getting are cosmetic and can be ignored until it’s fixed fully in a future release.

Regards,
Alec Smecher
Public Knowledge Project Team

1 Like

i get this warning error. how can i fix it?

Strict Standards: Declaration of CustomBlockPlugin::getBlockContext() should be compatible with BlockPlugin::getBlockContext($contextId = NULL) in /home/bmebbior/public_html/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 19

thanks a lot

Hi @hari_pramono,

That’s cosmetic and I’d suggest ignoring it. We’ll be working to resolve these in the next few releases.

Regards,
Alec Smecher
Public Knowledge Project Team

Hi. I did this patch and still get the error.

function getContents($templateMgr, $request = null) {
# removed the ampersand sign before $templateMgr above
# jmo
$context = $request->getContext();
$contextId = $context ? $context->getId() : 0;

  // Get the block contents.
  $customBlockContent = $this->getSetting($contextId, 'blockContent');
  $currentLocale = AppLocale::getLocale();
  # $contextPrimaryLocale = $context->getPrimaryLocale(); replaced by below line
  $contextPrimaryLocale = $context?$context->getPrimaryLocale():$request->getSite()->getPrimaryLocale();
  # jmo 
  # https://forum.pkp.sfu.ca/t/local-installation-of-ojs-3-1-on-windows/37220/6

Hi @johnostrowick,

What version of OJS are you using? Which of the above messages are you trying to resolve?

You can use three backticks (```) on this forum to quote sections of code; otherwise they’re hard to read.

Regards,
Alec Smecher
Public Knowledge Project Team

3.1.0, as far as I can tell.

Hi @johnostrowick,

See How do I determine my PKP software's version? - #2 if you’re not sure what version you’re using. Can you answer the other question above? Also, I can’t read the quoted code you posted; don’t forget to use backticks to quote code sections.

Regards,
Alec Smecher
Public Knowledge Project Team

version 3.1.0.1

The error I am trying to solve is:


Warning: Declaration of CustomBlockPlugin::getEnabled() should be compatible with BlockPlugin::getEnabled($contextId = NULL) in /var/www/issa.africa/plugins/generic/customBlockManager/CustomBlockPlugin.inc.php on line 140```

Hi @johnostrowick,

That warning is already resolved in OJS 3.1.2. But it’s just cosmetic and shouldn’t be causing any failures, unless you have configured your system to display error messages in the browser; if you’ve done that, warnings will interrupt AJAX requests and cause problems there. It is better to configure your system to send error and warning messages to the log.

Regards,
Alec Smecher
Public Knowledge Project Team

OK but it’s a production server so I can’t tinker too much.
I’ve tried

error_reporting = ~E_ALL
;   Default Value: E_ALL & ~E_NOTICE & ~E_STRICT & ~E_DEPRECATED
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT```

none seem to help

Hi @johnostrowick,

Are your errors/warnings going to the browser, or to the log file?

Regards,
Alec Smecher
Public Knowledge Project Team

browser; if it was just the log file I’d not be bothered. However, the client is bothered.

[removed spam]

oh great, i see it received the spam injection as well

Hi @johnostrowick,

You’ll need to work with the display_errors setting (it’s in both config.inc.php and your PHP configuration).

You’ll definitely need to fix the spam injection you mentioned on your other thread before you can expect things to behave predictably. I just posted about a similar problem on another thread.

Regards,
Alec Smecher
Public Knowledge Project Team