php code error Warning: Declaration of Digital_Signature::CreateSign() - php

function CreateSign()
{
$rsa_obj = new Crypt_RSA(array('private_key' => $this->_privateKey));
$this->check_error($rsa_obj);
return $rsa_obj->createSign($this->_document);
}
this code display this error
Warning: Declaration of Digital_Signature::CreateSign() should be compatible with Crypt_RSA::createSign($document, $private_key = NULL, $hash_func = NULL) in /var/www/html/shares/digital_signature.php on line 49
can any one help

both functions in the parent class and child class should have the same arguments , also same default values for their arguments

Related

array_shift() expects parameter 1 to be array

I am using my application in a shared hosting, it is produced in laravel. It gives me
PHP Warning: array_shift() expects parameter 1 to be array, null given in line 53
PHP Notice: Undefined index: argv in line 49
with this code:
class ArgvInput extends Input
{
private $tokens;
private $parsed;
public function __construct(array $argv = null, InputDefinition $definition = null)
{
if (null === $argv) {
$argv = $_SERVER['argv'];
}
// strip the application name
array_shift($argv);
$this->tokens = $argv;
parent::__construct($definition);
}
It can mean that the $_SERVER['argv'] variable is also empty. I'd recommend to check it first, or you can do this:
$argv = $argv ?? $_SERVER['argv'] ?? [];
This way you'll always have an array, even if there's no input, in which case the array will be empty, and it won't trigger that error

A PHP Error: Only variables should be passed by reference in Codeigniter

I'm stuck in this error. Can someone help me out? I am using Codeigniter 3.1.10
Here's a snippet of my code in system/core/Common.php
function &load_class($class, $directory = 'libraries', $param = NULL)
{
static $_classes = array();
// Does the class exist? If so, we're done...
if (isset($_classes[$class]))
{
return $_classes[$class];
}
$name = FALSE;
// Look for the class first in the local application/libraries folder
// then in the native system/libraries folder
foreach (array(APPPATH, BASEPATH) as $path)
{
if (file_exists($path.$directory.'/'.$class.'.php'))
{
$name = 'CI_'.$class;
if (class_exists($name, FALSE) === FALSE)
{
require_once($path.$directory.'/'.$class.'.php');
}
break;
}
}
I keep on receiving this error message:
Notice: Only variables should be passed by reference in
/customers/5/d/b/tsoft.se/httpd.www/kanban/system/codeigniter/Common.php
on line 148
A PHP Error was encountered Severity: Notice
Message: Only variables should be passed by reference
Filename: codeigniter/Common.php
Line Number: 148
**Note : Line 148 is this return $_classes[$class];
As stated in a comment on this github issue, since you are using CodeIgniter version 3.1.10, you need to replace your system folder.
The file system/codeigniter/Common.php has been moved to system/core/Common.php on your version.

How does one define a PECL bbcode extension callback when writing a CodeIgniter library?

I'm writing a CodeIgniter library around PHP's bbcode PECL extension, but I'm having some trouble with callbacks.
I set up the handler in the library constructor:
function __construct() {
$basic = array(
'url' => array(
'type' => BBCODE_TYPE_OPTARG,
'open_tag' => '<a href="{PARAM}" rel="nofollow">',
'close_tag' => '</a>',
'childs'=>'i,b,u,strike,center,img',
'param_handling' => array($this, 'url')
)
);
$this->handler = bbcode_create($basic);
}
public function parse($bbcode_string) {
return bbcode_parse($this->handler, htmlentities($bbcode_string));
}
As you notice, this uses a callback for handling what's allowed to go into the URL. I use this to insert an "exit redirect" page
public static function url($content, $argument) {
if (!$argument) $argument = $content;
$url = parse_url($argument);
if (!isset($url['host'])) {
if (strlen($argument) > 0 && $argument[0] != '/') return false;
$destination = '//'.$_SERVER['HTTP_HOST'].$argument;
} elseif ($url['host'] != $_SERVER['HTTP_HOST']) {
$destination = '//'.$_SERVER['HTTP_HOST'].'/exit?'.urlencode($argument);
} else {
$destination = $argument;
}
return htmlspecialchars($destination);
}
And I also have a little function which helps me test this out as I work:
function test() {
$string = '[url]http://www.google.com[/url]';
echo '<pre>';
die($this->parse($string));
}
This all works fine if the test() method is called from within the library. For example, if I throw $this->test() at the bottom of the constructor, everything works exactly as I would expect. However, calling $this->bbcode->test() from somewhere else (e.g. in a controller), I get the following errors:
**A PHP Error was encountered**
Severity: Warning
Message: Invalid callback , no array or string given
Filename: libraries/bbcode.php
Line Number: 122
**A PHP Error was encountered**
Severity: Warning
Message: bbcode_parse(): function `' is not callable
Filename: libraries/bbcode.php
Line Number: 122
http://www.google.com
The callback does not get executed, and as a result the link's href attribute is empty. Line 122 refers to the single line of code in my parse function:
return bbcode_parse($this->handler, htmlentities($bbcode_string));
How do I address this callback function such that it can be located when $this->bbcode->test() is called from inside a controller?
Now I'm even more confused...
So in the hopes of just putting this all behind me, I put these callback functions in a helper so I can just call them directly. So I now have code like this:
function __construct() {
$basic = array(
'url' => array(
'type' => BBCODE_TYPE_OPTARG,
'open_tag' => '<a href="{PARAM}" rel="nofollow">',
'close_tag' => '</a>',
'childs'=>'i,b,u,strike,center,img',
'param_handling' => 'bbcode_url'
)
);
$this->handler = bbcode_create($basic);
}
With the above, I get the following error:
**A PHP Error was encountered**
Severity: Warning
Message: Invalid callback 6.7949295043945E-5, no array or string given
Filename: libraries/bbcode.php
Line Number: 176
**A PHP Error was encountered**
Severity: Warning
Message: bbcode_parse(): function `6.7949295043945E-5' is not callable
Filename: libraries/bbcode.php
Line Number: 176
(line 176 is the new location of the parse() function)
Um... I don't even know what's going on. The number 6.7949295043945E-5 changes with every attempt.
The only solution I have found to this is quite simply not to set the handler up in a constructor. Instead, the parse() method contains both the bbcode_create() call and the bbcode_parse() call. That is, the bbcode_handler is freshly created for every string of bbcode to be parsed.
This seems needlessly wasteful to me. But, over the course of the lifetime of this project, it is exceedingly unlikely to cost even a tenth of the amount of time that I have spent trying to sort this out "properly", so I'm calling it a day.
I'm posting this "solution" here in case somebody else happens across this question and can thereby save themselves a few hours' pain. That said, I would really like to know what on earth is going on, and how to do this properly.

Fatal error: Declaration of EasyBlogTableMediaManager::bind() must be compatible with that of JTableInterface::bind()

I have a problem with easyblog. When I try to open a blog entry through backend I get the following error:
Fatal error: Declaration of EasyBlogTableMediaManager::bind() must be compatible with that of JTableInterface::bind() in /home/mysit/public_html/localadvertiser/administrator/components/com_easyblog/tables/mediamanager.php on line 46
I am running Joomla 3.2.5
The error reporting is set to 'maximum'. Any idea what the issue could be here?
This is file where the error occurs
class EasyBlogTableMediaManager extends EasyBlogTable
{
var $id = null;
var $path = '';
var $type = '';
var $params = '';
function __construct(& $db )
{
parent::__construct( '#__easyblog_mediamanager' , 'id' , $db );
}
public function bind( $data = array() )
{
return parent::bind( $data );
}
public function load( $path , $type )
{
$db = EasyBlogHelper::db();
$query = 'SELECT * FROM ' . EasyBlogHelper::getHelper( 'SQL' )->nameQuote( $this->_tbl );
$query .= ' WHERE ' . EasyBlogHelper::getHelper( 'SQL' )->nameQuote( 'path' ) . '=' . $db->Quote( $path );
$query .= ' AND ' . EasyBlogHelper::getHelper( 'SQL' )->nameQuote( 'type' ) . '=' . $db->Quote( $type );
$db->setQuery( $query );
$obj = $db->loadObject();
return parent::bind( $obj );
}
}
TLDR
Yes I think the error is occurring because you have error reporting set to maximum, which is probably forcing a STRICT mode, if you set the level to None it should work fine, as this will set display_errors to 0. This is also, probably, an indication you're using PHP 5.4 or higher on your server (A Good Thing™).
Longer & more precise:
As the error states the Declaration of EasyBlogTableMediaManager::bind() must be compatible (i.e. the same/match) with the original declaration in the JTableInterface class.
This tells us that EasyBlogTableMediaManager which extends EasyBlogTable has as a parent class going back to JTable (found at /libraries/joomla/table/table.php) which is defined as:
abstract class JTable extends JObject implements JObservableInterface, JTableInterface
You will notice that it implements JTableInterface, which means that the original JTable->bind() must match the interface declaration of JTableInterface (found at /libraries/joomla/table/interface.php) you will see that it's defined in the interface file as:
public function bind($src, $ignore = array());
When you compare that to the declaration in the EasyBlogTableMediaManager class you've provided:
public function bind( $data = array() )
{
return parent::bind( $data );
}
You can see the method signatures are different (i.e. the EasyBlog bind() method is only defining a single parameter $data). So, quoting the PHP documentation for interface linked previously:
Note: The class implementing the interface must use the exact same
method signatures as are defined in the interface. Not doing so will
result in a fatal error.
Between Joomla 2.5.x and Joomla 3.x several method signatures changed, given that it's a major version number change this is to be expected and developers can produce separate extension builds for each version to avoid this issue but it does introduce an extra layer of support.
If you need Error Reporting on Maximum
You may be able to fix it by simply changing the method signature to this:
public function bind( $data = array(), $ignore = array())
{
return parent::bind( $data );
}
However, that may result in the error moving further up the class hierarchy, and will probably re-appear if you update the version of EasyBlog (as your change will be over-written). It's probably best to take it up with the developer of EasyBlog.
Fixed!
I used the following code
public function bind( $data = array(), $ignore = array())
{
return parent::bind( $data );
}
Which gave a standards violation error
In order to fix this I needed to make the following changes to the load function's declaration by adding additional parameters to the EasyBlogTableMediaManager class -
public function load($path = '' , $type = '' , $keys = null, $reset = true )

Fatal error: Call to a member function isUploaded() on a non-object [duplicate]

This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 8 years ago.
I'm facing an error message:
Fatal error: Call to a member function isUploaded() on a non-object in /www/htdocs/nether/http/123factuur/application/controllers/Helpers/ImportXls.php on line 30
To my understanind this error message pops-up because I'm calling a method which doesn't exists in the object. But I'm sure that isUploaded() does exists.
The function isUploaded is defined in the class Zend_Form_Element_File. To check if $xls is an instance of the Zend_Form_Element_File I debugged the $xls variable.
Zend_Debug::dump($xls); //OUTPUT: object(Zend_Form_Element_File)#141 (29) {
exit;
Line 30 looks like this:
if ( $xls->isUploaded() ) {
The first thing I did was to check the expression value.
Zend_Debug::dump($xls->isUploaded()); //the output was: bool(true)
exit;
Then I checked the type of the $xls variable.
echo gettype($xls); //the output was object
exit;
I'm not fully understanding the error. Perhaps, I'm not interpreting the error message as it should be interpreted. Anyway, assistance is needed.
The code snippet:
At the controller:
public function importAction() {
$form = $this->getImportFrom();
$this->view->form = $form;
$this->view->allowedHeaders = array();
$this->importInvoices($form);
$this->importInvoiceArticles($form);
$this->importInvoiceServices($form);
foreach ($this->_lookupIssues as $issue) {
$this->_flashMessenger->addMessage($issue);
}
}
public function importInvoiceArticles($form) {
$model = 'Invoice_article';
$config = Zim_Properties::getConfig($model);
$Model = new Zim_Model($model, $config->model);
$headerMapping = array_flip(array_intersect_key($Model->getHeaders(true), array_flip($this->_allowedArticleImportHeaders)));
$this->getHelper('ImportXls')->handleImport($form, $headerMapping, $Model->getName(), $this->_modelName, null, null, array($this, 'saveImportedArticleData'), 'invoiceArticle');
}
At the helper:
class F2g_Helper_ImportXls extends Zend_Controller_Action_Helper_Abstract {
public function handleImport($form, $allowedHeaders, $tableName, $modelName, $onDuplicateImportCallback, $importMethod = null, $saveMethod = null, $name = 'xls') {
if ($this->getRequest()->isPost()) {
$xls = $form->getElement($name);
if ( $xls->isUploaded() ) {
//some code
}
}
}
}
I'm quite sure that the handleImport() method is called multiple times, possibly inside a loop, probably with different values for the $name parameter. You echo the variable and die in order to debug it, which works perfectly if the provided value for $name is correct on the first run - but since you kill the script - you don't get any debug information about subsequent calls.
Make sure the object has that method before calling it. You can either call method_exists() or instanceof to make that determination.
Code:
if ($xls instanceof Zend_Form_Element_File) {
// object of correct type - continue (preferred version)
}
// or
if (method_exists($xls, 'isUploaded')) {
// avoids the error, but does not guarantee that
// other methods of the Zend_Form_Element_File exist
}
Add this to your condition to avoid the Fatal Error :
if ( !empty($xls) && is_object($xls) && $xls->isUploaded() ) {
// do your job with serenity :)
}

Categories