Warning: File_Get_Contents in php 8.1 wordpress - php

I recently changed the php version from 7.4 to 8.1
But after the change, I get an error when posting content in WordPress
You need to know that despite this error, the article will be sent, but this error has bothered me
I activated the WordPress debugger, the error was referring to the active plugin in WordPress
This line:
$pictureFile = file_get_contents($imageFilePath);
WP_DEBUG :
Fatal error: Uncaught ValueError: Path cannot be empty in /home/admin/domains/xxx.org/public_html/wp-content/plugins/mp3publisher7/mp3-post-publisher.php:113
Stack trace:
#0 /home/admin/domains/xxx.org/public_html/wp-content/plugins/mp3publisher7/mp3-post-publisher.php(113): file_get_contents()
#1 /home/admin/domains/xxx.org/public_html/wp-includes/class-wp-hook.php(310): save_mp3_post_publisher()
#2 /home/admin/domains/xxx.org/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#3 /home/admin/domains/xxx.org/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#4 /home/admin/domains/xxx.org/public_html/wp-includes/post.php(4717): do_action()
#5 /home/admin/domains/xxx.org/public_html/wp-includes/revision.php(337): wp_insert_post()
#6 /home/admin/domains/xxx.org/public_html/wp-includes/revision.php(191): _wp_put_post_revision()
#7 /home/admin/domains/xxx.org/public_html/wp-includes/class-wp-hook.php(310): wp_save_post_revision()
#8 /home/admin/domains/xxx.org/public_html/wp-includes/class-wp-hook.php(332): WP_Hook->apply_filters()
#9 /home/admin/domains/xxx.org/public_html/wp-includes/plugin.php(517): WP_Hook->do_action()
#10 /home/admin/domains/xxx.org/public_html/wp-includes/post.php(4686): do_action()
#11 /home/admin/domains/xxx.org/public_html/wp-includes/post.php(4819): wp_insert_post()
#12 /home/admin/domains/xxx.org/public_html/wp-admin/includes/post.php(426): wp_update_post()
#13 /home/admin/domains/xxx.org/public_htm/wp-admin/post.php(227): edit_post()
#14 {main} thrown in /home/admin/domains/xxx.org/public_html/wp-content/plugins/mp3publisher7/mp3-post-publisher.php on line 113
More complete code of this plugin :
$mp3FilePath = get_attached_file($_POST["mp3_file_id"]);
$thumb_id = get_post_thumbnail_id($postId);
$imageFilePath = get_attached_file($thumb_id);
$pictureFile = file_get_contents($imageFilePath);
$info = array(
"artist"=>$_POST["mp3_artist"],
"album"=>$_POST["mp3_album"],
"comment"=>$_POST["mp3_comment"],
"title"=>$_POST["mp3_caption"],
"cover_data" => array(
array (
'data'=> $pictureFile,
'picturetypeid'=> 3,
'mime'=> 'image/jpeg',
'description' => 'My Picture'
)
)
When I disable this plugin, there is no problem in posting
After deleting the following line, the problem will be solved, but some parts of the plugin will not work anymore:
// $pictureFile = file_get_contents($imageFilePath);
If anyone can please help. I can't think of anything anymore
tnx..........................

The error is not occurring with file_get_contents(), but your variable $imageFilePath is returning a null value.
Try console log echo("<script>console.log('The value of imageFilePath is : " . $imageFilePath . "');</script>");

Related

Getting an error while connecting to the BigTable using Google's PHP client library

I've created a BigTable instance in my GC account and when I'm trying to connect to it using Google's library (this is a sample code from Google's docs):
require 'vendor/autoload.php';
use Google\Cloud\Bigtable\BigtableClient;
/** Uncomment and populate these variables in your code */
$project_id = 'my_project_id';
$instance_id = 'table_instance';
$table_id = 'table_name';
// Connect to an existing table with an existing instance.
$dataClient = new BigtableClient([
'projectId' => $project_id,
]);
$table = $dataClient->table($instance_id, $table_id);
$key = 'r1';
// Read a row from my-table using a row key
$row = $table->readRow($key);
$column_family_id = 'cf1';
$column_id = 'c1';
// Get the Value from the Row, using the column_family_id and column_id
$value = $row[$column_family_id][$column_id][0]['value'];
printf("Row key: %s\nData: %s\n", $key, $value);
I'm getting an error:
Fatal error: Uncaught BadMethodCallException: Streaming calls are not supported while using the REST transport. in /srv/vendor/google/gax/src/Transport/HttpUnaryTransportTrait.php:119 Stack trace: #0 /srv/vendor/google/gax/src/Transport/HttpUnaryTransportTrait.php(63): Google\ApiCore\Transport\RestTransport->throwUnsupportedException() #1 /srv/vendor/google/gax/src/GapicClientTrait.php(479): Google\ApiCore\Transport\RestTransport->startServerStreamingCall(Object(Google\ApiCore\Call), Array) #2 /srv/vendor/google/gax/src/Middleware/CredentialsWrapperMiddleware.php(61): Google\Cloud\Bigtable\V2\Gapic\BigtableGapicClient->Google\ApiCore\{closure}(Object(Google\ApiCore\Call), Array) #3 /srv/vendor/google/gax/src/Middleware/FixedHeaderMiddleware.php(67): Google\ApiCore\Middleware\CredentialsWrapperMiddleware->__invoke(Object(Google\ApiCore\Call), Array) #4 /srv/vendor/google/gax/src/Middleware/RetryMiddleware.php(85): Google\ApiCore\Middleware\FixedHeaderMiddleware->__invoke(Object(Google\ApiCore\Call), Array) #5 /srv/vendor/google/gax/src/Middleware/OptionsFilterMiddleware.php(64): Google\ApiCore\Middleware\RetryMiddleware->__invoke(Object(Google\ApiCore\Call), Array) #6 /srv/vendor/google/gax/src/GapicClientTrait.php(462): Google\ApiCore\Middleware\OptionsFilterMiddleware->__invoke(Object(Google\ApiCore\Call), Array) #7 /srv/vendor/google/cloud-bigtable/src/V2/Gapic/BigtableGapicClient.php(357): Google\Cloud\Bigtable\V2\Gapic\BigtableGapicClient->startCall('ReadRows', 'Google\\Cloud\\Bi...', Array, Object(Google\Cloud\Bigtable\V2\ReadRowsRequest), 3) #8 [internal function]: Google\Cloud\Bigtable\V2\Gapic\BigtableGapicClient->readRows('projects/project...', Array) #9 /srv/vendor/google/cloud-core/src/ExponentialBackoff.php(80): call_user_func_array(Array, Array) #10 /srv/vendor/google/cloud-bigtable/src/ResumableStream.php(96): Google\Cloud\Core\ExponentialBackoff->execute(Array, Array) #11 /srv/vendor/google/cloud-bigtable/src/ChunkFormatter.php(168): Google\Cloud\Bigtable\ResumableStream->readAll() #12 [internal function]: Google\Cloud\Bigtable\ChunkFormatter->readAll() #13 /srv/vendor/google/cloud-bigtable/src/Table.php(331): Generator->current() #14 /srv/index.php(24): Google\Cloud\Bigtable\Table->readRow('r1') #15 {main} thrown in /srv/vendor/google/gax/src/Transport/HttpUnaryTransportTrait.php on line 119
Any help?
OK, I figured it out.
For those who facing the same problem:
create/add a line into your php.ini file:
extension=grpc.so
php.ini should be in the same directory with app.yaml

How do I make a successfull callback for a mediawiki extension hook?

I have the following code in my extension.hooks.php file:
public static function onEditFormPreloadText( &$text, &$title )
return true;
}
the 'return true;' should tell Mediawiki to continue regularly with generating the create page, but I am getting the following error that I simply can't wrap my head around.
[59f7b43514fbe1ec0988f3b0] /mediawiki/index.php?title=newwikipage&action=edit&redlink=1
MWException from line 176 of
...\mediawiki\htdocs\includes\Hooks.php:
Invalid callback AutoLinkerHooks::onEditFormPreloadText in hooks for EditFormPreloadText
Backtrace:
#0 ...\mediawiki\htdocs\includes\EditPage.php(628): Hooks::run(string, array)
#1 ...\mediawiki\htdocs\includes\actions\EditAction.php(59): EditPage->edit()
#2 ...\mediawiki\htdocs\includes\MediaWiki.php(495): EditAction->show()
#3 ...\mediawiki\htdocs\includes\MediaWiki.php(289): MediaWiki->performAction(Article, Title)
#4 ...\mediawiki\htdocs\includes\MediaWiki.php(851): MediaWiki->performRequest()
#5 ...\mediawiki\htdocs\includes\MediaWiki.php(512): MediaWiki->main()
#6 ...\mediawiki\htdocs\index.php(43): MediaWiki->run()
#7 {main}
I have no idea where the function goes wrong since I've read the documention about 5 times right now, but perhaps I'm just missing something.
Mediawiki-documentation that I used: Manual:Developing_extensions | Manual:Hooks
It turns out I had a spelling error within my extension.json files. . . .
"AutoloadClasses": {
"AutoLinkrHooks": "AutoLinker.hooks.php"
},
Oops.

Give an error before refreshing in ZF

Hi i am new in Zend Framework. i am working with existing project.
Here,
$url = $this->view->url(array('controller' => $user->status), 'default', true);
$url = $this->_getParam('url', $url);
$this->_redirect($url);
it is redirected to another page but there i get following error:
Exception information:
Message: Mysqli statement execute error : No data supplied for parameters in prepared statement
Stack trace:
#0 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Db\Statement.php(300): Zend_Db_Statement_Mysqli->_execute(Array)
#1 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Db\Adapter\Abstract.php(479): Zend_Db_Statement->execute(Array)
#2 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Db\Table\Abstract.php(1526): Zend_Db_Adapter_Abstract->query(Object(Zend_Db_Table_Select))
#3 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Db\Table\Abstract.php(1388): Zend_Db_Table_Abstract->_fetch(Object(Zend_Db_Table_Select))
#4 C:\web\Apache2\htdocs\application\modules\default\controllers\generalController.php(24): Zend_Db_Table_Abstract->fetchRow(Object(Zend_Db_Table_Select))
#5 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Controller\Action.php(513): generalController->indexAction()
#6 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('indexAction')
#7 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#8 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#9 C:\web\Apache2\php\Zend\1.11.3\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#10 C:\web\Apache2\htdocs\public\index.php(59): Zend_Application->run()
#11 {main}
but if i refresh page everything get OK, i dont get error
i can not understand what is the problem
can anyone help me please?

Pagination error when upgrade from cakephp 1.3 to 2.0

I am upgrading cakephp 1.3 to 2.0
I am getting below error in error log
Error: [MissingTableException] Table aros_acos for model Permission was not found in datasource default.
Exception Attributes: array (
'table' => 'aros_acos',
'class' => 'Permission',
'ds' => 'default',
)
Request URL: /users/show?%2Fusers%2Fshow=
Stack Trace:
#0 /lib/Cake/Model/Model.php(3498): Model->setSource('aros_acos')
#1 /lib/Cake/Model/Datasource/DboSource.php(1063): Model->getDataSource()
#2 /lib/Cake/Model/Model.php(2902): DboSource->read(Object(User), Array)
#3 /lib/Cake/Model/Model.php(2874): Model->_readDataSource('count', Array)
#4 /app/Controller/Component/PaginationComponent.php(212): Model->find('count', 'status!='DL'')
#5 /app/Controller/UsersController.php(108): PaginationComponent->init('status!='DL'')
#6 [internal function]: UsersController->show()
#7 /lib/Cake/Controller/Controller.php(490): ReflectionMethod->invokeArgs(Object(UsersController), Array)
#8 /lib/Cake/Routing/Dispatcher.php(185): Controller->invokeAction(Object(CakeRequest))
#9 /lib/Cake/Routing/Dispatcher.php(160): Dispatcher->_invoke(Object(UsersController), Object(CakeRequest), Object(CakeResponse))
#10 /app/webroot/index.php(108): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
UsersController.php error section
$criteria = "status!='1'";
$this->Pagination->direction = 'ASC';
$this->Pagination->sortBy = 'username';
//********
$this->Pagination->setPageLimit($page_limit);
list($order, $limit, $page) = $this->Pagination->init($criteria); // Added
PaginationComponent.php
$count = $this->controller->{$this->modelClass}->find('count', $criteria);
Please let me know what is going wrong.
Thanks,
Have you even tried to read and understand the error message? Debugging starts by reading (and understanding) error messages if you get some.
[MissingTableException] Table aros_acos for model Permission was not found in datasource default.
That means that the table aros_acos doesn't exist in your database.

redirecting from admin page to a postAction on frontend

Edited code: now I'm not receiving the 404 Error but on the other hand there is nothing added on the database or on exception logs.
I need to call from my model php file a postAction function on a third part module (VideoTestimonials from aheadWorks) in order to reuse all their code to get the needed functionalities and avoid future bugs if I just copied the code and modified at will.
On a previous question I was pointed on the, I guess, right direction to accomplish this goal by using setRedirect. Here is the code I'm using on my php model file to try to redirect to the postAction on the frontend:
<?php
class Dts_Videotestimonials_Model_SearchVideo extends Mage_Core_Model_Abstract
{
function printVideoEntry($videoEntry, $_product, $tabs = "")
{
# get user data
$user = Mage::getSingleton('admin/session');
$userName = $user->getUser()->getFirstname();
$userEmail = $user->getUser()->getEmail();
$data = array(
"ProductId" => $_product->getId(),
"AuthorEmail" => $userEmail,
"AuthorName" => $userName,
"VideoLink" => $videoEntry->getVideoWatchPageUrl(),
"VideoType" => "link",
"Title" => $videoEntry->getVideoTitle(),
"Comment" => "this is a comment"
);
$actionUrl = Mage::getUrl('vidtest/youtube/post', $data);
Mage::app()->getResponse()->setRedirect($actionUrl);
}
}
All the modifications to get here where ok, step by step (with help of #Francesco) I got to this point. But when I make this call I'm receiving a 404 Error. What is wrong?
I was looking into this SO question/answer and this post on the Magento forum but can't make my self clear. The second one is a redirect from an event Observer, I do not know exactly if it can help.
Here is the full exception log on this error:
2012-09-04T14:25:17+00:00 ERR (3):
exception 'Zend_Controller_Response_Exception' with message 'Invalid HTTP response code' in C:\wamp\www\magento\lib\Zend\Controller\Response\Abstract.php:286
Stack trace:
#0 C:\wamp\www\magento\lib\Zend\Controller\Response\Abstract.php(150): Zend_Controller_Response_Abstract->setHttpResponseCode(Array)
#1 C:\wamp\www\magento\app\code\core\Mage\Core\Controller\Response\Http.php(106): Zend_Controller_Response_Abstract->setRedirect('http://127.0.0....', Array)
#2 C:\wamp\www\magento\app\code\local\Dts\Videotestimonials\Model\SearchVideo.php(64): Mage_Core_Controller_Response_Http->setRedirect('http://127.0.0....', Array)
#3 C:\wamp\www\magento\app\code\local\Dts\Videotestimonials\Model\SearchVideo.php(198): Dts_Videotestimonials_Model_SearchVideo->printVideoEntry(Object(Zend_Gdata_YouTube_VideoEntry), Object(Mage_Catalog_Model_Product))
#4 C:\wamp\www\magento\app\code\local\Dts\Videotestimonials\Model\SearchVideo.php(244): Dts_Videotestimonials_Model_SearchVideo->printVideoFeed(Object(Zend_Gdata_YouTube_VideoFeed), Object(Mage_Catalog_Model_Product), 'Search results ...')
#5 C:\wamp\www\magento\app\code\local\Dts\Videotestimonials\controllers\Adminhtml\VideotestimonialsbackendController.php(28): Dts_Videotestimonials_Model_SearchVideo->searchAndPrint('s')
#6 C:\wamp\www\magento\app\code\core\Mage\Core\Controller\Varien\Action.php(419): Dts_Videotestimonials_Adminhtml_VideotestimonialsbackendController->postAction()
#7 C:\wamp\www\magento\app\code\core\Mage\Core\Controller\Varien\Router\Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('post')
#8 C:\wamp\www\magento\app\code\core\Mage\Core\Controller\Varien\Front.php(176): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#9 C:\wamp\www\magento\app\code\core\Mage\Core\Model\App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#10 C:\wamp\www\magento\app\Mage.php(683): Mage_Core_Model_App->run(Array)
#11 C:\wamp\www\magento\index.php(87): Mage::run('', 'store')
#12 {main}
you using getUrl and getBaseUrl and it's the same thing, you can use this code:
$this->_redirect('module/controller/action','parameters');
but u have extends Mage_Adminhtml_Controller_Action on your class. its the best way. if isn't a controller so u shouldn't do this redirect.

Categories